Switched to glortho, now textures are TINY!? Help!

Started by
3 comments, last by Clancy 22 years, 3 months ago
I switch from perspective to ortho, since I am making 2d game. Problem, now all my textures are VERY small, and I can''t understand why. my setup code is: code: -------------------------------------------------------------------------------- glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width,height,0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0,0,width,height); -------------------------------------------------------------------------------- and my textures are size 128x64, and 32x64, and when display on screen now, they look like few pixels. I can do scale(50,50,50); then I see then again, but I do not understand why I need to do this? when I use perspective then the textures are correct! I am confused why I need to scale, or do glvertex2f(50.0,50.0) from glvertex2f(1.0,1.0)!! Oh yes, also I notice I do glscale(-50,50,50) since now textures are flipped? I look at many books, and they no say why! Help! Many thanks friends! --Clancy
Advertisement
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width,height,0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0,width,height);

this should make 1:1 mapping on the screen thus if your screen->width = 1024 + u draw something 32 units wide (32x64) this should appear to be 1/32th of the windows width (ie quite small)
also try to avoid glScale in this case to make it bigger

http://uk.geocities.com/sloppyturds/gotterdammerung.html
So you saying that since I use glvertex2f(1,1) that really is only 1 pixel big, and then I should use glvertex2f(128,64)
to fix the problem?

I never think of that! Thanks!

I try now!

OK, this works better now, but I still need scale to mirror image in correct direction.

I am using :
glVertex2d(32,64); // Top Right
glVertex2d(-32,64); // Top Left
glVertex2d(-32,-64); // Bottom Left
glVertex2d(32,-64); // Bottom Right
(but I did have)
glVertex2d(1,1); // Top Right
glVertex2d(-1,1); // Top Left
glVertex2d(-1,-1); // Bottom Left
glVertex2d(1,-1); // Bottom Right

which in perspective mode have the textures looking OK, no need to do anything special to fix them.

Now I am getting overlap for some reason, I use:
...
for(y=0;y<7;y++)
for(x=0;x<20;x++)
{
Xpos=((float)x*32.0);
Ypos= ((float)(y*64.0));
glTranslatef ( Xpos,Ypos,0);
glScalef(-1,1,1);
...(gltexcoord & vertext stuff here)
to draw, and since I have x loop= 640/32=20 cols, and y loop 480/64=~7 rows, should it not draw correct now?


Hmm, it wasn''t overlap, it was a problem (still is?) with the blend function I use. When I do
glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA ); I get a weird horizontal stripe alternating in different shades...

When I use
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Then all is OK (so far, I don''t get that pattern above).

I am still plugging away though

Thanks again for the info/tips!

This topic is closed to new replies.

Advertisement