Display list not displaying?

This is a discussion on Display list not displaying? within the Game Programming forums, part of the General Programming Boards category; Iv'e made a display list for a cube, but when i glCallList();, i don't see the cube. Probably somthing simple ...

  1. #1
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070

    Display list not displaying?

    Iv'e made a display list for a cube, but when i glCallList();, i don't see the cube.
    Probably somthing simple iv'e overlooked (as usual).

    Code:
    GLvoid SolidCube(float Length, float Width, float Height, float elevation, float posX, float posZ, 
    			   BOOL bTransparent,
    			   float t1btmU, float t1btmV, float t1topU, float t1topV, float t1bakU, float t1bakV, float t1fntU, float t1fntV, float t1lftU, float t1lftV, float t1rhtU, float t1rhtV,
    			   float t2btmU, float t2btmV, float t2topU, float t2topV, float t2bakU, float t2bakV, float t2fntU, float t2fntV, float t2lftU, float t2lftV, float t2rhtU, float t2rhtV,
    			   float t3btmU, float t3btmV, float t3topU, float t3topV, float t3bakU, float t3bakV, float t3fntU, float t3fntV, float t3lftU, float t3lftV, float t3rhtU, float t3rhtV)
    {	
    	GLuint SCube;	
    	SCube = glGenLists(1);
    	glNewList(SCube, GL_COMPILE);
    	
    	LoadTextures();
    	while (bTransparent)
    	{
    		glEnable(GL_BLEND);	
    		glBlendFunc(GL_ONE, GL_ONE);
    	}
    
    	glActiveTextureARB		= (PFNGLACTIVETEXTUREARBPROC)		wglGetProcAddress("glActiveTextureARB");
    	glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)		wglGetProcAddress("glMultiTexCoord2fARB");
    	glActiveTextureARB(GL_TEXTURE0_ARB);
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D,  g_Texture[4]);
    	glActiveTextureARB(GL_TEXTURE1_ARB);
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D,  g_Texture[2]);
    	glActiveTextureARB(GL_TEXTURE2_ARB);
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D,  g_Texture[3]);
    	
    	glBegin(GL_QUADS); //bottom
    	glNormal3f( 0.0f, -1.0f, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1btmU, t1btmV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2btmU, t2btmV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3btmU, t3btmV);
    	glVertex3f(-Width/2 + posX, elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1btmU, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2btmU, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3btmU, 0.0f);
    	glVertex3f(-Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, 0.0f);
    	glVertex3f(Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, t1btmV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, t2btmV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, t3btmV);
    	glVertex3f(Width/2 + posX, elevation, Length/2 + posZ);
    	glEnd();
    	
    	glBegin(GL_QUADS); //top
    	glNormal3f( 0.0f, 1.0f, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1topU, t1topV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2topU, t2topV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3topU, t3topV);
    	glVertex3f(-Width/2 + posX, elevation + Height, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1topU, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2topU, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3topU, 0.0f);
    	glVertex3f(-Width/2 + posX, elevation + Height, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, 0.0f);
    	glVertex3f(Width/2 + posX, elevation + Height, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, t1topV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, t2topV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, t3topV);
    	glVertex3f(Width/2 + posX, elevation + Height, Length/2 + posZ);
    	glEnd();
    	
    	glBegin(GL_QUADS); //back
    	glNormal3f( 0.0f, 0.0f, -1.0f);	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1bakU, t1bakV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2bakU, t2bakV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3bakU, t3bakV);
    	glVertex3f(-Width/2 + posX, Height + elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1bakU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2bakU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3bakU, 0.0);
    	glVertex3f(-Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, 0.0);
    	glVertex3f(Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, t1bakV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, t2bakV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, t3bakV);
    	glVertex3f(Width/2 + posX, Height + elevation, -Length/2 + posZ);
    	glEnd();
    	
    	glBegin(GL_QUADS); //front
    	glNormal3f( 0.0f, 0.0f, 1.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1fntU, t1fntV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2fntU, t2fntV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3fntU, t3fntV);
    	glVertex3f(-Width/2 + posX, Height + elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, t1fntU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, t2fntU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, t3fntU, 0.0);
    	glVertex3f(-Width/2 + posX, elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, 0.0);
    	glVertex3f(Width/2 + posX, elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, Width, t1fntV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, Width, t2fntV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, Width, t3fntV);
    	glVertex3f(Width/2 + posX, Height + elevation, Length/2 + posZ);
    	glEnd();
    	
    	glBegin(GL_QUADS); //left side
    	glNormal3f(-1.0f, 0.0f, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -t1lftU, t1lftV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -t2lftU, t2lftV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -t3lftU, t3lftV);
    	glVertex3f(-Width/2 + posX, Height + elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -t1lftU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -t2lftU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -t3lftU, 0.0);
    	glVertex3f(-Width/2 + posX, elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -Length, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -Length, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -Length, 0.0);
    	glVertex3f(-Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -Length, t1lftV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -Length, t2lftV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -Length, t3lftV);
    	glVertex3f(-Width/2 + posX, Height + elevation, -Length/2 + posZ);
    	glEnd();
    	
    	glBegin(GL_QUADS); //right side
    	glNormal3f( 1.0f, 0.0f, 0.0f);
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -t1rhtU, t1rhtV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -t2rhtU, t2rhtV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -t3rhtU, t3rhtV);
    	glVertex3f(Width/2 + posX, Height + elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -t1rhtU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -t2rhtU, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -t3rhtU, 0.0);
    	glVertex3f(Width/2 + posX, elevation, Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -Length, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -Length, 0.0);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -Length, 0.0);
    	glVertex3f(Width/2 + posX, elevation, -Length/2 + posZ);
    	
    	glMultiTexCoord2fARB(GL_TEXTURE0_ARB, -Length, t1rhtV);
    	glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -Length, t2rhtV);
    	glMultiTexCoord2fARB(GL_TEXTURE2_ARB, -Length, t3rhtV);
    	glVertex3f(Width/2 + posX, Height + elevation, -Length/2 + posZ);
    	glEnd();
    	glEndList();
    }
    Code:
    VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC )
    {
    	PIXELFORMATDESCRIPTOR pfd;
    	int iFormat;
    	float ScreenDepth = 16;
    	float ColorDepth = 24;
    	
    	// get the device context (DC)
    	*hDC = GetDC( hWnd );
    	
    	// set the pixel format for the DC
    	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 = ColorDepth;
    	pfd.cDepthBits = ScreenDepth;
    	pfd.iLayerType = PFD_MAIN_PLANE;
    	iFormat = ChoosePixelFormat( *hDC, &pfd );
    	SetPixelFormat( *hDC, iFormat, &pfd );
    	
    	// create and enable the render context (RC)
    	*hRC = wglCreateContext( *hDC );
    	wglMakeCurrent( *hDC, *hRC );
    
    	SolidCube(0.5, 0.5, 0.5, 0.0, 0.0, 0.0,
    	FALSE,
    	2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0,
    	2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0,
    	2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0, 2.5, 1.0);
    	
    }
    Code:
    // enable OpenGL for the window
    	EnableOpenGL( EditWin, &hDC, &hRC );
    	
    	// program main loop
    	while ( !bQuit ) {
    		
    		// check for messages
    		if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
    			
    			// handle or dispatch messages
    			if ( msg.message == WM_QUIT ) {
    				bQuit = TRUE;
    			} else {
    				TranslateMessage( &msg );
    				DispatchMessage( &msg );
    			}
    			
    		} else {
    			
    			ProjMatrix();
    			void RenderScene();
    			{
    				//CreateFog(5, 100, 0.05, 0.5, 0.5, 0.5);
    				ModelMatrix();
    				glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    				glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    				
    				glPushMatrix();
    				glCallList(SCube);
    				glPopMatrix();
    				SwapBuffers( hDC );				
    				
    				//MouseMove();
    				KeyboardInput();
    				
    			}
    			
    			
    			
    		}
    		
    	}
    any help will be very much appreciated!

    -psychopath
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    im not even sure where to start....

    i dont mean to deter you from graphics programming, but your code suggests that you dont really understand how OpenGL works. Youve included your LoadTextures call in your compiled display list (do you really want to do that every time the list is called?), you enable the same GL state variable 3 times in a row. (once its enabled, it stays that way untill you glDisable() it)... and you make way more calls to glBegin() and glEnd() than neccessary.

    Go to NeHe's site and check out the opengl tutorials there. That will help you get a cube on the screen. once you can render that building a display list should not be hard.

  3. #3
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    yea....i'm pretty much learning as i go, so that really helps.

    getting a cube on the screen isn't the problem....iv'e done that hundreds of times before, and for the display list i'm following the NeHe tutorial on it, but i still can't get it to work.

    anyway, what you have told me helps alot...but i'd still like to know why the display list dosn't work

    -psychopath
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by psychopath
    anyway, what you have told me helps alot...but i'd still like to know why the display list dosn't work
    its hard to say what exactley doesnt work. i cant run your code because i dont use windows

    have a look at this tut, it uses display lists.
    http://www.lighthouse3d.com/opengl/displaylists/

  5. #5
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    >>i cant run your code because i dont use windows<<
    yeah! fight the power! o.0\m/ :P.....i myself only use windows for programming...every other time i use linux

    anyway, i'll have a look at that tutorial tomorrow probably...don't have time at the moment

    -psychopath
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  6. #6
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    just fixed those errors....Perspective i will forever worship you...you have solved my FPS woes ;
    still havn't gotten to that tut yet tho...

    -psychopath
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. deleting a node in linked list
    By BoneXXX in forum C Programming
    Replies: 18
    Last Post: 12-17-2007, 11:30 AM
  2. urgent please please..
    By peter_hii in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2006, 05:35 AM
  3. Anyone good with linked list.....I am not....
    By chadsxe in forum C++ Programming
    Replies: 11
    Last Post: 11-10-2005, 01:48 PM
  4. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

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