Archived

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

AzHole

Texturing vs. Other Non-Texturing Objects - Houston, we have a problem...

Recommended Posts

Havent been doing OpenGL for a while, but have been through NeHe pretty far with the tutorials and decided to try some things out myself. Wrote a simple app that first creates a set of GL_QUADS in the upper right corner of the screen with a mask and image (images are 256x256 but masked down to 200x50). This was working fine. I even added in the tutorial with bitmapped fonts being loaded in from a texture file. Still, working great. Then I decided to try and draw a line for a spacer, and what do you know, the line wont show up! For example... // Button ------------------------------------------------------------------- glLoadIdentity(); glColor3f(1.0f,1.0f,1.0f); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_DST_COLOR,GL_ZERO); glBindTexture(GL_TEXTURE_2D, texture[1]); glTranslatef(1.80f, 1.30f, 0.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, -4.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f, -4.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f, 0.5f, -4.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, -4.0f); glEnd(); glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[3]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, -4.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f, -4.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f, 0.5f, -4.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, -4.0f); glEnd(); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); // ---------------------------------------------------------------------------------------- // Spacer Line ----------------------------------------------------------------------- glLoadIdentity(); glLineWidth(2.0f); glColor3f(1.0f,1.0f,1.0f); glTranslatef(xpos,ypos,0.0f); glBegin(GL_LINES); glVertex3f(0.0f,0.0f, -4.0f); glVertex3f(10.0f,0.0f, -4.0f); glEnd(); // ---------------------------------------------------------------------------------------- And the line never shows up! xpos and ypos are defined earlier as floats so I can move the line inside the program and determine where it should be (easier then guessing and typing in numbers), of which both are initialized to 0.0f. I even tried turning on a few lights, but that had no effect, and even made the bitmap font strings I had turn funky colors. Anybody got an idea? I can email the entire source if needed. Thankx in advance. *Moving Forward Along the Backward Walkway of Technology* [edited by - AzHole on May 8, 2003 4:49:12 AM]

Share this post


Link to post
Share on other sites
I think that there is a problem of coordinates.
The button is drawn at a -4.0f on the Z plane, you activated masking, then you write the line on the same Z coordinates, this means that the line is "into" the button, try drawing it at, for example -3.9f and tell us what appened...

Or try to increase the LineWidth, it''s possible that the distance from the camera makes 2.0 uneffective.

---------------------------------------
There are 10 type of people:
those who knows binary code
and those who doesn''t
---------------------------------------

Share this post


Link to post
Share on other sites
Try disabling texturing while drawing your line:


  
// Spacer Line -----------------------------------------------------------------------

glLoadIdentity();
glDisable(GL_TEXTURE_2D); // Disable texturing

glLineWidth(2.0f);
glColor3f(1.0f,1.0f,1.0f);
glTranslatef(xpos,ypos,0.0f);
glBegin(GL_LINES);
glVertex3f(0.0f,0.0f, -4.0f);
glVertex3f(10.0f,0.0f, -4.0f);
glEnd();
glEnable(GL_TEXTURE_2D); // ... and enable it again

// ----------------------------------------------------------------------------------------




// Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions //

Share this post


Link to post
Share on other sites
Oy, thankyah much guys I reset the image textures to -3.9f (though that wasnt the problem, but thanx for noticing that, cleared up a few other artifacts I had laying around). I also disabled the 2D textures and that worked a treat. Thought I had tried that..oh well..it works now. Much appreciated guys Thanks a lot.

*Moving Forward Along the Backward Walkway of Technology*

Share this post


Link to post
Share on other sites