Advertisement

OpenGL window background..

Started by March 16, 2003 03:06 PM
2 comments, last by Guzba 21 years, 8 months ago
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?
"I never finish what i sta.."Computer:ATI Radeon 9700 PROP4 2.66 GHz512 RDRAM
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]
ASCII stupid question, get a stupid ANSI
Advertisement
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
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
alright that makes sense, ill give that a try
"I never finish what i sta.."Computer:ATI Radeon 9700 PROP4 2.66 GHz512 RDRAM

This topic is closed to new replies.

Advertisement