Jump to content
  • Advertisement
Sign in to follow this  
Cyntalan

OpenGL odd representation of textures - EDIT - I is dumb, disregard

This topic is 3674 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

I have a triangular shaped object, flat on both sides, to where I want a solid color texture on one flat side, and a scribing on the opposite. To do this, I made my textures as necessary, loaded, mapped them accordingly, but this is where things go awry. My first problem might be simple and actually solve my real problem, or maybe that's just how it's done and I have to figure something else out. I've noticed that my texture mapping has actually mapped the texture on both sides, one side a mirror of the other. I know that happens with some setting not in place, but I'm not sure if that's actually what's causing my real problem. I actually built this in half originally so when I began, it looked fine. The scribe was showing fine, rotated it around, noticed the mirror, "meh"d past it thinking when I place the other half in place, I'd never see it anyway. However, when I did place the other half, I was able to see directly through the texture, as if it weren't there, to the other half's texture. Upon rotation, I was able to see through the solid side to the mirrored scribe. Now I'm totally confused. My understanding (from my experience in 3D modelling) is that the normals are backwards. My understanding of openGL is that to draw a triangle with the correct normals, you draw the vertices in counter-clockwise order facing the direction you intend on it being visible. Am I totally missing something? Also, is this explanation of my problem too vague and requiring source code help? [Edited by - Cyntalan on July 25, 2008 3:38:53 PM]

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure I fully understand your problem. Some screenshots and probably some code would help (at least me [smile]).

In OpenGL you can define whether counter clockwise or clockwise winding describes the front face. You can also define that backface culling should be disabled and that one side should be drawn filled and the other as a wireframe.

You can't define distinct textures for both sides of a triangle (except when using shaders and calculating the side yourself or setting the texture accordingly before drawing the triangle). The driver will draw the triangle and use whatever texture is set, which means due to the "mirroring" of the vertices (including texture coordinates) one side will show the "mirrored" texture.

Drawing two triangles using the same vertices (at least positions) but different winding should work, if you have backface culling enabled. If not, you might suffer from z-fighting, i.e. the driver finds fragments with equal depth and might decide to reject the new ones (if the z-pass condition is GL_LESS), i.e. the triangle drawn first would always prevent the second triangle to show up. Try glEnable(GL_CULL_FACE);

Share this post


Link to post
Share on other sites
EDIT: Boy is my face red. Stupidity on my part was proven by enabling culling. Normals were being drawn EXACTLY how I told 'em.... which was absolutely wrong. Please disregard this waste of disk space and bandwidth. ^^;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!