For the IDE, I’m using codeBlocks. For the tutorial, yes I’m trying to run it using their data and it compiles but when I run it I get a black screen.
Here’s the code: (I tried to post the whole code but I kept getting the message " post denied, new users are limited…")
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
/* register window class */
.....
/* create main window */
......
int M[8][8] ={
{ 0, 0, 0, 0,0,0,0,0,0 },
{ 1, 1, 1, 1,1,1,1,1,1 },
{ 1, 3, 2, 3,3,4,2,1,1 },
{ 1, 2, 1, 2,2,2,2,1,1 },
{ 1, 2, 1, 2,2,2,2,1,1 },
{ 1, 2, 1, 2,2,2,2,1,1 },
{ 1, 2, 2, 3,3,3,3,2,1 },
{ 1, 2, 2, 3,4,4,3,3,1 },
{ 1, 2, 1, 1,1,1,1,1,1 },
{ 0, 1, 1, 1,1,1,1,1,1 } };
/* enable OpenGL for the window */
EnableOpenGL(hwnd, &hDC, &hRC);
/* program main loop */
while (!bQuit)
{
/* check for messages */
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
/* handle or dispatch messages */
if (msg.message == WM_QUIT)
{
bQuit = TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
int x;
int z;
int MAP_SIZE = 10;
glPushMatrix();
for ( x = 1; x < MAP_SIZE-1; x++) {
for (z = 1; z < MAP_SIZE-1; z++) {
glBegin(GL_QUADS);
glVertex3f( x, M[x][z] , z );
glVertex3f( x+1, M[x+1][z] , z );
glVertex3f( x+1, M[x+1][z+1], z + 1);
glVertex3f( x, M[x][z+1] , z + 1);
glEnd();
}
}
glPopMatrix();
SwapBuffers(hDC);
theta += 1.0f;
Sleep (1);
}
}
/* shutdown OpenGL */
DisableOpenGL(hwnd, hDC, hRC);
/* destroy the window explicitly */
DestroyWindow(hwnd);
return msg.wParam;
}