int LoadTextures(int TextureSet) // Load Bitmaps And Convert To Textures
{
int StartOffset;
int TextureNum;
byte Texture[9];
if (TextureSet > 0)
LoadNewTexture = TextureSet;
if (LoadNewTexture == 1)
{
Texture [0] = IDB_Title;
Texture [1] = IDB_SHead;
Texture [2] = IDB_SBody;
Texture [3] = IDB_SBody2;
Texture [4] = IDB_SBody3;
Texture [5] = IDB_SEye;
StartOffset = 0;
TextureNum = 6;
}
else if (LoadNewTexture == 2)
{
Texture [1] = IDB_UDLR;
Texture [2] = IDB_WASD;
Texture [3] = IDB_Logo;
Texture [4] = IDB_Select;
Texture [5] = IDB_Cursor;
Texture [6] = IDB_KeyMask;
Texture [7] = IDB_SelectMask;
Texture [8] = IDB_CursorMask;
StartOffset = 1;
TextureNum = 8;
}
glDeleteTextures (8, &texture[1]); // where texture = "GLuint texture[9];"
glGenTextures(8, &texture[StartOffset]);
StartOffset = 1 - StartOffset;
for (int loop = 1; loop <= TextureNum; loop++)
{
HBITMAP hBMP;
BITMAP BMP;
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(Texture[loop]),
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (hBMP)
{
GetObject(hBMP, sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glBindTexture(GL_TEXTURE_2D, texture[loop-StartOffset]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3,
BMP.bmHeight, BMP.bmWidth,
0, GL_BGR_EXT, GL_UNSIGNED_BYTE,
BMP.bmBits);
DeleteObject(hBMP);
}
}
LoadNewTexture = 0;
}
Illegal error in texture load
Hi. Ive been writing a simple game. Part of it is naturally loading textures, which worked fine. Ive just included the bmps in a resource. Im pretty sure Ive done this right, because I did it just like I did in another project. Unfortunately, having made the appropriate changes, I keep getting illegal errors. Below is a slightly abbreviated version of the texture loading code (there are more texture loading states in the actual code). In the main program, the procedure is called with LoadNewTexture as 1, which runs fine, then as 2. Here it invariably crashes out with an illegal error after going through the for loop 5 times. What could this be? Im open to any suggestions....
Thanks
zoidy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement