Pages: 1
  Print  
Author Topic: DirectX Image formats and Fonts  (Read 1309 times)
Offline (Male) Goombert
Posted on: July 29, 2013, 09:15:06 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Ok well this something we need to discuss.  ENIGMA has its own code for loading various image formats, but Direct3D has a S*** TON of built in formats supported...

from...
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172801%28v=vs.85%29.aspx
".. the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga"

DirectX also has internal classes for dealing with fonts, you can simply request them by name and tell it to render, it takes like 5 lines of code...
http://www.two-kings.de/tutorials/dxgraphics/dxgraphics09.html
You can also ask it to build a mesh from font numerics and it will do so.

So this begs the question as to what to do about our fontstruct as it obviously needs moved so that its not included in our DX system when it doesn't need to be.

DirectX also provides internal classes for drawing sprites and batching them...
http://www.two-kings.de/tutorials/dxgraphics/dxgraphics09.html

Now this also leads to another thing as to whether or not we want to use those sprite functions for backgrounds as well. Not to mention in GameMaker sometimes people will apply transformations to text and sprite drawing functions to use them as 3D billboards. I would like some input from you guys Harri, forthevin, Josh.

Edit:

I have managed to get texture loading and draw_sprite implemented...

As you can see there is a tad bit of a problem, DX uses ARGB, ENIGMA loads textures into RGBA :( You can tell by the sprites pixel color being off.
« Last Edit: July 30, 2013, 02:32:51 AM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #1 Posted on: July 30, 2013, 04:23:36 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172801%28v=vs.85%29.aspx
".. the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga"
Josh was thinking about some way to specify different formats for different systems. I don't think we should get rid of one system for the other though. We could use .bmp and .png just like we have now to be consistent and in D3D implement other formats (although the implementation would probably ugly). So unless Josh explains how the format feature would work, then I don't think we should touch this for now. It's not that essential anyway.

Quote
DirectX also has internal classes for dealing with fonts, you can simply request them by name and tell it to render, it takes like 5 lines of code...
http://www.two-kings.de/tutorials/dxgraphics/dxgraphics09.html
You can also ask it to build a mesh from font numerics and it will do so.
Same as with formats. I think we can use the ones we have now until we either split it or just think of augmenting it. The font functions microsoft provide can be useful for loading fonts at runtime, so it allows creating those functions, but I don't think we should get rid of current texture fonts, as those rendered and packed in the .exe, so if you use some font which the user doesn't have, then it won't break for him. I don't think we should pack MS font files in the .exe though.

Quote
Now this also leads to another thing as to whether or not we want to use those sprite functions for backgrounds as well. Not to mention in GameMaker sometimes people will apply transformations to text and sprite drawing functions to use them as 3D billboards. I would like some input from you guys Harri, forthevin, Josh.
I thin we can use batching only for backgrounds. For sprites it would not be really possible taking into account the depth changes and dynamic nature. And as sprites are still defined as vertices then I don't see how billboards are a problem.

Quote
As you can see there is a tad bit of a problem, DX uses ARGB, ENIGMA loads textures into RGBA :( You can tell by the sprites pixel color being off.
You just specify the format when loading. I don't know which function you use, but the function which loads from files has D3DFORMAT, which allows specifying shit-ton of formats.
Logged
Offline (Male) Josh @ Dreamland
Reply #2 Posted on: July 30, 2013, 07:20:08 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
I still am uncertain what to do with formats. I think the best course of action is to assume that there are differences in the formats that will be offered by each system's base installation, and that the user will only choose extensions for codecs/formats that are missing. So basically, the LoadPNG code would go in an extension, and would register an image format reader. Before loading any image, the loader function cycles through those loaders and asks each one, "can you load this?". If the extension returns true, it is asked for the data, and the search is over. Otherwise, the next extension is asked. When all extensions have been asked, the data is handed to the base system. In GL's case, that means it's a bitmap, or you're SOL. In DirectX's case, I guess that means it's .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, or .tga, or you're SOL.

As for fonts, GL can do that, too; we don't want mesh fonts. We want nice, anti-aliased sprite fonts. When ENIGMA used meshes for its fonts, they were infinitely ugly. Moreover, you're also relying on an assumption you should certainly not be making: All computers have the font the user requested available. Turns out, not everyone has the super cool font the user picked out in the IDE that looks kind of alien-y. Guess Arial will work in its place, right? In embracing this, you also damn the font_add_sprite() function. The answer is no, no, no, no, and a thousand times, no.

I have no idea what you're asking with regard to sprites vs backgrounds. Maybe it'd help if you gave the correct link, instead of the first one twice. :P
In principle, the only difference between sprites and backgrounds is that backgrounds are not animated, are used as tilesets (meaning, are much more frequently drawn in pieces), and are more frequently tiled. If your sprite batching can accommodate that, I see no reason not to use it for both. Assuming that's what you're asking.

I promise DX can load from RGBA data.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #3 Posted on: July 30, 2013, 12:13:53 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
I still am uncertain what to do with formats. I think the best course of action is to assume that there are differences in the formats that will be offered by each system's base installation, and that the user will only choose extensions for codecs/formats that are missing. So basically, the LoadPNG code would go in an extension, and would register an image format reader. Before loading any image, the loader function cycles through those loaders and asks each one, "can you load this?". If the extension returns true, it is asked for the data, and the search is over. Otherwise, the next extension is asked. When all extensions have been asked, the data is handed to the base system. In GL's case, that means it's a bitmap, or you're SOL. In DirectX's case, I guess that means it's .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, or .tga, or you're SOL.
Guess that could work. Of course they should be prioritized and be included at compile time. Like if DirectX is used, then it will have the most priority (will be the first one to be asked) and LodePNG won't even be included, because DX already said it could load .png's. If OGL is used and no native one is included, then LodePNG will be included as it will be the first to affirm it can load .png's. Of course a way to select needed file extensions (like select .png and it will include either DX or LodePNG) or file loader extensions (if you just want .png then maybe using just LodePNG instead of DX could be better). Of course everything on Windows is shared library, so there probably be no reason (size or otherwise) to deselect DX and use LodePNG when using D3D to draw.

Quote
As for fonts, GL can do that, too; we don't want mesh fonts. We want nice, anti-aliased sprite fonts. When ENIGMA used meshes for its fonts, they were infinitely ugly. Moreover, you're also relying on an assumption you should certainly not be making: All computers have the font the user requested available. Turns out, not everyone has the super cool font the user picked out in the IDE that looks kind of alien-y. Guess Arial will work in its place, right? In embracing this, you also damn the font_add_sprite() function. The answer is no, no, no, no, and a thousand times, no.
I actually like font_add_sprite() and I have used it. Of course it won't give much for a game, but for an editor (text, image or otherwise) it is very useful. So I hate that we don't have it. Also, vector fonts can be very useful, especially when drawn on geometry and in many sizes. Even simple things like rotations make sprite fonts look like shit. Sadly I cannot fathom how much loops we need to jump trough to support both... maybe not that many.
Logged
Offline (Male) Goombert
Reply #4 Posted on: July 30, 2013, 04:13:48 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
No, Josh, DirectX does not have the format available for RGBA only ARGB or RGB, please see the Microsoft documentation...
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558%28v=vs.85%29.aspx

And I was not suggesting throwing out fonts altogether, I was just wondering if we wanted to abstract it to make use of some of these nice features of the API. Now what I meant with sprites and backgrounds is that DX provides a sprite drawing class, which I could just as easily use for the background functions, that is what the last link was about...
http://www.two-kings.de/tutorials/dxgraphics/dxgraphics09.html

Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print