PDA

View Full Version : OpenGL good to use with this little 2D hack i want to do?



10-22-2000, 11:13 AM
Hello everybody,

I'm thinking about creating a little 2D game and i'm wondering if i should use OpenGL for it. Want i want to do i basically to have a screen in 640x480 with a background that's has about 1280x480 in size so it should be able to be scrolled horizontally. I was thinking that i should create a polygon and then map this big texture to it and only show half of it at the time... and when scrolling i just move the polygon. I have ran into some problem doing this though, mostly how to calculate different coords.
Are there any way to do it simplier with OpenGL using some 2d functions? Sure i could do all this with the native windows API but it would be better to use OpenGL because then it should be easier to port to other platforms.

Can anyone give me any directions on which way to go and please give me some good references?

thanks in advance.

zed
10-22-2000, 12:36 PM
youre gonna have to use textures that are a power of 2 so 480 is out 512's ok
so create 3 textures of 512x512 provided u aint got a voodoo card then u have to stick to 256x256

mgt
10-23-2000, 10:42 AM
I have tried to doing similar stuff the following way..

Load a texture 1024x1024.
Setup a gluOrtho2d(); in windows width/height.

texturemap the texture on a QUAD and set the U/V coords so i would get a pixel from the
texture to match 1 pixel on screen. (i also use glTranslatef(0.375,0375,0) because it said so in a faq).

When scrolling the picture i just change the u/v coords so it would look like the picture is scrolling... but this is not exactly fast heheh =) Texturemapping 1024x1024 seems to be pretty rough stuff =)

There's probably a much better way to do it... at least there must be a faster way.