Archived

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

Alex Finlayson

Bitmaping problems

Recommended Posts

I''m finally getting better at this whole Open GL thing, I have a few problems but this is the most crucial for what I''m toying with right now , Why can''t I use any bitmaps bigger than what is used as the crate in lesson 7. the bmp file is the same compression infact its exactly 3x the original size of the crate , is there a different way then that used in lesson 7? Thanks

Share this post


Link to post
Share on other sites
If this helps the I put the image up on this server
http://www.geocities.com/timessquare/9435/programming/mountain.bmp
download it if you think you could help me Thanks


its a 24 bit RGB file (for those who know that stuff)

Thanks a bunch
Alex Finlayson

Share this post


Link to post
Share on other sites
> Why can't I use any bitmaps bigger than what is used as the
> crate in lesson 7. the bmp file is the same compression infact > its exactly 3x the original size of the crate ,

You CAN use any bitmap, but its' sizes must be a power of 2. Your picture (mountain.bmp) is 640/640, so you'll see only empty polygon . Try to resize it to 512/512 or any other 2^n/2^m combination. I hope it'll help.

> is there a different way then that used in lesson 7? Thanks

Different way of what exactly do you mean? (Lesson 7 is very big )

Alex


Edited by - Alex Bijamov on January 14, 2002 7:13:13 AM

Share this post


Link to post
Share on other sites
quote:
is there a different way then that used in lesson 7?


Alex B: I think he wonder if there exists another way of using bitmaps, like there exists different ways of coloring objects (using glColor without lights, or using lights with color materials, or texturing, ...).

Alex F: Unless you look for drawing bitmaps in front of the screen, somewhat 2D rendering, there's no way you can define textures. You gotta resize the picture. Though, I recommend to resize the image file instead of resizing the picture on-the-fly, unless the image may exceed the gfx capabilities.

Edited by - vincoof on January 14, 2002 7:14:11 AM

Share this post


Link to post
Share on other sites
well no one has posted this yet.

instead of resizing the image, you can (a waste of space though in this case) place the 640x640 image onto a 1024x1024 image.

when you render the image, you use to use the co-ordinates
1,0 1,1
0,0 0,1

instead of this you would use
ratio=640x1024 (=0.625)

0.625,0.000 0.625,0.625
0.000,0.000 0.000,0.625

this will texture it to that part of the image only.

Hope this helps you out.





Beer - the love catalyst
good ol'' homepage

Share this post


Link to post
Share on other sites
Yeah this solution works too. It has the great advantage of not stretching the image.
Good point.

Also, I''d like to add that it only works for non-tiled textures.
If the texture repeats, then we''ll see the texture "empty" part.

Also (2), it can be easier to set texture coordinates using the texture transformation with texture matrix.
  
GLint matrix_mode;
glGetIntegerv(GL_MATRIX_MODE, &matrix_mode);
glMatrixMode(GL_TEXTURE);
glScalef(0.625f, 0.625f, 1.f);
glMatrixMode(matrix_mode);

After that, you can just set, as usual, your texture coordinates from (0,0) to (1,1) with functions like glTexCoord, and the texture transformation will automatically compute ''real'' texture coordinates from (0,0) to (0.625,0.625).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You do not HAVE to have textures that are power of 2. This only applies on a few cards, I am using 64x43 now with no problems.
AFAIK the power of 2 limit is only for X, and that is only on some cards.

Of course, max texture size is now 2048x2048, but anyone that uses that is insane! (or have a 64/128MB card!)
:D

Share this post


Link to post
Share on other sites
Sorry mate, but you''re wrong.
YOU CAN NOT SET A NON POWER-OF-TWO SIZED TEXTURE IN OPENGL, BY ANY MEAN.
you hear me ?

OpenGL specifications clearly says that.

IMO, if your 64x43 texture works, this is because you''re using mipmaps which, using the glu, automatically resizes the image to its better size.

Also, the texture size is not limited to 2048x2048. It depends on your graphics card.
OpenGL specifications (again those specifications...) do not ensure that a texture greater than 64x64 can be used. Eh eh, hopefully most of the graphics cards support more than that

If you don''t want to overload the texture memory, you gotta ask the graphics card (using OpenGL) which texture size can be set while you''re setting it on the card.

Also, you may not use static limits (like 2048x2048) because (i) this limit varies depending on the graphics card, and (ii) you may not have enough memory for storing the texture if too many textures were loaded before.

Share this post


Link to post
Share on other sites
The limits of Size are quite clear to me,
but I wonder which colorDepth the bitmap has to have??

Does the Colordepth have to be the same as the screens one?
bppBitmap = bppScreen (device context)

or does it have to be lower or equal to that of the screen?
bppBitmap <= bppScreen
(this is what I would think)

or can it be any colordepth?
e.g: bppBitmap = 32, bppScreen = 8



waiting for a life after death

Share this post


Link to post
Share on other sites
The color depth doesn''t matter, you give the texture to OpenGL and he''ll know how to draw it.

The only thing you have to be careful about color depth is that you may give OpenGL a format he can decode, eg 8bit per channel (say for instance, 24bit for RGB and 32bit for RGBA).

Share this post


Link to post
Share on other sites