#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    8
    Rep Power
    0

    [Dev-C++, OpenGL, Windows (7,xp,vista)] General Questions


    I am trying to learn game programmin in c++ and simple graphics. (My future goal is to make games that will work on as many computers as possible, including mac and other OS's.)
    Using Dev-C++, I am trying to set up OpenGL, but with no luck. The MANY tutorials I find on the net say similar things and I did manage to get it to work, but with the following questions:

    Where could I learn about the build process/linking libraries and what do commands like -lopengl32 -lglu32 mean under Project > Project Options > Parameters.
    I hate to use them and not understand them.

    Also, the first example I have seen to literally just make a simple window was 400 lines long, does game programming in c++ really require that much code?

    I know basic C++, but not how to use graphic API's/libraries; they require a lot of setting up in the IDE which I am not experienced in whatsoever.

    Any help is appreciated.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    8
    Rep Power
    0
    I found a lovely website http://www.lazyfoo.net/ , that has solved my problems.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2010
    Posts
    128
    Rep Power
    0
    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    
    LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    	WNDCLASSEX windowClass;
    	ZeroMemory(&windowClass, sizeof(WNDCLASSEX));
    	
    	windowClass.cbSize = sizeof(WNDCLASSEX);
    	windowClass.style = CS_HREDRAW | CS_VREDRAW;
    	windowClass.lpfnWndProc = WindowProc;
    	windowClass.hInstance = hInstance;
    	windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
    	windowClass.lpszClassName = "WindowClassName";
    
    	RegisterClassEx(&windowClass);
    
    	HWND windowHandle = CreateWindowEx(NULL, "WindowClassName", "Win32 Window", 
    		WS_OVERLAPPEDWINDOW, 0, 0, 300, 300, NULL, NULL, hInstance, NULL);
    
    	ShowWindow(windowHandle, nShowCmd);
    	UpdateWindow(windowHandle);
    
    	MSG msg;
    
    	while(GetMessage(&msg, NULL, 0, 0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    }
    
    LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	case WM_DESTROY:
    			PostQuitMessage(0);
    			return 0;
    			break;
    	default:
    		return DefWindowProc(hWnd, message, wParam, lParam);
    		break;
    	}
    }
    This will create a window if this is what you're looking for...
    All of this is for both OpenGL and Direct3D programming.
    If you wish to learn more about Visual C++ or OpenGL I would purchase Ivor Horton's Beginning C++ or have a look at it.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    8
    Rep Power
    0
    thanks man! I'll have a look at that.
  8. #5
  9. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    Of course, the example is Windows only!

    If you want to write platform independent GUI C/C++ code, look into wxWidgets, FLTK and a few others. Also, you need to realize that OpenGL works best when the video card supports it in hardware and you cannot guarantee that will always be the case, so be sure to check that your program can function in the absence of hardware accelerated OpenGL.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

IMN logo majestic logo threadwatch logo seochat tools logo