View Full Version : Scrolling stars / background in opengl?
06-12-2002, 06:30 PM
Ok so im a beginner at opengl and im starting to make a space game.
My goal is to have a top-down view of objects/spacecraft ect with stars underneath them. The ships would move like real live (I.E. the old asteroids game) and the stars would scroll under the ships.
Any ideas on a good way to accomplish this with opengl?
06-12-2002, 11:59 PM
I am assuming that your camera moves but does not rotate (to maintain the top-down perspective).
One way to accomplish this would be to draw a large quad that will fill the whole view and is far enough back to be behind the ships when they are drawn. You could then texture map the quad with a picture of some stars, and translate the texture across slightly every frame. You probably want something like this :
// Translate the texture
glTranslatef(xTrans, 0.0, 0.0);
xTrans += 0.05;
// Translate to camera pos but further back
glTranslatef(cam.x, cam.y, cam.z + 100);
// Draw the quad
// Vertex3f & TexCoord2f calls to draw the quad
I guess that should work (but as I just wrote it off the top of my head I wouldn't bet on it). Hope it helps.
[This message has been edited by JimmyT (edited 06-13-2002).]
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.