PDA

View Full Version : 2d opengl line not the same size after mirroring



tergezz
12-05-2009, 08:58 AM
hallo together,

i am a bit new to opengl. i am working with opengl via the openframeworks toolkit. i have a question about drawing a line and then mirroring it and draw it again. my problem is that this line dont looks the same when i draw it mirrored. the best would be if you look to the atached pic below (it is a 500% zoomed screenshot of my 1 pixel line):

http://i915.photobucket.com/albums/ac355/strato_strichnin/gl_line_5000.jpg

here are some code snippets which i tried:


void testApp::draw(){

ofPushMatrix();
ofTranslate(1024/2+60,768/2);

glBegin(GL_LINES);
glVertex2f(30,0);
glVertex2f(35.0,5.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(35.0,5.0);
glVertex2f(35.0,19.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(35.0,19.0);
glVertex2f(34.0,20.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(20,0);
glVertex2f(15.0,5.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(15.0,5.0);
glVertex2f(15.0,19.0);
glEnd();
glBegin(GL_LINES);
glVertex2f(15.0,19.0);
glVertex2f(16.0,20.0);
glEnd();
ofPopMatrix();

ofPushMatrix();
ofTranslate(1024/2+30,768/2);

glBegin(GL_LINE_STRIP);
glVertex2f(30,0);
glVertex2f(35.0,5.0);
glVertex2f(35.0,19.0);
glVertex2f(34.0,20.0);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex2f(20,0);
glVertex2f(15.0,5.0);
glVertex2f(15.0,19.0);
glVertex2f(16.0,20.0);
glEnd();
ofPopMatrix();

ofPushMatrix();
ofTranslate(1024/2,768/2);

for(int j=0;j<2;j++){
glBegin(GL_LINE_STRIP);
glVertex2f(0,0);
glVertex2f(5.0,5.0);
glVertex2f(5.0,19.0);
glVertex2f(4.0,20.0);
glEnd();

ofRotateZ(180);
ofRotateX(180);
ofTranslate(10,0);
}

ofPopMatrix();

ofPushMatrix();
ofTranslate(1024/2+30,768/2);

for(int j=0;j<2;j++){
glBegin(GL_LINE_STRIP);
glVertex2f(0,0);
glVertex2f(5.0,5.0);
glVertex2f(5.0,19.0);
glVertex2f(4.0,20.0);
glEnd();

glScalef(-1, 1, 1);
ofTranslate(10,0);
}
ofPopMatrix();
}


all the snippets failed.
so i think you see what my problem is.
my question now is: is it be posibble to draw the line that it exactly looks the same like the first one? or is this not possible cause of antialiasing and other issues?

tergezz
12-29-2009, 09:52 AM
hallo people,

hope you all had a nice christmas.
i had some time during the xmas days so i tried again to fix my problem but without success. are there any german speaking people around here so that i can write down my problem in german language maybe then i can better describe my problem.
i searched around on many different pages but the only solutions which come near my problem was that it maybe has something todo with the size of the opengl window and a distortion trough the window size. changing my opengl window has also no success. anny ideas what is going wrong. anyone also working with 1px thin lines?

tergezz
12-29-2009, 11:20 AM
hey guys, i got it,

found it here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=556634

a line is not a line, it is a rect. so i positioned it not on 0 but rather on 0.5 and the problem is away.