OpenGL help

This is a discussion on OpenGL help within the C++ Programming forums, part of the General Programming Boards category; ok im learning opengl and im of corse running msvc 6.0 enterprise edition blah blah blah anywho this code(below) seemed ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    58

    OpenGL help

    ok im learning opengl and im of corse running msvc 6.0 enterprise edition blah blah blah anywho this code(below) seemed to do nothing untill i added a messagebox to to the if(!registerclassex...). the message box tells me that obviously it cant register the class. why is this? does it have to do with the fact im running windowsxp? what do i do?!

    Code:
    #include "asdf.h"
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    PAINTSTRUCT paintStruct;
    HDC hDC;
    char str[]="Hello World";
    
    //////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	
    	switch(message)
    	{
    	case WM_CREATE:
    		{
    			return 0;
    		}
    	case WM_CLOSE:
    		{
    			PostQuitMessage(0);
    			return 0;
    			break;
    		}
    	case WM_PAINT:
    		{
    			hDC= BeginPaint(hwnd, &paintStruct);
    			SetTextColor(hDC, COLORREF(0x00FF0000));
    
    			TextOut(hDC, 150,150, str, sizeof(str)-1);
    
    			EndPaint(hwnd, &paintStruct);
    		}
    	default:
    		break;
    	}
    	return DefWindowProc(hwnd,message,wParam,lParam);
    }
    
    
    
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    	{
    	
    	
    
    	WNDCLASSEX windowClass;
    	bool done;
    	HWND hwnd;
    	MSG msg;
    	windowClass.cbSize = sizeof(WNDCLASSEX);
    	windowClass.lpfnWndProc = WndProc;
    	windowClass.cbClsExtra = 0;
    	windowClass.cbWndExtra = 0;
    	windowClass.hInstance = hInstance;
    	windowClass.hIcon = NULL;
    	windowClass.hbrBackground=NULL;
    	windowClass.lpszMenuName = NULL;
    	windowClass.lpszClassName="MyClass";
    	windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    
    	
    	windowClass.style = CS_VREDRAW | CS_HREDRAW;
    	
    	//windowClass.hCursor LoadCursor(NULL, IDC_ARROW);
    	if(!RegisterClassEx(&windowClass))
    	{
    		MessageBox(NULL, "ERROR", "ERROR", NULL);
    		return 0;
    	}
    	
    	hwnd = CreateWindowEx(NULL, "MyClass", "My Windows Application!", WS_OVERLAPPEDWINDOW |WS_CLIPSIBLINGS | WS_CLIPCHILDREN |WS_VISIBLE |WS_SYSMENU, 100,100, 400,400,NULL,NULL, hInstance, NULL);
    	if (hwnd == NULL)
    	return 0;
    	
    	done = false;
    	//ShowWindow(hwnd, nCmdShow);
    	//UpdateWindow();
    	while(!done)
    	{
    		if(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
    		{
    			if(msg.message == WM_QUIT)
    			{
    				done=true;
    			}
    			else
    			{
    				TranslateMessage(&msg);
    				DispatchMessage(&msg);
    			}
    		}
    	}
    	return msg.wParam;
    --== www.NuclearWasteSite.com==--

  2. #2
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    The register thing that your referring to is that all it does is tell the user it couldn't load whatever. if(!registerclassex...) is just a way of telling the computer that if it can't load registerclassex, tell the user.

  3. #3
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy,
    try asking your question onOpenGL Forums

    M.R.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 11:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21