Jump to content
  • Advertisement
Sign in to follow this  

compiling files as a resource in Visual Studio...

This topic is 5393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all.. i made a few icons in photoshop to put at the top left hand part of the openGL app and have gotten tired of having to load it into the program. how would i compile it as a resource into my application? thanks!

Share this post

Link to post
Share on other sites
Just create a new bitmap/icon in the resource editor, then use copy and paste from photoshop to devstudio

Share this post

Link to post
Share on other sites
You may also need to load textures from the resources. I'll post code for in the case it helps you. Based on NeHe's tutorials, so it will fill the famous 'textures' array.

AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*2); // Set The Pointer To NULL

// load bitmap from resource file
HBITMAP bitmap = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));

// setup 24 bits bitmap structure
// works on 8 bits bitmaps also!
header.biSize = sizeof(BITMAPINFOHEADER);
header.biWidth = 256;
header.biHeight = 256;
header.biPlanes = 1;
header.biBitCount = 24;
header.biCompression = BI_RGB;
header.biSizeImage = 0;
header.biClrUsed = 0;
header.biClrImportant = 0;
info.bmiHeader = header;
info.bmiColors->rgbRed = NULL;
info.bmiColors->rgbGreen = NULL;
info.bmiColors->rgbBlue = NULL;
info.bmiColors->rgbReserved = NULL;
// store bitmap data in a vector
const int size = 256*256*3;
unsigned char data[size];
GetDIBits(hDC, bitmap, 0, 256, &data, &info, DIB_RGB_COLORS);
// convert from BGR to RGB
unsigned char buff;
for(int i=0; i<256*256; i++) {
buff = data[i*3];
if(i>=3) {
data[i*3] = data[i*3+2];
data[i*3+2] = buff;

glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, &data);


return TRUE; // Return The Status

What it does is to read the bytes from the resource and fill the AUX_RGBImageRec by hand.

Hope it helps.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!