Jump to content
  • Advertisement

Jonus

Member
  • Content Count

    460
  • Joined

  • Last visited

Community Reputation

170 Neutral

About Jonus

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks Skeleton_V@T you are a big help.
  2. Quote:1. It is not a good idea to call DestroyWindow () and UnregisterClass () in the window procedure. There maybe remaining messages in the message queue, and there're lots of housekeeping works Windows has to perform when a window get destroyed. You should move them out of window procedure, the best place is right before WinMain () returns I guess.That doesn't seem to work either. I get error messages that the programm failed to release stuff. Quote:2. This way the function doesn't have an extra jump (break) statement, which might improve performance.Dunno if that's right. Ok changed. Quote:3.Makes sense. :) Quote:4.So i have to set it to = NULL; right? Quote:5.But is this change really neccesary? I don't find anything about WS_CLIPCHILDREN | WS_CLIPSIBLINGS being neccesary: Quote:WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only. Quote:6.AH ok, thanks. Anyways if i remove ShowWindow and use WS_VISIBLE the start up of the window looks weird. Quote:7.Ok. Quote:8.I think it's a good style to put variables down at the beginning of a procedure Here the code again: #include <windows.h> #include <gl\gl.h> #include <gl\glu.h> const char g_myClassName[] = "myWindowClass"; HWND hwnd=NULL; HINSTANCE g_hInstance=NULL; HDC g_hDC=NULL; HGLRC g_hRC=NULL; double r = 0.0; int InitGL(GLsizei width, GLsizei height) { if (height==0) { height=1; } glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return TRUE; } int DeinitWindow() { if (g_hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(g_hRC)) // Are We Able To Delete The RC? { MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } g_hRC=NULL; // Set RC To NULL } if (g_hDC && !ReleaseDC(hwnd,g_hDC)) // Are We Able To Release The DC { MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); g_hDC=NULL; // Set DC To NULL } if (hwnd && !DestroyWindow(hwnd)) // Are We Able To Destroy The Window? { MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hwnd=NULL; // Set hWnd To NULL } if (!UnregisterClass("OpenGL",g_hInstance)) // Are We Able To Unregister Class { MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); g_hInstance=NULL; // Set hInstance To NULL } return 0; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DeinitWindow(); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { unsigned int PixelFormat; WNDCLASSEX wc; int width = 240, height = 160; int done = false; g_hInstance = hInstance; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = g_myClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_myClassName, "Der Titel des Fensters", WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 16, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(g_hDC=GetDC(hwnd))) // Did We Get A Device Context? { DeinitWindow(); MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(g_hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { DeinitWindow(); MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!SetPixelFormat(g_hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { DeinitWindow(); MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(g_hRC=wglCreateContext(g_hDC))) // Are We Able To Get A Rendering Context? { DeinitWindow(); MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!wglMakeCurrent(g_hDC,g_hRC)) // Try To Activate The Rendering Context { DeinitWindow(); MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hwnd, nCmdShow); if (!InitGL(width,height)) // Initialize Our Newly Created GL Window { DeinitWindow(); MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } MSG Msg; while(!done) { if (PeekMessage(&Msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (Msg.message==WM_QUIT) // Have We Received A Quit Message? { done=TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&Msg); // Translate The Message DispatchMessage(&Msg); // Dispatch The Message } } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // glRotated(r,0,0,1); r+=0.1; glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.15470f, -10.0f); glVertex3f(-1.0f,-0.57735f, -10.0f); glVertex3f( 1.0f,-0.57735f, -10.0f); glEnd(); SwapBuffers(g_hDC); } } return (int)Msg.wParam; }
  3. As far as i can tell everything should work fine with this code, but i have some questions: 1. Is everything deinitialised right when an error ocours by calling PostMessage(hwnd,WM_CLOSE,0,0); //? I am asking this, because the debugger won't stop in the switch(msg){[...]} 2. Do i use ShowWindow(hwnd, nCmdShow); // and UpdateWindow(hwnd); // correctly? 3. Do you see any other obvious flaws? #include <windows.h> #include <gl\gl.h> #include <gl\glu.h> const char g_szClassName[] = "myWindowClass"; HWND hwnd=NULL; HINSTANCE hInstance=NULL; HDC hDC=NULL; HGLRC hRC=NULL; double r = 0.0; int InitGL(GLsizei width, GLsizei height) { if (height==0) { height=1; } glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return TRUE; } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: if (hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? { MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hRC=NULL; // Set RC To NULL } if (hDC && !ReleaseDC(hwnd,hDC)) // Are We Able To Release The DC { MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hDC=NULL; // Set DC To NULL } if (hwnd && !DestroyWindow(hwnd)) // Are We Able To Destroy The Window? { MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hwnd=NULL; // Set hWnd To NULL } if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class { MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { GLuint PixelFormat; WNDCLASSEX wc; MSG Msg; int width = 240, height = 160; hInstance = GetModuleHandle(NULL); wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "The title of my window", WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 16, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC=GetDC(hwnd))) // Did We Get A Device Context? { MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); PostMessage(hwnd,WM_CLOSE,0,0); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); PostMessage(hwnd,WM_CLOSE,0,0); return FALSE; // Return FALSE } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); PostMessage(hwnd,WM_CLOSE,0,0); return FALSE; // Return FALSE } if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); PostMessage(hwnd,WM_CLOSE,0,0); return FALSE; // Return FALSE } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); PostMessage(hwnd,WM_CLOSE,0,0); return FALSE; // Return FALSE } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); if (!InitGL(width,height)) // Initialize Our Newly Created GL Window { PostMessage(hwnd,WM_CLOSE,0,0); MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } int done = false; while(!done) { if (PeekMessage(&Msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (Msg.message==WM_QUIT) // Have We Received A Quit Message? { done=TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&Msg); // Translate The Message DispatchMessage(&Msg); // Dispatch The Message } } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // glRotated(r,0,0,1); r+=0.1; glBegin(GL_TRIANGLES); glVertex3f( 0.0f, 1.0f, -15.0f); glVertex3f(-1.0f,-1.0f, -15.0f); glVertex3f( 1.0f,-1.0f, -15.0f); glEnd(); SwapBuffers(hDC); } } return Msg.wParam; }
  4. Thanks Crane you're a true livesaver. I searched the msdn before but didn't find anything.
  5. I am working with the nehe framework without sdl. I just need something that i can build upon. I just need the 4 arrows of the game controller plus 3 buttons. Everything works fine with keyboard (using win32), but i think i need the game controller.
  6. Sorry but i have to bump this once.
  7. What's the easiest way to do it? I know i have to use direct input, does anyone know a good tutorial on it?
  8. Ok i played arround with svn now and i just love it. Although i dunno if i grasped every feature. Thanks all.
  9. Quote:Original post by lightbringer Quote:Original post by Jonus The client runs on Win9x/Me but the server does not, see the FAQ. Well, yes, but your question was about XP and not ME or 9x :DD'oh. Well after it was recommended here i installed it anyways. :) Now i just have to skim through the help on how to start.
  10. Quote:Original post by lightbringer Quote:Original post by Jonus Quote:Original post by jpetrie Subversion (and probably CVS, though I've never tried) can be used locally. If you download the TortoiseSVN client you can right-click somewhere and choose "Create Repository here..." or something similar. That will allow you host locally.That would be exacltly what i need. Are you sure it works on windows xp? A quick look at http://subversion.tigris.org/project_packages.html shows that the program is at least advertised as working on Windows NT, 2000, XP and 2003.Indeed, but the first line says: The client runs on Win9x/Me but the server does not, see the FAQ. Quote:Original post by SiCrane Quote:Original post by Jonus That would be exacltly what i need. Are you sure it works on windows xp? I've used it on XP, XP SP1, XP SP2 and XP Tablet Edition 2003. Worked fine on all of them.Ok i will try it out.
  11. Quote:Original post by lightbringer You don't need to install apache, just download and install (and configure - that's a pain) cvs on your local machine, then use your ide or a program like WinCVS or something similar for checking stuff out. Personally I think that full-blown version control for a single-programmer project is an overkill, it adds complexity to your development cycle without providing many benefits - you don't need concurrent accees since you're the only one working on it, and versioning can be solved by making daily backups of your source tree - something you ought to think about anyway. You can always move to a version control package later on if more programmers join in.I aggree partially. I don't need the concurrent part, but version control is a nice thing even for single developer projects. Sometimes it happens that i change something in the code and nothing won't work anymore. With version control i see what code lines have changed. That's priceless.
  12. Quote:Original post by jpetrie Subversion (and probably CVS, though I've never tried) can be used locally. If you download the TortoiseSVN client you can right-click somewhere and choose "Create Repository here..." or something similar. That will allow you host locally.That would be exacltly what i need. Are you sure it works on windows xp?
  13. Where do i get a free cvs, svn account/webspace. I am sort of new to this stuff. I thought i'd use sourceforge, but it demands real identification with all your personal data. I am developing on windows xp and i am developing for windows xp. Is there a easy to use single person version control software? I don't want to install apache on my system.
  14. Quote:Original post by deadimp Here's a link on C++ I/O. My money is on the function "unsetf()".yep, i know this function, but with it i have to use it for every single flag i want to clear. Well ok.
  15. Like to change back the fill('*') to a whitespace and change the width(10) back to default? I simply want to reset the whole thing.
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!