Archived

This topic is now archived and is closed to further replies.

Guzba

OpenGL window background..

Recommended Posts

Guzba    122
Well im making a 2D space shooter game and im wondering how i can load a bitmap as the background of the window? would i just use the glClearColor(*sp?) or is there some other way to do it?

Share this post


Link to post
Share on other sites
Yohumbus    152
Assuming you know how to use textures all you need to do it load your background texture and stretch a quad with that texture over the entire window. You could even just use a portion of the texture and then scroll it by translating the coordinates

[edited by - Yohumbus on March 16, 2003 4:29:35 PM]

Share this post


Link to post
Share on other sites
falkone    444
Use a textured quad the size of the viewing display.. turn the depth buffer off, then on again, so that anything is drawn over top.. if you do this background, you don''t have to use glClearColor at all..

To find what size you need, you can use this..

1) pick an arbitrary value.. use that for the Z value when you translate the scene..

2) make a triangle. The one angle should be half the viewing angle.. the adjacent angle will be that arbitrary Z value.. the x value will equal the inverse tangent of (half the viewing angle) * the abitrary Z value... (e.g. atan(viewangle/2.0f) * Zvalue).. this will return the x value.. to get the y, i guess you just transform that value (keeping in mind the 4:3 ratio of the display)... x*(3.0f/4.0f)= y value... i''m not sure about that though, becuase it''s quite possible that ogl uses the same viewing angle for both the x and the y

Share this post


Link to post
Share on other sites