5
Hi all,
I've began some test in opengl this afternoon. For the moment I'm using Purebasic.
There's something I really don't understand. How can I match the pixels of screen with the space axis positions? I explain:
if I'm trying to put a 32*32 pixel gfx onto screen, and that I want it to be displayed truely in 32*32pixels, how can it be done?
This is usefull for retro remakes, as the logos, fonts should be displayed like in the original way.
In my example, I've made a simple scrolltext. After playing with the values of glTranslatef, I've found "good" value to display it but it is NOT the good one that make it like the original size.
here is the part of the code, the bitmap texture is 640*300 bmp includebinary, the fonts are 64*50 pixels
cco = 0
For cc = 0 To 11
letter = (Asc(UCase(Mid(t.s, tptr+cc, 1)))-32)
xf = ((letter % 10)*64)
x.f = xf/640 ; find the x postion in matrix
yf = (5-((letter - (letter%10))/10))*50
y.f = yf/300 ; find the x position in matrix
larg.f = 64*1/640 ; find the size of the font in matrix depth
haut.f = 50*1/300
glLoadIdentity_() ;Reset The Current Matrix
glTranslatef_((cco+sco)-10.0,0,-20.0) ;Center On X, Y, Z Axis
glPushMatrix_()
glBindTexture_(#GL_TEXTURE_2D,texture(0)) ;Select Our Texture
glBegin_(#GL_QUADS)
glTexCoord2f_(x, y) : glVertex3f_(-1.0,-1.0, 0.0) ;Bottom Left Of The Texture and Quad
glTexCoord2f_((x+larg), y) : glVertex3f_( 1.0,-1.0, 0.0) ;Bottom Right Of The Texture and Quad
glTexCoord2f_((x+larg), (y+haut)) : glVertex3f_( 1.0, 1.0, 0.0) ;Top Right Of The Texture and Quad
glTexCoord2f_(x, (y+haut)) : glVertex3f_(-1.0, 1.0, 0.0) ;Top Left Of The Texture and Quad
glEnd_()
glPopMatrix_()
cco = cco + 2 ; here is the problem : why it works with 2 ??? dunno...
Next
sco-0.2
If sco<=-2.0
sco = 0.0
tptr+1
If tptr > (Len(t.s)-12)
tptr = 1
EndIf
EndIf