12 Replies - 620 Views - Last Post: 04 July 2013 - 07:09 PM Rate Topic: -----

#1 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

OpenGL glCallList calls all lists?

Posted 03 July 2013 - 09:57 AM

Me again heh, i hope it doesnt seem like asking you guys is my first response to every problem i encounter, but im stumped again. What i think is happening is that glCallList is calling every list i've every made. Im trying to render 3d text saying "BAT", but instead i get three renditions(?) of every object i have loaded up to that object. I made some pictures to illustrate the issue. The first picture is a sphere by itself. looks fine. Then i try to render "BAT" as 2d text and it gets weird. I thought that maybe glCallList was drawing all my objects, so i changed the sphere.obj to the 3D-letter-C.obj. The rest of the images are self explanatory i think.

Image(Each image is one scene, the red is beacuse there is a red quad in the background)
Spoiler


My Code to Load Objects looks something like this:(Here is where i think the problem lies?)
Spoiler


Here is my Draw Text Function, but i dont think there is anything wrong with it
Spoiler


I originally thought that it was calling all lists up to the called-list, but i dont think that anymore because in image 3 an almost perfect 'C' is rendered even though it was suppose to be an 'A'(in "CAT"). Some how, the first object i loaded(The Sphere, The C, the M) alters the rest of the objects?

This post has been edited by Nano511: 03 July 2013 - 12:56 PM


Is This A Good Question/Topic? 0
  • +

Replies To: OpenGL glCallList calls all lists?

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 12:04 PM

Hi,

What type of font are you trying to display... ??

Bitmap font, or Outline Font or Texture Font... ??

also why is glGenLists range a 1 ??

this doesnt seem right as you are using 3 characters ..

Best Wishes.

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#3 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 12:48 PM

Hi snoopy. Im not sure what the font is, but i created each 3d letter in blender and exported them as .obj's. My objectLoader function's purpose is the read the .obj's and their corresponding .mtl's(material file), create a display list to display the object, then return the number that was used to make the new list. glGenLists' range is 1 because the objects are loaded one at a time. The Text class has a list of each identifier for each letter(.obj), called characters. characters is a vector of unsigned ints.

	std::vector<GLuint> chars;
	char tmp[40];
	for( int i =0; i < 26; i++)
	{
		sprintf(tmp, "Font/%d.obj", i);        //store filename in tmp
		GLuint tmp2 = objectLoader.Load(tmp); //objectLoader.Load(tmp) returns a GLuint from glGenLists(1)
		chars.push_back(tmp2);
	}
	text = new Text(1.0f,0.8f, chars  );



My A obj is called 0.obj, B is 1.obj, etc.
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 01:15 PM

Ok,

Weird way to display text in opengl but you are just loading them as bitmaps and displaying them through glCallList ?

This is where you must be having difficulty through glPushMatrix...

what is your matrix mode ?

There is nothing you have posted so far that seems obviously wrong so my guess your problem lies elsewhere like the matrix mode.

The glPushMatrix function pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on the top of the stack is identical to the one below it.

I think you need to give up more code.

Best Wishes

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#5 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 01:30 PM

Im not sure if you understand, but the text is 3D. Each letter in the alphabet has been modeled in blender. There are no bitmaps.

Im not sure what code you would want to see, but heres more code anyways.

main.cpp Init Function:
Spoiler


main.cpp Display Function:
Spoiler



ObjectLoader::Load. Used for loading .obj and .mtl.
WARNING: is a doozy.
I think you might like to see code around lines 248 and 410
Spoiler

This post has been edited by Nano511: 03 July 2013 - 01:33 PM

Was This Post Helpful? 0
  • +
  • -

#6 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 01:48 PM

Right,

They are .obj's.

They are obviously being loaded so the problem must lie in the Display part.

However still not seeing a call to glMatrixMode.

Snoopy.

Edit scratch that saw where glMatrixMode was hiding...

This post has been edited by snoopy11: 03 July 2013 - 01:53 PM

Was This Post Helpful? 0
  • +
  • -

#7 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 01:52 PM

The last call to glMatrixMode is glMatrixMode(GL_MODELVIEW), as seen in the Init() function.

Edit: Perhaps there are no problems in the code i've shown, but could you give me your guess as to what you think might be happening? It was suppose to render "BAT" in 3d letters, but the 'B' and 'T' have other letters drawn in and on them.

This post has been edited by Nano511: 03 July 2013 - 02:07 PM

Was This Post Helpful? 0
  • +
  • -

#8 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 02:32 PM

Could you try this and tell me

what happens

//Draw the 3D Text(DrawText(position, rotation, stringToDisplay))
text->DrawText(coordinate(10,0,0), coordinate(0,0,0),"BAT\n");

Thanks

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#9 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 02:38 PM

Nothing changed. Just curious, why did you think that would change anything?

Edit: "AAA" works perfectly if no other object is loaded before the alphabet objects are loaded.
Edit: "ABC": 'A' is good, 'B' has an A over it, 'C' has an A and a B over it. This is with no other objects besides the alphabet being loaded.
EDIT: "AAA", but with a 'Z' loaded before the alphabet: It is 3 A's with a Z over each. note that Z has just been loaded only. no call to render Z was made.
EDIT: "AAA", but with 'z' loaded AFTER the alphabet: 3 A's, like it should be.
EDIT: "AAA", but with a sphere.obj loaded before the alphabet, 3 spheres(A's are believed to be inside the spheres). Note that no call to render a sphere was ever made, it was only loaded.


Im pretty certain now that all objects that have been loaded are drawn when a glCallList is called.

This post has been edited by Nano511: 03 July 2013 - 02:48 PM

Was This Post Helpful? 0
  • +
  • -

#10 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 768
  • View blog
  • Posts: 2,234
  • Joined: 20-March 10

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 02:52 PM

Thats interesting.

You must be drawing over each letter


You might need to do something like this.
void Text::DrawText(coordinate pos, coordinate rot, const char* tex)
{
	

		int g=0;
		for(unsigned int i =0; i < strlen(tex);i++)
		{
			glPushMatrix();
		        glTranslatef(pos.x, pos.y, pos.z);
		        glRotatef(rot.x, 1.0, 0.0, 0.0);
		        glRotatef(rot.y, 0.0, 1.0, 0.0);
		        glRotatef(rot.z, 0.0, 0.0, 1.0);

                        if(tex[i]=='\n')
			{
				glTranslatef(-g*width, -height, 0);
				g=0;
				continue;
			}
			g++;

			glCallList(characters.at((int)tex[i]-65));
			glTranslatef(width,0,0);
                 
                        glPopMatrix();
}
		}

	





But I am not sure as it is an unconventional way to draw text.

Here is a more conventional way using bitmap fonts

http://nehe.gamedev....ap_fonts/17002/

Regards

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#11 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 03 July 2013 - 05:56 PM

Alright but i still cant call 2 different glCallList()s. I've removed any code about text and i've just loaded and rendered the letter A and the letter Z in that order. A is fine, but Z has an A inside/ontop of it.

This post has been edited by Nano511: 03 July 2013 - 06:31 PM

Was This Post Helpful? 0
  • +
  • -

#12 Nano511  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 145
  • Joined: 07-October 12

Re: OpenGL glCallList calls all lists?

Posted 04 July 2013 - 07:07 PM

I figured it out, thought i should post the solution in case anyone else ever has a similar problem. The problem was that ObjectLoader::vectorOfStrings wasnt cleared each time ObjectLoader::Load() was called, so the data from each object was piling on vectorOfStrings. This explains why A looked fine, but Z had all the other letters on top of it.
Was This Post Helpful? 1
  • +
  • -

#13 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1327
  • View blog
  • Posts: 4,552
  • Joined: 19-February 09

Re: OpenGL glCallList calls all lists?

Posted 04 July 2013 - 07:09 PM

I don't think you want to call glCallList but glCallLists.

See Executing Multiple Display Lists here :

Chapter 4 Display Lists
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1