Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: AnimalMother on July 03, 2008
-
Hi folks.
I would like to include gfx stuff in the executeable but I don´t want to do it with resources.
Is it possible?
-
Hi AnimalMother!
just use the small attached toolI made to turn your data (gfx/music/etc) into an array of bytes usable in C/C++. just put your "byte" data type and array name. Also this tool has a small bug as it adds the end of file code (-1) at the end of the array (0xffffffff value at the very end of the array).
you may need to change the settings of your compile to give it more memory for the precompiler headers (if you include large arrays of data).
Good luck!
-
Yes this tool comes quite handy, but for example OpenGl requires a diffrent gfx format. I read about the raw format or do I have to include a bmp and convert it?
-
OpenGL only takes RAW data from memory => the tool I gave you converts any file into an array of bytes.
If you have BMP files, consider converting them with Photoshop, or whatever freeware tool into RAW format => which is basically only the bytes containing the data, no metadata, no formatting, etc.
Use this tool: http://www.xnview.com/ (XNview, freeware) to convert your files into RAW data. then my tool to convert the RAW data into an array of bytes for C/C++. there you go.
BTW, why do people (including me?) write RAW with capital letters??? it's not an acronym at all. it should be raw files (as raw fish). This means bytes containing the data only, no metadata and special formatting.
-
Of course make sure your raw file has the same format as OpenGL expects it. This means that if you give OpenGL the data as RGB 8bit, then your raw file should have RGB pixels (interleaved format) in 8bits. This means 1byte per channel the following order:
1 byte red, 1 byte green, 1 byte blue, 1 byte red, 1 byte green, 1 byte blue, 1 byte red, 1 byte green, 1 byte blue, 1 byte red, 1 byte green, 1 byte blue, ...
...
1 byte red, 1 byte green, 1 byte blue, 1 byte red, 1 byte green, 1 byte blue, 1 byte red, 1 byte green, 1 byte blue
ordering pixels from top to bottom or bottom to top, or right to left, etc does not make a difference since you can change that very easily with OpenGL. Just order the pixels in a way that makes it easy for you to understand/compute U/V coordinates for your texture. Personally I prefer left to right, top to bottom. More logical to me. It's a question of taste.
Before you jump into daisy-chaining conversions etc, try to update your texxture with the contents of a buffer in memory. Once you have done that, go to the conversion step. In order to simplify debugging, try with some stupid patern that you can understand, such as a gradient, a 1-pixel black & white checkerboard, etc. Make sure this works and then try with a picture.
The reason I'm saying this it's because OpenGL is a state machine. If you do not set your state correctly before your draw/paint, then the results may not be the ones you have expected.
So make sure the basics work first.
-
Ahh ok I´ll give it a try. Thank you very much !!!
BTW: Maybe RAW looks more dangerous than raw. Or maybe capitals are more 3l337 style ::)
-
You are welcome!
Of course some stupid marketing poeple have invented the RAW format name to designate the native file formats of their still picture/motion picture cameras.
Of course this is bad becase these formats are not raw, they have a specific format and contain the camera metadata. However "most" of the time the image data is stored in the file as it comes off the camera CCD... anyway.
-
just use the small attached toolI made to turn your data (gfx/music/etc) into an array of bytes usable in C/C++. just put your "byte" data type and array name. Also this tool has a small bug as it adds the end of file code (-1) at the end of the array (0xffffffff value at the very end of the array).
@stormbringer: try this one (attached), there's no bug in it :)
-
Thanks mate! you are correcting all my bugs these days ;)
-
Now, it works !
BTW: I found another tool that does the same but automatically adds array type & name and the size. Just for the lazy ones like me ;)
-
Hi
another way is to use Jim's DirectX LOader (http://dbfinteractive.com/index.php?topic=2760.0)
and use that returned mem and generate an OPENGL- texture in BGRA-Format.
Its very small, but only for use under Windows.
-
Now I´am stuck again. :(
Can someone provide me with a sample for drawing text with a bitmap font like the amiga bitmap fonts?
-
What's wrong with Nehe's (http://nehe.gamedev.net/lesson.asp?index=03) ?
-
Nothing except it uses the standard system fonts. I would like to use a custom font which is stored in a picture for example. Like this one attached.
-
If you already have a texture with the required characters, all you need to do is to draw a quad with the appropriate texture-coordinates (to get those you just need to map the character's pixel-positions [0..textureSizeInPixels] to 0..1).
-
Take a look at this tutorial (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17), more specifically at "BuildFont" and "glPrint" subroutines, you can easily adapt it to your program.
-
Thanks. Now things become clearer ;D
-
can you give an example of how to use bin2c please?
-
At the command prompt, type:
bin2c inputfile output.cpp
-
i tried that, but it wouldnt save the file. maybe a vista thing.
I read a few messages up a bit about specifying the byte and arrayname.
-
Maybe try running it on your desktop?
Jim
-
when you say that do you mean adding a shortcut to the command prompt, and then travelling to the bin2c path?
-
I mean that FreeBasic is still installed in 'Program Files' and has its default project file location point there, which is bad. Under Vista and Windows 7, 'C:\', 'C:\Program Files', 'C:\WINDOWS' and a number of other areas WILL NOT let you write there unless you are logged in as Administrator. This is a good thing for security.
If you're trying to run stuff in one of these areas it could easily fail.
If you move everything into Desktop or My Documents then you might have more luck.
Jim
-
Ah ok, I get ya!
Thats one of the things I dont like about Vista, that and the change in direct3D for games.
Hence why I have an XP partition and a Vista one, for store room problems I had to decide on installing VSC++ Epress 08 onto vista as the sdks are pretty big; only little problem i've had with compiling is that sometimes it can't save the output file. I do like Vista, just a shame it was never given much of a chance, and M$ are bringing out the new one. I bought the Ultimate Edition, but that was a waste the ultimate extras where very thin on the ground and too few to mention.
So im either going to run the cmd prompt as administrator ( why it isnt I dont know as I am logged in as the administrator ), or do it when im on XP.