|
Post by DJLinux on May 6, 2010 2:01:33 GMT -5
Normaly in 2D mode the most left pixel colum are 0. But i don't get the red line visible. Is it only on my video card ? thank you for testing. Joshy dim w,h,IsOn Sub BlitterOn(On) if On and not IsOn then glViewPort(0,0,w,h) glDisable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() glOrtho(0,w,0,h,0,1) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() IsOn=True elseif not On and IsOn then glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) glPopMatrix() glEnable(GL_DEPTH_TEST) IsOn=False end if End Sub w=WindowWidth() h=WindowHeight() BlitterOn(True) glBegin(GL_LINES) glColor3f(1,0,0) glVertex2i(0,0) glVertex2i(0,h) glColor3f(0,1,0) glVertex2i(1,0) glVertex2i(1,h) glEnd() BlitterOn(False) Swapbuffers()
|
|
|
Post by Wayne Rayner on May 6, 2010 2:44:52 GMT -5
I got a complete black screen. Is that what you are getting? If I knew more OpenGL I'd actually try and help you.
|
|
|
Post by Supermonkey on May 6, 2010 4:07:14 GMT -5
Looks like a bug maybe? That's how I've set up a 2D viewport in the past.
|
|
|
Post by shadow008 on May 6, 2010 6:57:30 GMT -5
red line? I get a green line at the left of the screen.
|
|
|
Post by Supermonkey on May 6, 2010 8:22:27 GMT -5
The problem is that screen coordinates start at 0,0 and end at WindowWidth(), WindowHeight(). The red line therefore should be running vertically down the very edge of the screen and the green line should be running parallel to it, like in this example:
dim w,h,IsOn Sub BlitterOn(On) if On and not IsOn then glViewPort(0,0,w,h) glDisable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() glOrtho(0,w,0,h,0,1) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() IsOn=True elseif not On and IsOn then glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) glPopMatrix() glEnable(GL_DEPTH_TEST) IsOn=False end if End Sub w=WindowWidth() h=WindowHeight() BlitterOn(True) glBegin(GL_LINES) glColor3f(1,0,0) glVertex2i(1,0) glVertex2i(1,h) glColor3f(0,1,0) glVertex2i(2,0) glVertex2i(2,h) glEnd() BlitterOn(False) Swapbuffers()
However in order to get this effect you're actually starting at screen coordinates 1,1 and ending at WindowWidth(), WindowHeight(). I dunno why, I'm assuming it's a bug...
|
|
|
Post by DJLinux on May 6, 2010 11:36:37 GMT -5
to solve the problem i translated all one pixel to the right and moved the origin 0,0 to the top left. Joshy dim w,h,IsOn Sub BlitterOn(On) if On and not IsOn then glViewPort(0,0,w,h) glDisable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() glOrtho(0,w,h,0,-1,1) ' mirror the y axis to the top glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() glTranslatef(1,0,0) ' all one pixel to the right IsOn=True elseif not On and IsOn then glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) glPopMatrix() glEnable(GL_DEPTH_TEST) IsOn=False end if End Sub
w=WindowWidth() h=WindowHeight()
BlitterOn(True) w=w-1:h=h-1 glBegin(GL_LINES) glColor3f(1,0,0)' left line from top to bottom glVertex2i(0,0):glVertex2i(0,h)
glColor3f(0,1,0)' bottom line from left to right glVertex2i(0,h):glVertex2i(w,h) glColor3f(0,1,1)' right line from bottom to top glVertex2i(w,h):glVertex2i(w,0) glColor3f(1,1,0)' top line from right to left glVertex2i(w,0):glVertex2i(0,0)
glEnd()
BlitterOn(False) Swapbuffers()
|
|
|
Post by Supermonkey on May 6, 2010 16:49:07 GMT -5
You're still losing a pixel though aren't you? Not a big deal but a bit odd.
|
|
|
Post by DJLinux on May 7, 2010 2:40:56 GMT -5
losing a pixel why ? for example if your window/screen is 640x480 x = 0-639=640 pixels y = 0-479=480 pixels Joshy
|
|
|
Post by Supermonkey on May 7, 2010 3:16:32 GMT -5
Good point, I clearly wasn't thinking when I posted that.
|
|
|
Post by aphoticgenesis on May 7, 2010 3:27:56 GMT -5
Good point, I clearly wasn't thinking when I posted that. fail.
|
|
|
Post by shadow008 on May 7, 2010 13:38:28 GMT -5
Good point, I clearly wasn't thinking when I posted that. fail. one word post fail...
|
|
|
Post by Supermonkey on May 7, 2010 17:29:02 GMT -5
It doesn't require a reply... I'm just wondering usually opengl calls map 1 to 1 with basic4gl functions, is this an opengl thing or is it an issue with basic4gl?
|
|
|
Post by aphoticgenesis on May 7, 2010 20:09:31 GMT -5
fail at trying to post about a fail.
|
|
|
Post by shadow008 on May 7, 2010 20:34:30 GMT -5
fail at trying to post about a fail. tsk tsk, i thought we had learned our lesson in the "Your Banned" thread.... back to the general question: DJLinux: The first time i tested this was on the schools comps and got said results above.... On my comp: When i run your first post of code, i just get a blank screen in fullscreen and windowed mode.... is that what your problem is? When i run your second post of code, i get a blue line on the right and green line on the bottom.... What seems to be the problem? I see nothing wrong with your code....
|
|
|
Post by DJLinux on May 7, 2010 23:18:27 GMT -5
hello shadow thanx for testing if i run the first code glColor3f(1,0,0) ' this red lin xpos=0 aren't visible glVertex2i(0,0) glVertex2i(0,h) glColor3f(0,1,0) ' the second green line xpos=1 are visible glVertex2i(1,0) glVertex2i(1,h) if i run the second code (all pixels translate one pos to the right and y on top) i get a box with 4 lines if you get only 2 looks like my video driver has a problem. Joshy
|
|