Thread: GLUT or wgl which one

  1. #1
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218

    Unhappy GLUT or wgl which one

    Hi evri1;

    a while i was reading this book leisurly"opengl superbible"and it was mostly done in glut and now that im reading this book"opengl
    gameprogramming" it says that GLUT implementation is mostly for demos and small programs. am i right to assume:

    1-GLUT is a poor simulation of GUI done with bare essentials to mimick an operating system to make opengl os independent?

    2-and to actually make some serious app in window , i have to use wgl as rod said it , within "window architect" which i prefer sinceive been doing win32 for couple of years now




    what about claims that MS on purpose is slow to update its opengl libraries is it true?if so should i use their opengl libs?

    is it true again that its better to reference SGI libs"silicon graphics"?or mesa or or or ,,,its getting so confusing just to start
    with can any one simplify all this for me specially which to use?

    thx

    cheers!
    Last edited by SAMSAM; 02-12-2003 at 08:12 PM.

  2. #2
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    yes you're pretty much correct in your assumptions. GLUT is for simple stuff and people who are learning, it's so you can learn OpenGL without having the hassle of setting up a window and setting up the pixel format and setting up the rendering/device contexts. I'm not too sure about the rest of the stuff, because it's never been a serious issue for me. If you want a suggestion, i.e how I started, use NeHe's lesson1 (.here ) as a sort of basecode. Whenever you learn something new in opengl, just plug it into the drawglscene functin. That single source file has become a standard religiously followed by my friends (yes I have one or a few) when we start projects. Not only that but you'll get so used to looking at it you'll be able to write your own basecode. I hope all goes well.


    EDIT:

    I've always known SGI to mean silicon graphics.
    Last edited by Silvercord; 02-12-2003 at 08:31 PM.

  3. #3
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    thx silvercord again do u program on vc++6 and windows own lib for opengl32?

    im reading on this book actualy done by friends of nehe"gamedev.net kevin hawkins and on some programs when i import it to vc++6 i get the error for glut32.dll not being found.
    now i checked lib files in vc directory and noticed that glu32 is there so i cant figure as why im getting that error message?

    and last one how do i find out that the version of opengl on my compiler is the latest libs"version 1.2"?

    excuse me for the number of questions it figures when u r a beginner at something.

    cheers!

  4. #4
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    Yes I do programming with visual C++ 6 and 'windows own opengl' functions (wgl/wiggle). If you are trying to use the code from OpenGL game programming you shouldn't need the GLUT library installed at all. chance are you are including a glut header file into your project but you do not have the .dll in the windows32 folder of your system (that's where all your opengl related dlls should go).

    You should be able to check the version in GL.h, just use ctrl F and keep pressing f3 until you get what you are looking for. In your actual header file you should only see GL_VERSION 1_1 or something like that, because:

    from the latest GL.h header file:
    OpenGL v1.2, 1.3 or 1.4 are included with the drivers for your OpenGL video cards. So you only need to make sure you have the latest OpenGL driver for your video card. If you do not have the latest driver with OpenGL 1.2 or 1.3 or 1.4 support, either use GLSetup (for Win95/98 only) or contact the video card manufacturer directly and ask them for an OpenGL 1.2/1.3/1.4 driver for your card and OS.
    EDIT: I hope I answered your questions, if I didn't just keep asking
    Last edited by Silvercord; 02-13-2003 at 08:32 AM.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Wow, You guys act like GLUT is a curse .
    It's just for people not feeling like getting through the fuss of
    learning all routines required to get OpenGL working for
    the specific platform. Yes it's a little slower than using the
    platfom specific routines but it isn't such a disaster using it.

  6. #6
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    thx silvercord again i promise promise promise !
    to be more clear on my questions these are my questions;


    To all opengl vets:

    1- do u use version1.1 headers and libs offered by ms on your
    vc++6?

    2-if yes why? when its a version (what i mean is the version that developers use) going back to 95 and i read there is newer version 1.2 (by sgi) out since 1999 but ms hasnt implemented it yet. so if
    we use the older version how can we utilize the awesom new capabilities of new videocards like nvidia?

    3- if i want to use the newer version headers and libs lets say 1.2
    can i simply download it and extract the libs and header as i normaly do to vc++6 lib and include files?

    4-why is opengl ARB lagging in sending out updated versions "like MS SDK" so it wont fall behind directx with newer technologies which it updates yearly .?

    5-why the info about opengl so scattered and not centralized like DIRECTX MS and u have to learn by examples?


    any answers to these or part of it in details need to go to FAQ section because these are i believe major questions for any
    dude who is a beginner to opengl programming.

    thx in advance

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by SAMSAM
    why the info about opengl so scattered and not centralized
    there we go

  8. #8
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    Again samsam to answer your questions about the newest OpenGL libraries, if you have the latest video drivers then you have the latest version of OpenGL.

    If you downloaded the header and library files from opengl.org ( here ) as well as the latest video drivers from your video card's manufacturer then you have everything up to date, and you need not worry about anything.

    You will see this at that URL:

    OpenGL v1.2, 1.3 or 1.4 are included with the drivers for your OpenGL video cards. So you only need to make sure you have the latest OpenGL driver for your video card
    If you want you may email me
    [email protected]

    EDIT:
    3- if i want to use the newer version headers and libs lets say 1.2
    can i simply download it and extract the libs and header as i normaly do to vc++6 lib and include files?
    You need to download the OpenGL library and header files from the site posted above, if you have an updated version of your video card then the DLLs you download will contain the latest version of OpenGL. If you do not understand the correlation between the OpenGL dlls and your video card's dlls, you may want to read this thread here

    To be honest with you I think you are getting a bit too hung up on the best way to start OpenGL, if you download the library files from opengl.org and have an up to date video card driver then you are OK. As I suggested before, take a look into downloading lesson1 from here (bottom of the page). When you learn something new in OpenGL simply plug it into the drawglscene() function

    Hope I'm helping.
    Last edited by Silvercord; 02-13-2003 at 02:39 PM.

  9. #9
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I agree with silver on this matter actually.

    BTW SGI = Silicon Graphics.

  10. #10
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    Ok thx all i have assume version 1.4 with my nvidia gef440
    that they say on nvidia website is part of their 4.09 update drivers that i downloaded a while back.

    note*opengl game programming is a good book with horrible CD
    support .be mindfull if u buy it because %30 of its source code
    crash upon compiling i will send u this example of the first program that wont crash but shows just the window and no triangle rotating and i dont know why"by the way this code itsnot even on their cd because of some screwup that they said happend during developing the CD"

    Code:
    #include <windows.h>
    #include <gl/gl.h>
    #include <gl/glu.h>
    #include <gl/glaux.h>
    
    float angle = 0.0f;
    
    
    HDC g_HDC;
    
    void SetupPixelFormat(HDC hdc)
    {
    int npixelformat;
    
    static PIXELFORMATDESCRIPTOR pfd = {
    	sizeof(PIXELFORMATDESCRIPTOR),
    		1,
    		PFD_DRAW_TO_WINDOW |
    		PFD_SUPPORT_OPENGL |
    		PFD_DOUBLEBUFFER,
    		PFD_TYPE_RGBA,
    		32,
    		0, 0, 0, 0, 0, 0,
    		0,
    		0, 
    		0,
    		0, 0, 0, 0,
    		16,
    		0,
    		0,
    		PFD_MAIN_PLANE,
    		0, 
    		0, 0, 0,};
    	
    	
    	npixelformat = ChoosePixelFormat(hdc, &pfd);
    	SetPixelFormat(hdc, npixelformat, &pfd);
    	}
    
    LRESULT  CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	static HGLRC hRC;
    	static HDC hdc;
    	char  hello[] = "HELLO SARA";
    	int width, height;
    
    
    	switch(message){
    
    	case WM_CREATE:
    
    		hdc = GetDC(hwnd);
    		g_HDC = hdc;
    
    		SetupPixelFormat(hdc);
    
    		hRC = wglCreateContext(hdc);
    		return 0;
    		break;
    
        case WM_CLOSE:
    
    		wglMakeCurrent(hdc, NULL);
    		wglDeleteContext(hRC);
    		PostQuitMessage(0);
    		return 0;
    		break;
    
    	case WM_SIZE:
    		height = HIWORD (lParam);
    		width  = LOWORD (lParam);
    		if(height == 0)
    		{
    			height = 1;
    		}
    
    		glViewport(0, 0, width, height);
    		glMatrixMode(GL_PROJECTION);
    		glLoadIdentity();
    		gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 1.0f, 1000.0f);
    		glMatrixMode(GL_MODELVIEW);
    		glLoadIdentity();
    		return 0;
    		break;
    	default:
    		break;
    	}
    	return (DefWindowProc(hwnd, message, wParam, lParam));
    }
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
    
    
    
    	
    	
    	
         static char szAppName[] = TEXT ("opengl") ;
    	  BOOL  done;
         HWND         hwnd ;
         MSG          msg ;
         WNDCLASSEX     wndclass ;
         wndclass.cbSize        = sizeof(wndclass); 
         wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
         wndclass.lpfnWndProc   = WndProc ;
         wndclass.cbClsExtra    = 0 ;
         wndclass.cbWndExtra    = 0 ;
         wndclass.hInstance     = hInstance ;
         wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
         wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
         wndclass.hbrBackground = NULL;
         wndclass.lpszMenuName  = NULL ;
         wndclass.lpszClassName = szAppName ;
         wndclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
         RegisterClassEx(&wndclass);
    
    	
    
    hwnd = CreateWindow ( szAppName,                  // window class name
                              TEXT ("opengl"), // window caption
                              WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN|WS_CLIPSIBLINGS,       // window style
                              100,              // initial x position
                              100,              // initial y position
                              400,              // initial x size
                              400,              // initial y size
                              NULL,                       // parent window handle
                              NULL,                       // window menu handle
                              hInstance,                  // program instance handle
                              NULL) ;  
    
                  if(!hwnd)
    		 return 0;   
         
         ShowWindow (hwnd, iCmdShow) ;
         UpdateWindow (hwnd) ;
         done = FALSE;
    
    	 while(!done)
    	 {
    		 PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE);
    		 if(msg.message == WM_QUIT)
    		 {
    			 done  = TRUE;
    		 }
    		 else
    		 {
    
    
    
    
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glLoadIdentity();
    	angle = angle + 0.1f;
    
    	if(angle >= 360.0f)
           angle = 0.0f;
    	glTranslatef(0.0f, 0.0f, -5.0f);
    	glRotatef(angle, 0.0f, 0.0f, 1.0f);
    	glColor3f(1.0f, 0.0f, 0.0f);
    	
    	
    	glBegin(GL_TRIANGLES);
    
    	glVertex3f(0.0f, 0.0f, 0.0f);
    	glVertex3f(1.0f, 0.0f, 0.0f);
    	glVertex3f(1.0f, 1.0f, 0.0f);
    
    	glEnd();
    
    	SwapBuffers(g_HDC);
    
    	TranslateMessage(&msg);
    	DispatchMessage(&msg);
    		 }
    	 }
    
    	 return  msg.wParam;
    }

  11. #11
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    opengl game programming is a good book with horrible CD
    support .be mindfull if u buy it because %30 of its source code
    crash upon compiling
    i couldn't disagree more, i have never had a problem, i love the book and think it has great cd support.

  12. #12
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by SAMSAM
    note*opengl game programming is a good book with horrible CD
    support .be mindfull if u buy it because %30 of its source code
    crash upon compiling
    Eehm, What compiler is used for examples in that book? your
    compiler?

  13. #13
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Visual Studio 6 (i forget if it was pro or std, but i use std)

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by RoD
    Visual Studio 6
    Well now, What compiler do you have SAMSAM?

  15. #15
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    >>shows just the window and no triangle rotating and i dont know why

    You opengl files aren't placed in the right places! Double check them, its not the books fault, its yours :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get relative mouse coordinates when GLUT return absolute
    By joeprogrammer in forum Game Programming
    Replies: 14
    Last Post: 02-10-2009, 06:35 PM
  2. Running into trouble with GLUT.
    By Josh@Dreamland in forum C++ Programming
    Replies: 4
    Last Post: 12-29-2007, 09:32 PM
  3. Glut
    By Matty_Alan in forum C Programming
    Replies: 7
    Last Post: 07-16-2007, 07:01 AM
  4. GLUT and Dev-CPP
    By Canadian_coder in forum Game Programming
    Replies: 4
    Last Post: 12-22-2004, 03:12 AM
  5. Dis/Advantages of Glut?
    By Zeusbwr in forum Game Programming
    Replies: 1
    Last Post: 11-28-2004, 10:00 PM