Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering Multiple models problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Wrathnut   Members   -  Reputation: 370

Like
0Likes
Like

Posted 12 March 2013 - 01:01 PM

Hi,

 

I think this problem might be related to the one I had the other day. But after an exhaustive search I am still not sure what I am doing wrong. Or if I am trying to render correctly.

 

I was able to get a model to render properly. So my next step was to try to make an stl::vector of different models and try to render them in the same way. When I do this I get some strange effects. I have attached an image of what is going on. I basically arranged a bunch of cubes into a square. It renders the cubes for the most part. (it seems to have messed up the color of one of them though) And then it also draws some extra stuff. I am guessing I am not addressing my models correctly but I am unsure how to do it.

 

I am also wondering if I am even using the right method to draw my models. The code below is when I am using to loop through my vector list of models and try to draw them:

 

        glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	
	for(int i=0; i < this->cubes.size(); i++){
		glColorPointer(4, GL_FLOAT, 0, &this->cubes[i]->colors[0]);
		glVertexPointer(3, GL_FLOAT, 0, &this->cubes[i]->vertices[0]);
		glNormalPointer(GL_FLOAT, 0, &this->cubes[i]->normals[0]);

		glDrawArrays(GL_QUADS, 0, this->cubes[i]->vertices.size());
	}

	

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

 

 

Any help would be greatly appreciated!

 

 

Attached Thumbnails

  • multiple cubes.JPG


Sponsor:

#2 Wrathnut   Members   -  Reputation: 370

Like
0Likes
Like

Posted 12 March 2013 - 03:30 PM

Looks like I have found the solution to my problem after messing around a bit.

 

The following line:

 

glDrawArrays(GL_QUADS, 0, this->cubes[i]->vertices.size());

 

should have been:

 

glDrawArrays(GL_QUADS, 0, this->cubes[i]->vertices.size()/3);

 

Everything seems to be rendering fine right now. For some reason it looked like it was rendering properly  using a single model. But after a few test cases I was able to determine that it in fact was suffering from the same problem as the multiple model drawing!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS