glaux replacement code (help)
Im on lesson 06 and cant figure out how to use the glaux replacement code, can someone please modify the following code to make a cube like they did using texture mapping with the glaux replacement code. I tried everything, and Ive been everywheres asking for help but not getting any, can someone please do this..
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <gl/gl.h>
void EnableGL(HWND hwnd,HDC* hDC,HGLRC* hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int format;
*hDC = GetDC(hwnd);
ZeroMemory(&pfd,sizeof(&pfd));
pfd.nSize = sizeof(pfd);
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 16;
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER;
format = ChoosePixelFormat(*hDC,&pfd);
SetPixelFormat(*hDC,format,&pfd);
*hRC = wglCreateContext(*hDC);
wglMakeCurrent(*hDC,*hRC);
}
void DisableGL(HWND hwnd,HDC hDC,HGLRC hRC)
{
wglDeleteContext(hRC);
wglMakeCurrent(NULL,NULL);
ReleaseDC(hwnd,hDC);
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR nCmdLine,
int nCmdShow)
{
HGLRC hRC;
HDC hDC;
HWND hwnd;
WNDCLASSEX wc;
MSG Message;
bool quit = false;
float theta = 1.0f;
wc.cbSize = sizeof(WNDCLASSEX);
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MAIN";
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hInstance = hInstance;
RegisterClassEx(&wc);
hwnd = CreateWindowEx(0,
"MAIN",
"_-+OpenGL+-_",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
800,600,
NULL,
NULL,
hInstance,
NULL);
EnableGL(hwnd,&hDC,&hRC);
ShowWindow(hwnd,nCmdShow);
while(quit == false)
{
if(PeekMessage(&Message,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&Message);
DispatchMessage (&Message);
if(Message.message == WM_QUIT){ quit = true; }
}
else
{
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(theta,1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glColor3f(1.0f,0.0f,0.0f); glVertex3f(-0.5,-0.5,0.0);
glVertex3f(-0.5,0.5,0.0);
glVertex3f(0.5,0.5,0.0);
glVertex3f(0.5,-0.5,0.0);
glColor3f(0.0f,1.0f,0.0f); glVertex3f(0.5,-0.5,-1.0);
glVertex3f(0.5,-0.5,0.0);
glVertex3f(0.5,0.5,0.0);
glVertex3f(0.5,0.5,-1.0);
glColor3f(0.0f,0.0f,1.0f); glVertex3f(-0.5,-0.5,0.0);
glVertex3f(-0.5,-0.5,-1.0);
glVertex3f(-0.5,0.5,-1.0);
glVertex3f(-0.5,0.5,0.0);
glColor3f(1.0f,0.0f,1.0f); glVertex3f(-0.5,-0.5,-1.0);
glVertex3f(-0.5,0.5,-1.0);
glVertex3f(0.5,0.5,-1.0);
glVertex3f(0.5,-0.5,-1.0);
glColor3f(0.0f,1.0f,1.0f); glVertex3f(0.5,0.5,0.0);
glVertex3f(-0.5,0.5,0.0);
glVertex3f(-0.5,0.5,-1.0);
glVertex3f(0.5,0.5,-1.0);
glColor3f(0.5f,0.2f,0.7f); glVertex3f(-0.5,-0.5,0.0);
glVertex3f(-0.5,-0.5,-1.0);
glVertex3f(0.5,-0.5,-1.0);
glVertex3f(0.5,-0.5,0.0);
glEnd();
glPopMatrix();
SwapBuffers(hDC);
theta+=1.0f;
}
}
DisableGL(hwnd,hDC,hRC);
return Message.wParam;
}
someone please help me lol.
look at the link in my sig, it explains how this should be done.
While the code might not be the same, it will perhaps give you a hint.
Note: this won't give you textures since that code doesn't do any textureloading, i suggest that you reread lesson 6, and then possibly download the code for it, apply the replacement code, and learn from there.
While the code might not be the same, it will perhaps give you a hint.
Note: this won't give you textures since that code doesn't do any textureloading, i suggest that you reread lesson 6, and then possibly download the code for it, apply the replacement code, and learn from there.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement