benang at cs.its.ac.id wrote:
- Performance wise, will this make my application faster or slower? FYI,
the intended machine is a VIA EPIA Mini ITX embedded with Linux openSuSE
10.1 as the OS.
On this point I’m really not sure, but I would guess that, so long as you have a good graphics card, and you keep the sprites in video RAM as textures, it’ll probably be faster. Plus, certain types of operations, such as scaling or rotating sprites, will be much faster.
- Do I need to implement shader languages (I think maybe Cg)?
Not unless you want to do some pretty fancy special effects. If your game is based entirely on drawing 2D images on top of each other with alpha channels, then just use OpenGL’s standard blending modes and you’ll be fine.
- What’s the settings for openGL so that the 2D environment looked just
like when I blit it directly to an SDL Surface (eg, the viewport, 1 points
equals to 1 pixel, etc)?
Leave the viewport alone unless you actually want to restrict drawing to limited portion of the screen. The standard state of the viewport is the same as the screen/window that the game is drawn into.
For setting it up to have 1 point per pixel, gluOrtho2D() is your friend. Specifically:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, width, 0, height);
Where “width” and “height” are the screen resolution.
Note that OpenGL’s coordinate system is based in the lower-left corner, not the upper-left corner like you might be used to. I BELIEVE the the call to gluOrtho2D, as I just demonstrated, will flip it vertically so it will map to what you expect. However, no promises on that. If that doesn’t work, you can always use the modelview matrix to scale everything by -1.0 on the y axis.
- AFAIK, to add a texture, the width & height of the image should be a
power of 2. So how do I make a sprite with width and/or height not of
power of 2?
This was true in the old versions of OpenGL, but I know it’s been fixed by OpenGL 2.0. Not sure, offhand, exactly which version made the shift, but if your version is up to date, you should be able to use any texture size. Provided, of course, it’s not larger then your implementation’s maximum texture size. These days, that’s usually either 512 or 1024, so you probably won’t have a problem there.