Jump to content
  • Advertisement
Sign in to follow this  
Homunculi

OpenGL Texture Mapping with glaux replacement

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I cant figure out how to do it, I was wondering if someone could show me how to use it with my style of code... because nehe does all that error checking that I dont like to do unless i have to... my code is: #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; } basically what im asking is if someone would be kind enough to change that into a cube using texture mapping like nehe's tutorial 6, but using the glaux replacement since I dont have glaux.h with my compiler/IDE any help will be more than greatly appreciated, ive beent trying to this for about 4 - 6 days....

Share this post


Link to post
Share on other sites
Advertisement
You know, they glaux replacement at nehe.gamedev.net, oml lol, i just want someone to help ,mw with texture mapping, i just want to make a simple cube, thats all... i was planning on using the glaux replacement at nehe, but really i just need to know how to load a BMP and map it.... please lol, im begging, someone HELP ME!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!