Jump to content
  • Advertisement
Sign in to follow this  
blake_

Trying to load a Bitmap for a Texture.. Visual problems? (OpenGL)

This topic is 3790 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

After reading about glaux had memory leaks I decided to write my own function to load bitmaps and create a texture out of them... HLOCAL LMem = NULL; BITMAP Bm; BITMAPINFO Bmi; Bmpfile[TexPos] = LoadImage(NULL, (LPCSTR)Bmp, IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE); if (!Bmpfile[TexPos]) { Error("Failed to open specified texture."); return FALSE; } GetObject(OGLDef.Bmpfile[TexPos], sizeof(BITMAP), &Bm); Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); Bmi.bmiHeader.biWidth = Bm.bmWidth; Bmi.bmiHeader.biHeight = Bm.bmHeight; Bmi.bmiHeader.biPlanes = 1; Bmi.bmiHeader.biBitCount = Bm.bmBitsPixel; Bmi.bmiHeader.biCompression = BI_RGB; Bmi.bmiHeader.biSizeImage = ((Bm.bmWidth * Bm.bmBitsPixel + 31) & ~31) / 8 * Bm.bmHeight; Bmi.bmiHeader.biXPelsPerMeter = 0; Bmi.bmiHeader.biYPelsPerMeter = 0; Bmi.bmiHeader.biClrUsed = 0; Bmi.bmiHeader.biClrImportant = 0; LMem = LocalAlloc(LMEM_FIXED, Bmi.bmiHeader.biSizeImage); SecureZeroMemory(LMem, Bmi.bmiHeader.biSizeImage); GetDIBits(hDC, (HBITMAP)Bmpfile[TexPos], 0, Bm.bmHeight, LMem, &Bmi, DIB_RGB_COLORS); glGenTextures(1, &TexId[TexPos]); glBindTexture(GL_TEXTURE_2D, TexId[TexPos]); glTexImage2D(GL_TEXTURE_2D, 0, 3, Bm.bmWidth, Bm.bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, LMem); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (TexPos < 3) TexPos++; LocalFree(LMem); return TRUE; } But, when I get to the part of applying the texture to my QUAD, its all very messed up. The first screen shot is the actual bitmap, the second screen shot is what the texture looks like when applied onto my QUAD.. How do I fix this? http://img244.imageshack.us/my.php?image=frontyw4.png http://img244.imageshack.us/my.php?image=errorai4.png

Share this post


Link to post
Share on other sites
Advertisement
If anyone wants to help me tackle this I provided a link to my project.. It's compiled with Visual C++ 2008 on Windows XP Pro SP2. Files included:

front.bmp // Bitmap (Texture)
OpenGL_New.cpp // C++ file
OpenGL_Start.vcproj // VC++ 2008 Project
OpenGL_Start.exe

http://www.megafileupload.com/en/file/63302/OpenGL3D-rar.html

Anyways, thanks for any help...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!