Hello, Im back

. I''ve gone through my OpenGL program - or atleast I''ve gone thorough the first example of NeHe''s tutorials. I had 36 errors originally but I cut them down to 13. I don''t know how to fix these errors - I''ve had them before some I con''t seem to figure out whats wrong. So if someone could help me out by telling me what to fix and where then I would be greatful. I have posted the source code and errors below.
Thanks alot,
orcblood
Errors:
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(136) : error C2065: ''GLunit'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(136) : error C2146: syntax error : missing '';'' before identifier ''PixelFormat''
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(136) : error C2065: ''PixelFormat'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(149) : error C2039: ''Style'' : is not a member of ''tagWNDCLASS''
c:\program files\microsoft visual studio\vc98\include\winuser.h(1184) : see declaration of ''tagWNDCLASS''
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(149) : error C2065: ''CS_HREDAW'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(149) : error C2065: ''CS_VREDAW'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(209) : error C2065: ''CreateWindowEX'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(214) : error C2065: ''WS_CHIPSIBLINGS'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(215) : error C2065: ''WS_CHIPCHILDREN'' : undeclared identifier
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(223) : error C2440: ''='' : cannot convert from ''int'' to ''struct HWND__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(431) : error C2143: syntax error : missing '';'' before ''}''
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(431) : error C2143: syntax error : missing '';'' before ''}''
C:\Windows\Desktop\OrcishProductions\OrcishRendering\WinMain.cpp(431) : error C2143: syntax error : missing '';'' before ''}''
Error executing cl.exe.
/*
Source code for the main window of OrcishRendering
Below is the OpenGL code for:
Initializing the window and setting up OpenGL,
Opening and writing a .ms3d file into the assigned views,
Rendering the .ms3d model in the Rendering Window.
*/
//
// Include Files
//
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
//
// The resource files
#include "resource.h"
//
// Handles and contexts
//
HDC hDC = NULL;
HGLRC hRC = NULL;
HWND hWnd=NULL;
HINSTANCE hInstance;
//
// Flags and Arrays
//
bool keys[256];
bool active = TRUE;
bool fullscreen = TRUE;
//
// Declair WinProc
//
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//
// Resize the window and the OpenGL view
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
{
if (height == 0)
{
height = 1;
}
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// calculate the ratio of the window
gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int InitGL(GLvoid)
{
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
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();
return TRUE;
}
GLvoid KillGLWindow(GLvoid)
{
if (fullscreen)
{
ChangeDisplaySettings(NULL, 0);
ShowCursor(TRUE);
}
if (hRC)
{
if(!wglMakeCurrent(NULL, NULL))
{
MessageBox(NULL, "Release of DC and RC failed, a shutdown error has occured.", "OrcishRendering - ERROR", MB_OK|MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC))
{
MessageBox(NULL, "Reneasing the Rendering Context failed, a shutdown error has occured.", "OrcishRendering - ERROR", MB_OK|MB_ICONINFORMATION);
}
hRC = NULL;
}
if (hDC && !ReleaseDC(hWnd, hDC))
{
MessageBox(NULL, "Releasing the Device Context failed, a shutdown error has occured.", "OrcishRendering - ERROR", MB_OK|MB_ICONINFORMATION);
hDC = NULL;
}
if (hWnd && !DestroyWindow(hWnd))
{
MessageBox(NULL, "The Window Handle could not be released, a shutdown error has occured.", "OrcishRendering - ERROR", MB_OK|MB_ICONINFORMATION);
hWnd = NULL;
}
if (!UnregisterClass("OpenGL", hInstance))
{
MessageBox(NULL, "The Window Handle could not be unregistered, a shutdown error has occured.", "OrcishRendering - ERROR", MB_OK|MB_ICONINFORMATION);
hInstance = NULL;
}
}
/*
Create the OpenGL window''s parameteres
title, widht, height, bits, and the fullscreenflag.
*/
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_HREDAW | CS_VREDAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_PGRMICON),IMAGE_ICON,0,0,LR_DEFAULTSIZE);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = "IDR_MAINMENU";
wc.lpszClassName = "OpenGL";
if (!RegisterClass(&wc))
{
MessageBox(NULL, "Failure to Register the Window''s Class, an error has occured.", "OrcishRendering - 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;
//
// try setting fullscreen mode
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
// if the change fails...
if (MessageBox(NULL, "An error occured while trying to switch to FullScreenMode. Use windowed mode instead?", "OrcishRendering - Error", MB_YESNO|MB_ICONEXCLAMATION) == IDYES)
{
fullscreen = FALSE;
}
else
{
// tell the user that the program will now close
MessageBox(NULL, "The Program will not close.", "OrcishRendering - 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);
// create the window
if (!(hWnd = CreateWindowEX(
dwExStyle,
"OpenGL",
title,
dwStyle|
WS_CHIPSIBLINGS|
WS_CHIPCHILDREN,
0,
0,
WindowRect.right-WindowRect.left,
WindowRect.bottom-WindowRect.top,
NULL,
wc.lpszMenuName = "IDR_MAINMENU", // menu
hInstance,
NULL)))
{
KillGLWindow();
MessageBox(NULL, "An error occured while createing the window.", "OrcishRendering - ERROR", MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW|
PFD_SUPPORT_OPENGL|
PFD_DOUBLEBUFFER,
PFD_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, "A Device Context could not be created.", "OrcishRendering - ERROR", MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
{
KillGLWindow();
MessageBox(NULL, "A suitable PixelFormat could not be found.", "OrcishRendering - ERROR", MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if(!SetPixelFormat(hDC, PixelFormat, &pfd))
{
KillGLWindow();
MessageBox(NULL, "Unable to set a Pixel Format.", "OrcishRendering - ERROR", MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if (!(hRC = wglCreateContext(hDC)))
{
KillGLWindow();
MessageBox(NULL, "Unable to create a Rendering Context.", "OrcishRendering - ERROR", MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}
if(!wglMakeCurrent(hDC, hRC))
{
KillGLWindow();
MessageBox(NULL, "Unable to activate the GL Rendering Context.", "OrcishRendering - 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;
}
// Create Our OpenGL Window
if (!CreateGLWindow("NeHe''s OpenGL Framework",640,480,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("NeHe''s OpenGL Framework",640,480,16,fullscreen))
{
return 0;
}
}
}
}
KillGLWindow();
return (msg.wParam);
}
}