Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Xtreme

OpenGL texture mapping using OpenGL

This topic is 6356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi there... I have a problem where I created a 3d object using glBegin(GL_LINES) and using glVertex3f() to specify the points. So, the 3d wireframe is ok. But when I try to put some texture on it, by using glBindTexture, etc, I still get a wireframe model but the wireframe itself are textured! I don''t want a wireframe anymore, I want a solid model (textured of course). Where am I going wrong? Xtreme.

Share this post


Link to post
Share on other sites
Advertisement
THANKS! that worked

BUT!

if I don''t texture it, i get multiple lines instead of the required ones. How can I get rid of the extra lines used to make up the mesh?

Share this post


Link to post
Share on other sites
Could be due to previously using GL_LINES instead of GL_TRIANGLES. You might be trying to draw much more than neccessary but still getting the same effect when textured.

Share this post


Link to post
Share on other sites
actually quite the opposite! I can see that more (unnecessary) lines are drawn with GL_TRIANGLES. but its ok with GL_LINES.
But, when I decide to put a texture on it, the one with GL_TRIANGLES comes out solid while the one with GL_LINES is textured in wireframe only.

Also, how can I divide up the textures in the whole 3d wireframe so that I can have I have say one texture on the body, a different one on the arms, etc... (that is, having multiple textures on the one object?) Currently, this texture is mapping to every single part of the object!

Share this post


Link to post
Share on other sites
currently this is how I implemented it:

  
glEnable(GL_TEXTURE_2D);
//glEnable(GL_BLEND);


glBindTexture(GL_TEXTURE_2D, texId[2]);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

glBegin(GL_TRIANGLES);
//draw object using glVertex3f() only

glEnd();

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
//glDisable(GL_BLEND);




Now, with this, I get one texture mapped to all of the object, how can I divide it up?

Share this post


Link to post
Share on other sites
i dont really understand what u want to do
do u want to draw the solid model textured
and then afterwards draw a wireframe version of the model over the top of it so u can see the individual tris of the solid model.

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
zeedzeek, i don''t want a wireframe model. (i just did that to see if the lines were drawn right).

I want a solid model but since I made this model from one piece (that is, from glvertex3fs) I now want parts of the object to be texture mapped with not just one, but multiple textures.

Is that possible?

Share this post


Link to post
Share on other sites
to use multiple textures u have to break your model(mesh) up into multiple meshes cause u cant go
glBegin(GL_TRIANGLES)
vertex,vertex,vertex etc
bind another texture
vertex,vertex,vertex etc
bind another texture
vertex,vertex,vertex etc
glEnd( );

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
so in other words, you are saying to attach a separate texture, i must use glBegin() and glEnd() separately? which means I have to break up the object into several objects?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!