Skip to main content
gamedev.net
🔒 Locked

Background

Started by cavendish Nov 29, 2002 at 2:32 PM 1 replies 350+ views
Original Post
cavendish
cavendish
Hey guys!! I have a question for you ppl.... Well, let''s say I have a texture that represents the background of a 2D game. Also, let''s say that this background remains there for the entire duration of the game. During the game, I just draw some quads over the background. I don''t want to draw all the time the background(because it''s time consuming), so I only draw it once, the first time, and I don''t clear the color and depth buffer bit... So, in order to do that, I need to display a new quad on top of the one I have drawn over the background that fits/looks exactly like the background... So, my problem is a simple one: How can I split the background texture (a texture) in a number of quads (pieces)? For loading the textures I use the NeHe_IPicture code... I know that if I have a pointer(*a) to height*width bytes, I can acces the (x,y) byte with: a+x*width+y if I start with x,y from 0 to height-1 and width-1 So, what is the format of the IPicture data? For my problem there are 2 solutions (or more): 1. I could make lots of textures when I load the file 2. I could display from the background only that part when drawing So, what should I do? And how should I do it ?
--------Whatever
snisarenko
snisarenko
First of all drawing the 1 background every frame is so unconsuming that you won''t see a difference, unless you have a shity graphics card.

But if you realy want to make your game more efficient. Fine

Well the solution is quite simple. You don''t need to brake up the background into polygons. You know when you draw a texture on a poly you can choose which part of the textrue you want to draw. Right ? For every vertex on the poly you choose a vertex on the texture. So if you draw a polygon over your background. Save the coordidnates of the polygon. Then convert those coordinates to texture coordinates. (depends on how u draw your background) And to overdraw that polygon all you have to do is to draw the same polygon, but you use the background as texture and use those texture coordinates that u converted as the coordinates for the texture (OBVIOUSLY !!!!)

So you see......
You are making it too complicated.
Just Draw the background.
cavendish
cavendish
Thanks! I suddenly realised what glTexture*() does... Thanks ...
--------Whatever

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.