OK, here’s a basic example.
bool keys[256];
bool LoadTextures()
{
char TexBuffer[128], Type;
short int Width, Height;
GLubyte ResA[32][32][3], ResB[64][64][3], ResC[96][96][3], ResD[128][128][3], ResE[96][64][3];
FILE *TexFile;
glGenTextures(Area.numTextures, &Texture[0]);
for(short int Loop = 0; Loop < Area.numTextures; Loop++)
{
sprintf(TexBuffer, “Textures\%s”, Area.TexList[Loop]);
if((TexFile = fopen(TexBuffer, “rb”)) == NULL)
return false;
fread(&Width, sizeof(short int), 1, TexFile);
fread(&Height, sizeof(short int), 1, TexFile);
Type = 0;
if(Width == 32 && Height == 32)
{
fread(&ResA, sizeof(ResA), 1, TexFile);
Type = 1;
}
if(Width == 64 && Height == 64)
{
fread(&ResB, sizeof(ResB), 1, TexFile);
Type = 2;
}
if(Width == 96 && Height == 96)
{
fread(&ResC, sizeof(ResC), 1, TexFile);
Type = 3;
}
if(Width == 128 && Height == 128)
{
fread(&ResD, sizeof(ResD), 1, TexFile);
Type = 4;
}
if(Width == 64 && Height == 96)
{
fread(&ResE, sizeof(ResE), 1, TexFile);
Type = 5;
}
fclose(TexFile);
if(Type == 0)
{
MessageBox(NULL, "Bad texture!", "Debug", MB_OK);
return false;
}
glBindTexture(GL_TEXTURE_2D, Texture[Loop]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if(Type == 1)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, ResA);
if(Type == 2)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, ResB);
if(Type == 3)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, ResC);
if(Type == 4)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, ResD);
if(Type == 5)
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, ResE);
}
return true;
}
bool InitGL()
{
if(!LoadTextures())
return false;
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return true;
}
LRESULT CALLBACK MainCalls(…)
{
switch(cbmsg)
{
case WM_KEYDOWN:
{
keys[cbwp] = true;
return 0;
}
case WM_KEYUP:
{
keys[cbwp] = false;
return 0;
}
}
return DefWindowProc(…);
}
int WINAPI WinMain(…)
{
bool done = false;
MSG msg;
WNDCLASS wc;
//Define and register window class
//Load custom settings
while(!done)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
done = true;
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
//Handles calling screen drawing and such
if(keys[VK_F12])
{
DestroyGLWindow();
glDeleteTextures(numTextures, Texture);
CreateGLWindow();
InitGL();
keys[VK_F12] = false;
}
}
}
return msg.wParam;
}
That should be all you need. In my “CreateGLWindow” function I have a check on every command, including pixelformat settings and the actual CreateWindowEx() command. The whole function seems to work, but the app just auto-exits for some reason.