• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

MindOfCorruption97

Members
  • Content count

    10
  • Joined

  • Last visited

Community Reputation

140 Neutral

About MindOfCorruption97

  • Rank
    Member
  1. I tried that but it seems like the keyboard is not the issue. When I replace the setVy with setVx the program responds to the keyboard input. But if I replace it back then it won't respond with the setVy. Basically something is wrong with the methods/variable itself not the keyboard.
  2. Sorry, minor mistake. But the bullets still won't shoot on the Y axis. Is there anything else wrong witht the code?
  3. OpenGL

    I made a bounding box class if you want. Just create a bounding box for the ball and the paddle and just check if they collide. Here are the files: http://www.mediafire.com/download/9pguyvnjdcucwpg/tools.h http://www.mediafire.com/download/0csbj0c6cbljyka/tools.cpp This only fixes the collision problem(hopefully). The bouncing problem I don't know how to fix...
  4. Hey, I have a problem. You see, for some reason, I am not able to shoot up or down. After a few hours looking I couldn't seem to find the error to this issue. So can anyone help me point out what is causing the bullets not go up nor down.   Player.h #ifndef PLAYER_H #define PLAYER_H #include <GL/glfw.h> #include <vector> #include "tools.h" using namespace std; class Bullet; class Player{ public: void init(); void draw(); void update(); void keyListener(); void mouseMotionListener(); void mouseClickListener(); void setVx(int Vx){intVx = Vx;} void setVy(int Vy){intVy = Vy;} void velocity(); void shoot(int intDir); void nothing(){} Rectangle getPlayer(){return rectPlayer;} Point getMotion(){return ptMotion;} Point getClick(){return ptClick;} private: int intX,intY,intVx,intVy,intWidth,intHeight; bool blInitiated; vector<Bullet> vectBullet; Rectangle rectPlayer; Point ptMotion,ptClick; }; class Bullet{ public: Bullet(int X,int Y); ~Bullet(); void draw(); void update(); void setVx(int Vx){intVx = Vx;} void setVy(int Vy){intVy = Vy;} void velocity(); Rectangle getBullet(){return rectBullet;} private: int intX,intY,intVx,intVy; Rectangle rectBullet; }; #endif Player.cpp #include "Player.h" void Player::init(){ blInitiated = false; intX = 0; intY = 0; intWidth = 50; intHeight = 50; rectPlayer = createRectangle(intX,intY,intWidth,intHeight); blInitiated = true; } void Player::draw(){ glColor3f(0.0,0.0,255.0); drawRectangle(rectPlayer.intX,rectPlayer.intY,rectPlayer.intWidth,rectPlayer.intHeight); for(int i = 0;i < vectBullet.size();i++){ vectBullet.at(i).draw(); } } void Player::update(){ if(!blInitiated){init();}else{nothing();} rectPlayer.intX = intX; rectPlayer.intY = intY; rectPlayer.intWidth = intWidth; rectPlayer.intHeight = intHeight; velocity(); for(int i = 0;i < vectBullet.size();i++){ vectBullet.at(i).update(); } } void Player::velocity(){ intX += intVx; intY += intVy; } void Player::shoot(int intDir){ vectBullet.push_back(Bullet(intX + 23,intY + 23)); if(intDir == 1){vectBullet.back().setVy(-10);} else if(intDir == 2){vectBullet.back().setVy(-10);} if(intDir == 3){vectBullet.back().setVx(-10);} else if(intDir == 4){vectBullet.back().setVx(+10);} } void Player::keyListener(){ if(glfwGetKey('A') == GLFW_PRESS){setVx(-3);} else if(glfwGetKey('D') == GLFW_PRESS){setVx(+3);} else{setVx(0);} if(glfwGetKey('W') == GLFW_PRESS){setVy(-3);} else if(glfwGetKey('S') == GLFW_PRESS){setVy(+3);} else{setVy(0);} if(glfwGetKey(GLFW_KEY_UP) == GLFW_PRESS){shoot(1);} else if(glfwGetKey(GLFW_KEY_DOWN) == GLFW_PRESS){shoot(2);} else if(glfwGetKey(GLFW_KEY_LEFT) == GLFW_PRESS){shoot(3);} else if(glfwGetKey(GLFW_KEY_RIGHT) == GLFW_PRESS){shoot(4);} } void Player::mouseMotionListener(){glfwGetMousePos(&ptMotion.intX,&ptMotion.intY);} void Player::mouseClickListener(){ if(glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS){ glfwGetMousePos(&ptClick.intX,&ptClick.intY); } } //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Bullet::Bullet(int X, int Y){ intX = X; intY = Y; rectBullet = createRectangle(intX,intY,4,4); } Bullet::~Bullet(){} void Bullet::draw(){ glColor3f(0.0,0.0,255.0); drawRectangle(rectBullet.intX,rectBullet.intY,rectBullet.intWidth,rectBullet.intHeight); } void Bullet::update(){ rectBullet.intX = intX; rectBullet.intY = intY; velocity(); } void Bullet::velocity(){ intX += intVx; intY += intVy; } It's just Vy(velocity of Y) won't set. I tried replacing "setVy" with "setVx" so I know the keyboard isn't the problem. It's something to do with setVy but I don't know what. PS. I tested it out and I know the problem is somewhere in the "shoot()".
  5. OpenGL

    Well I made Tex and Bitmap no longer a global variable. I also checked the debugger and it says the problem is this section of the code. if((i + 1) % padWidth == 0) { i += offset; } *(pixelData + j + 2) = *(tempPixelData + i); *(pixelData + j + 1) = *(tempPixelData + i + 1); *(pixelData + j) = *(tempPixelData + i + 2); j++; I tried deleting that part of the code and it worked but it didn't show the texture. Any idea what could be wrong?
  6. Sorry to ask but for some reason my OpenGL application does not seem to work. When I try to run/debug my application it stops and shows a message that my application stopped working. I tried to find ways to fix it, but I don't know what is causing to to stop working.   I listed all the classes and files associated with my application.   MainWindow.cpp #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include "EditorLink.h" const char g_szClassName[] = "Window"; BOOL quit = FALSE; void EnableOpenGL(HWND hWnd,HDC * hDc,HGLRC * hRc); void DisableOpenGL(HWND hWnd,HDC hDc,HGLRC hRc); Editor Edit; LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_CLOSE: quit = TRUE; break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd,msg,wParam,lParam); } } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR CmdLine,int nCmdShow) { WNDCLASS wc; HWND hWnd; HGLRC hRc; HDC hDc; MSG msg; wc.lpszClassName = g_szClassName; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.hInstance = hInstance; wc.style = CS_OWNDC; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpfnWndProc = WndProc; wc.lpszMenuName = NULL; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = LoadIcon(NULL,NULL); RegisterClass(&wc); hWnd = CreateWindow( g_szClassName, "OPENGL PRACTICE", WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_POPUP | WS_VISIBLE, CW_USEDEFAULT,CW_USEDEFAULT,800,700, NULL,NULL,hInstance,NULL ); EnableOpenGL(hWnd,&hDc,&hRc); Edit.init(hInstance); ShowWindow(hWnd,nCmdShow); UpdateWindow(hWnd); while(!quit) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { Edit.display(); SwapBuffers(hDc); } } DisableOpenGL(hWnd,hDc,hRc); DestroyWindow(hWnd); return msg.wParam; } void EnableOpenGL(HWND hWnd,HDC * hDc,HGLRC * hRc) { *hDc = GetDC(hWnd); int nFormat; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 0,0,0,0,0,0,0,0,0,0,0,0,0, 24, 8, 0, PFD_MAIN_PLANE, 0,0,0,0 }; nFormat = ChoosePixelFormat(*hDc,&pfd); SetPixelFormat(*hDc,nFormat,&pfd); *hRc = wglCreateContext(*hDc); wglMakeCurrent(*hDc,*hRc); } void DisableOpenGL(HWND hWnd,HDC hDc,HGLRC hRc) { wglMakeCurrent(NULL,NULL); wglDeleteContext(hRc); ReleaseDC(hWnd,hDc); } Editor.h #include <windows.h> #ifndef EDITORLINK_H #define EDITORLINK_H class Editor { public: void init(HINSTANCE hInstance); void display(); private: }; #endif   Editor.cpp #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include "EditorLink.h" #include "Texture.h" unsigned int tex; Bitmap *bitmap; void Editor::init(HINSTANCE hInstance) { glClearColor(0.0,0.0,0.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,640.0/480.0,1.0,500.0); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_TEXTURE_2D); float dif[] = {1.0,1.0,1.0,1.0}; glLightfv(GL_LIGHT0,GL_DIFFUSE,dif); float amb[] = {0.2,0.2,0.2,1.0}; glLightfv(GL_LIGHT0,GL_AMBIENT,amb); tex = bitmap->loadTexture("Practice.bmp"); } void Editor::display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); float pos[] = {-2.0,2.0,-3.0,1.0,}; glLightfv(GL_LIGHT0,GL_POSITION,pos); glTranslatef(0.0,0.0,-5.0); glBindTexture(GL_TEXTURE_2D,tex); glBegin(GL_QUADS); glTexCoord2f(0.0,1.0); glVertex3f(-2.0,2.0,0.0); glTexCoord2f(0.0,0.0); glVertex3f(-2.0,-2.0,0.0); glTexCoord2f(1.0,0.0); glVertex3f(2.0,-2.0,0.0); glTexCoord2f(1.0,1.0); glVertex3f(2.0,2.0,0.0); glEnd(); }   Texture.h #include <windows.h> #include <cstdio> #ifndef TEXTURE_H #define TEXTURE_H class Bitmap { public: RGBQUAD getColors(){return *colors;} BYTE getPixelData(){return *pixelData;} bool getLoaded(){return loaded;} LONG getWidth(){return width;} LONG getHeight(){return height;} WORD getBpp(){return bpp;} bool loadBmp(const char * FileName); unsigned int loadTexture(const char * FileName); private: RGBQUAD *colors; BYTE *pixelData; bool loaded; LONG width,height; WORD bpp; BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; }; #endif Texture.cpp #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include "Texture.h" bool Bitmap::loadBmp(const char* FileName) { int numColors,offset; DWORD size,diff; BYTE *tempPixelData; LONG byteWidth,padWidth; FILE *in; in = fopen(FileName,"rb"); fread(&bmfh,sizeof(BITMAPFILEHEADER),1,in); fread(&bmih,sizeof(BITMAPINFOHEADER),1,in); numColors = 1 << bmih.biBitCount; size = bmfh.bfSize - bmfh.bfOffBits; tempPixelData = new BYTE[size]; byteWidth = padWidth = (LONG)((float)width * (float)bpp/8.0); height = bmih.biHeight; diff = height * byteWidth; if(bmih.biBitCount == 8) { colors = new RGBQUAD[numColors]; fread(colors,sizeof(RGBQUAD),numColors,in); } if(tempPixelData == NULL) { fclose(in); return false; } fread(tempPixelData,sizeof(BYTE),size,in); while(padWidth % 4 != 0) { padWidth++; } if(height > 0) { int j = size - 3; offset = padWidth - byteWidth; for(int i = 0;i < size;i += 3) { if((i + 1) % padWidth == 0) { i += offset; } *(pixelData + j + 2) = *(tempPixelData + i); *(pixelData + j + 1) = *(tempPixelData + i + 1); *(pixelData + j) = *(tempPixelData + i + 2); j++; } } else { height = height* - 1; offset = 0; do{ memcpy((pixelData + (offset * byteWidth)), (tempPixelData + (offset * byteWidth)), byteWidth); offset++; }while(offset < height); } } unsigned int Bitmap::loadTexture(const char * FileName) { if(loadBmp(FileName)) { unsigned int id; glGenTextures(1,&id); glBindTexture(GL_TEXTURE_2D,id); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED_BYTE,pixelData); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); return id; } }   Thank you, sorry to waste your time. Also can you guys tell me what causes an application to stop working? Since I want to make sure I could prevent this from happening in the future.
  7. OpenGL

    Thank you for that. You saved me from future errors with my program. But after looking at the code bit. I switched GetMessage(&msg,NULL,0,0) > 0 with   PeekMessage(&msg,NULL,0,0,PM_REMOVE)   making the program work. Thank you for giving me more insight on opengl. :D
  8. Hello gents, I require some assistance. For some reason, my win32 program refuses to display a triangle. I've tried to find ways to fix it, but my attempts seem to result in failures. Here is the code to my program.   My window class. #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include "EditorLink.h" const char g_szClassName[] = "Window"; BOOL quit = FALSE; void EnableOpenGL(HDC hDc,HGLRC hRc); void DisableOpenGL(HDC hDc,HGLRC hRc); Editor Edit; LRESULT CALLBACK WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_CLOSE: quit = TRUE; break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd,msg,wParam,lParam); } } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR CmdLine,int nCmdShow) { WNDCLASS wc; HWND hWnd; HGLRC hRc; HDC hDc; MSG msg; wc.lpszClassName = g_szClassName; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.hInstance = hInstance; wc.style = CS_OWNDC; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpfnWndProc = WndProc; wc.lpszMenuName = NULL; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = LoadIcon(NULL,NULL); RegisterClass(&wc); hWnd = CreateWindow( g_szClassName, "OPENGL PRACTICE", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT,700,700, NULL,NULL,hInstance,NULL ); ShowWindow(hWnd,nCmdShow); UpdateWindow(hWnd); EnableOpenGL(hDc,hRc); Edit.init(); while(!quit) { if(GetMessage(&msg,NULL,0,0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } else { Edit.display(); SwapBuffers(hDc); } } DisableOpenGL(hDc,hRc); DestroyWindow(hWnd); return msg.wParam; } void EnableOpenGL(HDC hDc,HGLRC hRc) { int nFormat; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 0,0,0,0,0,0,0,0,0,0,0,0,0, 24, 8, 0, PFD_MAIN_PLANE, 0,0,0,0 }; nFormat = ChoosePixelFormat(hDc,&pfd); SetPixelFormat(hDc,nFormat,&pfd); hRc = wglCreateContext(hDc); wglMakeCurrent(hDc,hRc); } void DisableOpenGL(HDC hDc,HGLRC hRc) { wglMakeCurrent(NULL,NULL); wglDeleteContext(hRc); }   And my class where I entered the display data. #include <gl/gl.h> #include <gl/glu.h> #include "EditorLink.h" void Editor::init() { glClearColor(0.0,0.0,0.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45,640.0/480.0,1.0,500.0); glMatrixMode(GL_MODELVIEW); } void Editor::display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glVertex3f(0.0,2.0,-5.0); glVertex3f(-2.0,-2.0,-5.0); glVertex3f(2.0,-2.0,-5.0); glEnd(); }   I don't know what is wrong. So some help would be nice. Thank you and have a nice day.
  9. OpenGL

    [quote name='FLeBlanc' timestamp='1352246182' post='4998266'] At the top, you declare EnableOpenGL, but your implementation of it near the bottom of the code is called EnableOpenGl (note the lowercase l). [/quote] [quote name='NumberXaero' timestamp='1352246247' post='4998267'] void EnableOpenGL(HWND hwnd,HDC * hdc,HGLRC * hrc); <-- BIG L end of file void EnableOpenGl(HWND hwnd,HDC * hdc,HGLRC * hrc) <-- little l [/quote] Thank you, I never knew that the problem was so simple. Now it works great. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  10. Hey all, this is my first post so I'll make it quick. I currently have a problem in C++ where, after I compile, it prints an error in the console saying: ------ Build started: Project: OpenGL_1, Configuration: Debug Win32 ------ 1> CreatingAWindow.cpp 1>CreatingAWindow.obj : error LNK2019: unresolved external symbol "void __cdecl EnableOpenGL(struct HWND__ *,struct HDC__ * *,struct HGLRC__ * *)" (?EnableOpenGL@@YAXPAUHWND__@@PAPAUHDC__@@PAPAUHGLRC__@@@Z) referenced in function _WinMain@16 1>C:\Users\MindOfCorruption97\Desktop\MyStuff\Programming\C++\SDL_OpenGL\Sandbox\OpenGL_1\Debug\OpenGL_1.exe : fatal error LNK1120: 1 unresolved externals I linked the libraries because before the error was much larger. After I linked the libraries there was only one error message left as you can see above. Here is the code if you guys need it: [source lang="cpp"]#include <windows.h> #include <gl/gl.h> //Function that handles messages sent to your window. //hwnd is the handle to the window, uMsg is the message code, wParam and lParam contains more code about the message. LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); void EnableOpenGL(HWND hwnd,HDC * hdc,HGLRC * hrc); void DisableOpenGL(HWND hwnd,HDC hdc,HGLRC hrc); //wWinMain is the Main method in a windows C++ program. //hinstance is called "handle to an instance" or "handle to a module". It is used to identify the EXE. //nCmdLine contains command line arguments. nCmdShow chooses whether it is minimized, maximized, or hidden. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { WNDCLASS wc; HWND hwnd; HDC hdc; HGLRC hrc; MSG msg; BOOL quit = FALSE; float theta = 0.0f; wc.style = CS_OWNDC; wc.lpfnWndProc = WndProc; //Pointer to the Window Procedure(WindowProc). wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance;//hInstance is used to handle the application instance. wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "GLSample";//lpszClassName is a string that identifies the window class. RegisterClass(&wc);//Uses the OS to register the window. //Creates a new instance of the window.CreateWindowEx(Window style,Type of window,Title bar). //WS_OVERLAPPEDWINDOW give the window a title bar and all that stuff. hwnd = CreateWindow( "GLSample","OPENGL Window Creation", WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, 0,0,256,256, NULL,NULL,hInstance,NULL); EnableOpenGL(hwnd,&hdc,&hrc); //Used to dispatch messages to the correct windows. while(!quit) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) { quit = TRUE; }else { TranslateMessage(&msg);//Used to translate keyboard input. DispatchMessage(&msg);//Returns the message for the next loop. } }else { glClearColor(0.0f,0.0f,0.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(theta,0.0f,0.0f,1.0f); glBegin(GL_TRIANGLES); glColor3f(1.0f,0.0f,0.0f); glVertex2f(0.0f,1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex2f(0.87f,-0.5f); glColor3f(0.0f,0.0f,1.0f); glVertex2f(-0.87f,-0.5f); glEnd(); glPopMatrix(); SwapBuffers(hdc); theta += 1.0f; } } DisableOpenGL(hwnd,hdc,hrc); DestroyWindow(hwnd); return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CREATE:return 0; case WM_CLOSE:PostQuitMessage(0);return 0; case WM_DESTROY:return 0; case WM_KEYDOWN: switch(wParam) { case VK_ESCAPE: PostQuitMessage(0); return 0; } return 0; default:return DefWindowProc(hwnd,uMsg,wParam,lParam); } } void EnableOpenGl(HWND hwnd,HDC * hdc,HGLRC * hrc) { PIXELFORMATDESCRIPTOR pfd; int format; *hdc = GetDC(hwnd); ZeroMemory(&pfd,sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; format = ChoosePixelFormat(*hdc,&pfd); SetPixelFormat(*hdc,format,&pfd); *hrc = wglCreateContext(*hdc); wglMakeCurrent(*hdc,*hrc); } void DisableOpenGL(HWND hwnd,HDC hdc,HGLRC hrc) { wglMakeCurrent(NULL,NULL); wglDeleteContext(hrc); ReleaseDC(hwnd,hdc); } [/source] Help as soon as possible, thank you.