Jump to content
  • Advertisement
Sign in to follow this  
Spunkmeyer

Strange Error...

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

 
void topgl::drawbox(int x,int y,int width, int height,float r,float g,float b,float a){
    glColor4f(r,g,b,a);
    glPushMatrix();
    glLoadIdentity();
    if(a < 1.0){
        glEnable(GL_BLEND);
    }
    glTranslated(x,y,0);
    glBegin(GL_LINE_LOOP);
    glVertex2i(width,height);
    glVertex2i(width,0);
    glVertex2i(0,0);   
    glVertex2i(0,height);
 
    glEnd(); 
    if(a < 1.0){
        glDisable(GL_BLEND);
    }    
    glPopMatrix(); 
}

So far for the Code.But strangely, that's the result: strange...
What do you think??

Share this post


Link to post
Share on other sites
Advertisement
May be, you are asking about pixel-perfect texturing and drawing... may be...
So, this topics will help you.

http://www.gamedev.net/community/forums/topic.asp?topic_id=343952
http://www.gamedev.net/community/forums/topic.asp?topic_id=343825

Share this post


Link to post
Share on other sites
He's talking about pixel perfect line drawing. I see the same problem in my own program. Let's say you do something like:

glTranslated(x,y,0);
glBegin(GL_LINE_LOOP);
glVertex2i(0,0);
glVertex2i(10,0);
glVertex2i(10,10);
glVertex2i(0,10);
glEnd();

What you should get is a perfectly drawn box using lines. However, depending on what 'x' and 'y' are, the 4 lines can 'jitter' a little, sometimes not lining up quite right, sometimes missing a pixel at a corner, etc. In ASCII art...

// What you want...
----------
| |
| |
| |
----------

// What you can get ...
----------
| |
| |
| |
----------
// or
---------
| |
| |
| |
----------

You can tweak the x and y values to get it to line up just right on your machine, but NVidia and ATI cards have different 'fudge factors' required to get them to line up perfectly. I haven't found a good solution for this yet.

Share this post


Link to post
Share on other sites
I can fix the Problem, when I add 1 to some coordinates. But on other Grapic-Cards it may look stupid again and its not mathematically correct.

Setting the interpolation of textures doesn't do it.

So, have I to check the vendor of the graphic-board and apply the specific variables? That would be ... dirty!

I wanted a clean box, why is it so complicated... :-(

Share this post


Link to post
Share on other sites
Unfortunately, I've tried that with no success. I believe it works to get pixel-perfect texturing, but it does not solve the issue with GL_LINES not lining up properly.

Share this post


Link to post
Share on other sites
Perhaps... but I would then need repeated switches between glPolygonMode(GL_LINE/GL_FILL). I my case, I'm using lines and textured quads to draw my GUI. It would be cumbersome to draw all the textured quads, and then all the lined-quads. Plus, not all line drawing I'm doing can be accomplished using quads.

It's disappointing that this difference exists between OGL implementations, but I can't say I'm surprised. I eventually may switch over to using textured quads for everything, but I can live with the not-so-perfect lines for now.

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!