800x600 backdrops ... Your idea's

Started by
7 comments, last by Xces 21 years, 10 months ago
Hello, As we all know because we use OpenGL, it is only possible to use extures with a power of 2. What if... i have a quad which fully covers the background of my application (which runs @ 800 by 600) And i want: A 800x600 picture to fully cover the quad without image loss. Should i: a) Resize the 800x600 picture to 512x512, OpnGL will scale the pic by itself to the correct size b) Enlarge the canvas to 1024x1024 and calculate the ammount that this texture will cover this quad. c) Another option... Below are some examples: Any suggestions will be welcome..
Advertisement
c) split the image into sections using multiple textures. no seams will occer if you turn of filtering and ensure that you are not scaling the image.

800x600 =

512x512, 256x512, 32x512,
512x 64, 256x 64, 32x64,
32x512, 32x256, 32x32

this break up, has the final set of textures has a slight over hang in which the lower 8 pixels of the textures go unused. you could just break it up more, but i think thats a bit of overkill. alternativly, you could place mulitple images in your 1024x1024 texture. maybe the background, then some misc textures that are required by some 3d objects that are using that background. in this way you save yourself some texture switches, even if the data may be redundant (ie its stored in multiple backgrounds). wasted space should try to be kept to a minium, however the texture switching with the split image may be slightly slower. test each method speed wise to see which works best (ie in the actual game not some benchmark that only tests the speed of drawing the background otherwise you will not get accurate results).

of course your image does not appear to need the borders and can be shrunk significently (almost seems to fit a 512 texture width wise). black borders can easily be drawn using untextured quads, or even using a gl_clear with a black color.

becareful with the texture coordinates vs on screen coordinates. try drawing them in screen space, and dont let opengl handle the transformations. especially since this require pixel accurate placement of the quads.
Any other idea's / examples?

P.s.

You mean this:
800x600 =
512x512, 256x512, 032x512,
512x064, 256x064, 032x064,
512x032, 256x032, 032x032

This gives (if i am right):
first row x->800, y->512
second rw x->800, y->064
third row x->800, y->032

a) But then, would you render the textures in ortho mode?
b) When would you split up the textures? Load time, or when creating the image?


[edited by - Xces on June 4, 2002 6:47:46 PM]
load time or even just store the data that way (depends on which you would find easier). rendering should definatly be done in ortho mode, since you need to give ogl the exact screen coordinates for things to look correct. there is no need to use projection martices, since its a 2d image not being mapped to anything.
I believe this function would help you:

void glDrawPixels(
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels
);

The call you would probably make is:

  glClear(GL_DEPTH_BUFFER_BIT); // | GL_COLOR_BUFFER_BITglRasterPos2d(0, 0);glDrawPixels(nWidth, nHeight, GL_UNSIGNED_BYTE, GL_RGB, pData);  


This should draw your background behind everything and allow you to draw over it. The data should be in the form of three unsigned bytes per pixel, the first being byte being red, then blue, then green, and in rows, not columns (ie. Draw all the way across before moving down). I have never used this method, so I don''t know if it will work or not, but give it a try!

Oh, and you might need to write a simple utility to convert from a bitmap to simple RGB formatted data like is required.

"Dammit! What the friggin hell is the problem????"
"Wait a second! I never called [insert function here]/used the variable [insert variable here]/remembered to [insert action here]! Hahaha!"
:: fixes mistake ::
:: presses f7 ::
:: no errors ::
:: presses ctrl+f5 ::
"DOH!"
glDrawPixels is INCREDIBLY slow, and I doubt thats what he wants

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Well i need to have this routine because i want to display "party pics" when my application is running. I intend to load each texture @ runtime in a seperate thread.

Furthermore, i want the backdrops to be animated in 3D space. For example: The first backdrop comes in with a rotating cube which then rotates into full-view.
if you want the backdrops on a cube, then you should simply turn off texture filtering, and things should line up correctly (only when drawing your back drop). otherwise you will get seams. it might actually be better in your case to just use option B assuming you are running at 800x600, maybe even consider increasing the image size to 1024x768 so ppl running at 1024x768 will get a nicer image, and you wont feel so bad with the wasted space.

you really dont have many options, and basically have to use option b for the best quality, or option a if you need to conserve vram. you cant easily split the texture up and expect it to tile if you have any filtering on.

there are tricks, but they require playing with the texture coordinates and "doubling" up the edge pixels. this is done by having the edge pixels in one texture actually be the pixels for the neighboring textures. then adjusting the texture coordinates so that you are only using the actual texture, not the extra pixels at the edge. this will ensure proper blending (well at least the seams should not be too visible).

i have not tried the above method, and tend to use the 1024x1024 texture size with 1024x768 backdrops. though i like to run everythig at 1024x768x32, this may not be an option in your case.
Hello person

My application is going to run in disco''s and depending on the beamer which is installed in the disco i run the application at either 800x600 or 1024x768..

This topic is closed to new replies.

Advertisement