A Few Simple Questions

1.) If I wanted to create a background for a side-scrolling game, all I’d have to do is draw it up in paint, load it up as a texture for a 2D Quad, and just have it move when the character moves? Is this true, or do you have to use tiling methods and etc.?

2.) Whenever I resize the program’s window, all my textures get scaled up or down and look dumb. Is there any way to prevent the window from being resized, or to keep the textures the same size, regardless of the window size?

3.) Can someone give me a little bit of general info on how animation can be done using OpenGL? I really have no clue how you’d do it.

4.) When you’re doing collision detection, is it most common to set up variables in glTranslatef() and glVertex3f()? Do you draw another invisible box over the original box? Or do you just declare variables to be at a certain position?

(ex. GLfloat = 1.0f

I really have no idea what I’m doing here.

  1. That’s one way of doing it, though if you have a really big background, you might want several textured quads.

  2. There’s a few things you can do. For preventing the window from being resized, we need to know how you create your window. Win32? glut? Something else? You can also setup your projection matrix in such a way that when the window is resized, the view area just views more/less area rather than stretches the view area over the whole glViewport. (for istance if you are using glOrtho, just use the window coordinates for the w & h)

  3. Animation isn’t that difficult. You basically have some sort of state variable that gets updated each frame, and each frame clear the scene and redraw it based on the animation state.

  4. Collision detection is usually done outside of OpenGL. Just as a basic idea of how to do it would be keep track of the position/orientation of your objects, and then perform math to determine if you have objects touching. There are a number of algorithms you can use. Do google search and it should help some.