Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Loading OpenGL textures from resource files

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Loading OpenGL textures from resource files
#4707
Posted by: 2004-07-02 22:33:33
Hi,

I'm currently loading my openGL textures using the following code:

if (TextureImage[0]=LoadBMP("graphics/chair.bmp"))
	{

glGenTextures(1, &texture[0]);			
// Create The Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB, 
GL_UNSIGNED_BYTE,TextureImage[0]->data);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteriGL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 128, 128, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

	}
This is loading my 128x128 texture properly into memory and I can sucessfully use it later on when I am drawing.  The problem is that LoadBMP uses the auxDIBImageLoad function from the glaux library, and it will only load bmps from file, and not from a resource file.  Does anyone know how I can correctly put my BMP into memory, and what my two calls to glTexImage2D and gluBuild2DMipmaps would be that would allow me to load from a resource file instead?  I want to distribute my executable as a stand-alone package, and not with a bmp directory.
Message2. Re: Loading OpenGL textures from resource files
#4708
Posted by: upCASE 2004-07-02 22:39:43
Hi!
Use a wxImage instead of a wxBitmap. Try wxImage::GetData() :)
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: Loading OpenGL textures from resource files
#4709
Posted by: 2004-07-02 22:59:40
wow upCASE, you were absolutely right.  Thanks so much for your help.  I added these two lines:

	wxBitmap myBitmap("CHAIR_BMP");

	wxImage myImage(myBitmap.ConvertToImage());
where CHAIR_BMP was defined in my resource file, and then for the data paramater in my gl calls I used myImage.GetData(), and it works great.

Thanks again, this board is awesome.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,360.00 ·
 
 
¥271.00 ·
 
 
¥880.00 ·
 
 
¥980.00 ·
 
 
¥890.00 编辑
 
 
¥918.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0