Just started working on your lessons, i'm using Visual C++ 6.0... i'v completed both lesson 1 and 2, but when i try to BUILD the exe file... i get the following error message.... -----------Configuration: lesson1 - Win32 Debug-------------- Compiling... lesson.cpp c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void' c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found Error executing cl.exe. lesson1.exe - 3 error(s), 0 warning(s) i've proofread all my code, that i typed in by hand... and i've also downloaded the sample codes (for vc++ at the bottom of each lesson page) and when i try to build the exe from the code, on either, mine or the downloaded, i get this error... i can't find out whats wrong, i was thinking maybe you guys could let me know whats wrong... Heres the code i've typed up:
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
HGLRC hRC=NULL;
HDC hDC=NULL;
HWND hWnd=NULL;
HINSTANCE hInstance;
bool keys[256];
bool active=TRUE;
bool fullscreen=TRUE;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
GLvoid ReSizeGLScene(GLSizei width, GLsizei height)
{
if (height==0)
{
height=1;
}
gViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Calculate the aspect ration of the window
gluPerspective(45.0f, (GLfload)width/ (GLfload)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int InitGL(GLvoid); // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); //enables smooth shading
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //background color--this is equal to black
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return TRUE;
}
int DrawGLScene(GLVOID);
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f,0.0f);
glEnd();
glTranslatef(3.0f,0.0f,0.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
if (keys[VK_F1])
{
keys[VK_F1]=FALSE;
KillGLWindow();
fullscreen=!fullscreen;
if (CreateGLWindow("Nehe's First Polygon Tutorial!",640,480,16,fullscreen))
{
return 0;
}
}
return TRUE;
}
GLvoid KillGLWindow(GLvoid)
{
if (fullscreen)
{
ChaneDisplaySettings(NULL,0);
ShowCursor(TRUE);
}
if(hRC)
{
if (!wglMakeCurrent(NULL,NULL))
{
MessageBox(NULL,"Release of DC and RC failed!","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC))
{
MessageBox(NULL,"Release Rendering Context Failed!","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC-NULL;
}
if (hDC && !ReleaseDC(hWnd,hDC))
{
MessageBox(Null,"Release Device Context Failed!",SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL;
}
if (hWnd && !DestroyWindow(hWnd))
{
MessageBox(NULL,"Could not release hWnd!","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd-NULL;
}
if (!UnregisterClass("OpenGL,hInstance))
{
MessageBox(NULL,"Could not unregister class!","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
HiNSTANCE=null;
}
}
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
GLunit PixelFormat;
WNDCLASS wc;
DWORD dwExstyle;
DWORD dwstyle;
RECT WindowRect;
WindowRect.left=(long)0;
WindowRect.Right=(long)width;
WindowRect.Top=(long)0;
WindowRect.Bottom=(long)Height;
fullscreen=fullscreenflag;
hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hicon = LoadIcon(NULL,IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.ipszClassname = "OpenGL";
if (!RegisterClass(&wc))
{
MessageBox(NULL,"Failed to register the window class!","ERROR",MB_OK|MB ICONEXCLAMATION);
return FALSE;
}
if (fullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelswidth =width;
dmScreenSettings.dmPelsheight =height;
dmScreenSettings.dmbitsperpel =bits;
dmScreenSettings.dmfields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
IF (cHANGEdISPLAYsETTINGS(&dmScreenSettings,CDS_FULLSCREEN) !=DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE;
}
else
{
MessageBox(NULL."Program will now close!",ERROR",MB_OK|MB_ICONSTOP);
return FALSE;
}
}
}
if (fullscreen)
{
dwEXstyle=WS_EX_APPWINDOW;
dwstyle=WS_POPUP;
ShowCursor(FALSE);
}
else
{
dwExstyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwstyle=WS_OVERLAPPEDWINDOW;
}
AdjustWindowRectEx(&WindowRect, dwstyle, FALSE, dwExstyle);
if (!(hWnd=CreateWindowEx( dwEsstyle,
"OpenGL",
title,
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN |
dwstyle,
0,0
WindowRect.right-WindowRect.left,
windowRect.bottom-WindowRect.top,
NULL,
hInstance,
NULL)))
{
KillGLWindow();
MessageBox(NULL,"Window creation Error!","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
static PIXELFORMATDESCRIPTIOR pdf=
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PDF_DRAW_TO_WINDOW |
PDF_SUPPORT_OPENGL |
PDF_DOUBLEBUFFER,
PDF_TYPE_RGBA,
bits,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
if (!(hDC=GetDC(hWnd)))
{
KillGLWindow();
MessageBox(NULL,"Can't Create a GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
{
KillGLWindow();
MessageBox(NULL,"Can't Find a suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
}
if(!SetPixelFormat(hDC,PixelFormat,&pfd))
{
KillGLWindow();
MessageBox(NULL,"Can't Set The PixelFormat!","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if (!(hRC=wglCreateContext(hDC)))
{
KillGLWindow();
MEssagebox(NULL,"Can't Create a GL Rendering Contxt!","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if(!wglMakeCurrent(hDC,hRC))
{
KillGLWindow();
MessageBox(NULL,"Can't Activate the GL Rendering context!"."ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
ShowWindow(hWnd,SW_SHOW);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
ResizeGLScene(width, height);
if (!InitGL())
{
KillGLWindow();
MessageBox(NULL,"Initialization Failed!","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_ACTIVATE:
{
if (!HIWORD(wParam))
{
active=TRUE;
}
else
{active=FALSE;
}
return 0;
}
case WM_SYSCOMMAND:
{
switch (wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break;
}
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
}
case WM_KEYDOWN:
{
keys[wParam] = TRUE;
return 0;
}
case WM_KEYUP:
{
keys[wParam] = FALSE;
return 0;
}
case WM_SIZE:
{
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
return 0;
}
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
BOOL done=FALSE;
if (MessageBox(NULL,"Would you like to run in Fullscreen Mode?","Start Fullscreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
Fullscreen=FALSE;
}
if (!CreateGLWindow("Evulart's OpenGL Framework",800,600,16,fullscreen))
{
return 0;
}
while(!done)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
done=TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
if (active)
{
if(keys[VK_ESCAPE])
{
done=TRUE;
}
else
{
DrawGLScene();
SwapBuffers(hDC);
}
}
if (keys[VK_F1])
{
keys[VK_F1]=False;
KillGLWindow();
Fullscreen=!fullscreen;
if (createGLWindow(Evulart's OpenGL Framework",800,600,16,fullscreen))
{
return 0;
}
}
}
}
KillGLWindow();
return (msg.wParam);
}
I ran down the entire lessons, reading each "Note" that was placed before each section of code... read over the code, then typed it up, into VC++.