i got this source code from a book and i dont know why i got 98 errors
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <cmath>
static int gs_iWidth = 640;
static int gs_iHeight = 480;
static HDC gs_hWindowDC = (HDC)0;
static double gs_fLFrustum = -0.5500;
static double gs_fRFrustum = +0.5500;
static double gs_fBFrustum = -0.4125;
static double gs_fTFrustum = +0.4125;
static double gs_fNFrustum = +1.0;
static double gs_fFFrustum = +100.0;
static int gs_iXPort = 0;
static int gs_iYPort = 0;
static int gs_iWPort = gs_iWidth;
static int gs_iHPort = gs_iHeight;
static double gs_adEye[3] = {0.0, 0.0, 4.0};
static double gs_adDir[3] = {0.0, 0.0, -1.0};
static double gs_adUp[3] = {0.0, 1.0, 0.0};
static double gs_adRight[3] = {1.0, 0.0, 0.0};
static float gs_afVertex0[3] = {1.0f, 0.0f, 0.0f};
static float gs_afVertex1[3] = {-1.0f, 1.0f, 0.0f};
static float gs_afVertex2[3] = {-1.0f, -1.0f, 0.0f};
static float gs_afColor0[3] = {1.0f, 0.0f, 0.0f};//rojo
static float gs_afColor1[3] = {0.0f, 1.0f, 0.0f};//verde
static float gs_afColor2[3] = {0.0f, 0.0f, 1.0f};//azul
static float gs_afTranslate[3] =
{
0.0f, 0.0f, 0.0f
};
static float gs_aafRotate[3][3]=
{
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f}
};
static float gs_afMatrix[16] =
{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
static float gs_fDPosition = 0.1f;
static float gs_afAngle = 0.1f;
static float gs_fCos = cosf(gs_afAngle);
static float gs_fSin = sinf(gs_afAngle);
static char s_acWindowClass[] = “Wild Magic Application”;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName = s_acWindowClass;
wc.lpszMenuName = NULL;
RegisterClass(&wc);
RECT kRect = ( 0, 0, gs_iWidth-1, gs_iHeight-1);
AdjustWindowRect(&kRect, WS_OVERLAPPEDWINDOW, false);
static char s_acWindowTitle[] = “Draw Triangle”;
int iXPos = 0, iYPos = 0;
int iWidth = kRect.right - kRect.left + 1;
int iHeight = kRect.bottom - kRect.top + 1;
HWND hWnd = CreateWindow(s_acWindowClass,s_acWindowTitle,
WS_OVERLAPPEDWINDOW, iXPos, iYPos,iWidth, iHeight,(HWND)0,
(HMENU)0,hInstance, NULL);
gs_hWindowDC = GetDC(hWnd);
//3D Game Engine Architecture page 7
PIXELFORMATDESCRIPTOR kPFD;
memset(&kPFD,0,sizeof(PIXELFORMATDESCRIPTOR));
kPFD.nSize = sizeof(PIXELFORMATDESCRIPTOR);
kPFD.nVersion = 1;
kPFD.nwFlags =
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_GENERIC_ACCELERATED |
PFD_DOUBLEBUFFER;
kPFD.iPixelType = PFD_TYPE_RGBA;
kPFD.cColorBits = 24;
kPFD.cDepthBits = 16;
kPFD.cStencilBits = 8;
int iPixelFormat = ChoosePixelFormat(gs_hWindowDC, &kPFD);
if(iPixelFormat == 0)
{
ReleaseDC(hWnd,gs_hWindowDC);
return -1,
}
BOOL bSuccess = SetPixelFormat(gs_hWindowDC,iPixelFormat,&kPFD);
if(!bSuccess)
{
ReleaseDC(hWnd,gs_hWindowDC);
retunr -2;
}
HGLRC hWindowRC = wglCreateContext(gs_hWindowDC);
if(!hWindowRC)
{
ReleaseDC(hWnd,gs_hWindowDC);
return -3;
}
bSuccess = wglMakeCurrent(gs_hWindowDC,hWindowRC);
if (!bSuccess)
{
wglDeleteContext(hWindowRC);
ReleaseDC(hWnd, gs_hwindowDC);
retutn -4;
}
glClearColor(0.75f,0.75f, 0.75f,1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(gs_fLFrustum,gs_fRFrustum,gs_fRFrustum,gs_fTFrustum,
gs_fNFrustum,gs_fFFrustum);
glViewport(gs_iXPort,gs_iYPort,gs_iWPort,gs_iHPort);
double adLookAt[3) =
{
gs_adEye[0]+gs_adDir[0],
gs_adEye[1]+gs_adDir[1],
gs_adEye[2]+gs_adDir[2]
};
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(gs_adEye[0],gs_adEye[1],gs_adEye[2],adLookAt[0],adLookAt[1],
adLookAt[2],gs_adUp[0], gs_adUp[1], gs_adUp[2]);
ShowWindow(hWnd,SW_SHOW);
UpdateWindow(hWnd);
MSG kMsg;
while(TRUE)
{
if(PeekMessage(&kMsg, (HWND)0,0,0,PM_REMOVE))
{
if(kMsg.message == WM_QUIT)
break;
HACCEL hAccel = (HACCEL)0;
if(!TranslateAccelerator(hWnd, hAccel,&kMsg))
{
TranslateMessage(&kMsg);
DispatchMessage(&kMsg);
}
}
else
{
DrawIt();
}
}
wglDeleteContext(hWindowRC);
ReleaseDC(hWnd,gs_hWindowDC);
static void DrawIt()
{
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMultMatrixf(gs_afMatrix);
//Draw Triangle
glBegin(GL_POLYGON);
glColor3f(gs_afColor0[0],gs_afColor0[1],gs_afColor0[2]);
glVertex3f(gs_afVertex0[0],gs_afVertex0[1],gs_afVertex0[2]);
glColor3f(gs_afColor1[0],gs_afColor1[1],gs_afColor1[2]);
glVertex3f(gs_afVertex1[0],gs_afVertex1[1],gs_afVertex1[2]);
glColor3f(gs_afColor2[0],gs_afColor2[1],gs_afColor2[2]);
glVertex3f(gs_afVertex2[0],gs_afVertex2[1],gs_afVertex2[2]);
glEnd();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
SwapBuffers(gs_hWindowDC);
}
for(i = 0; i < 3; i++)
{
fTmp0 =
gs_fCos+gs_aafRotate[1][i] + gs_fSings_aafRotate[1][i];
fTmp1 =
gs_fCosgs_aafRotate[2][i] - gs_fSin*gs_aafRotate[1][i];
gs_aafRotate[1][i] = fTmp0;
gs_aafRotate[2][i] = fTmp1;
}
for(i = 0; i < 3; i++)
{
adTmp0[i] = gs_fCosgs_adRight[i] + gs_fSin gs_adDir[i];
adTmp1[i] = gs_fCosgs_adDir[i] - gs_fSings_adRight[i];
}
for(i = 0; i < 3; i++)
{
gs_adRight[i] = adTmp0[i];
gs_adDir[i] = adTmp1[i];
}