OpenGL - drawing directly to buffer?

Started by
5 comments, last by lucem 18 years, 1 month ago
Hi, I m trying to build a base framework for a 2d-scrolling game i plan to make, I would like to have a background image in that will not be built of tiles , a plain image. Now loading this into opengl as many small textures and drawing them seems silly to me as it is only 1 image after all (the image should be pretty big.. at least 4000x4000 if not more). Is it possible to directly access the buffers of opengl and just copy the bitmap directly into memory? (thus saving the whole texture generation + object management for each of the 'squares') Thanks in advance
Advertisement
For just a background image that is not projected, you can use glDrawPixels().

If your large picture is projected (i.e. on a surface within your 3D world) you have to make textures for it, and the maximum texture size is 256×256.
Quote:Original post by Bob Janova
the maximum texture size is 256×256.


That's not true. To determine the maximum texture size, you need to use glGet*() with GL_MAX_TEXTURE_SIZE. The value it gives you is the maximum square texture size (if it returns 1024, then you can use a 1024x1024 texture). If you're not using a square texture, then you have to get the dimensions another way. See this for more info.

[EDIT]
Incase you can't find the part I'm talking about, it's the second paragraph under the 'Description' heading.
glDrawPixels will probably be *slow*. Better just draw a screen-filling textured quad. The maximum texture size is nowhere near as little as 256x256 on even somewhat modern-resembling cards; for example, my GeForce 6600GT supports texture sizes up to 4096x4096. And if the limit is too low, you can always split the huge image into smaller parts.
Okay, so perhaps my knowledge is a little outdated :P. On my card, a couple of years ago when I was testing this crap, textures larger than 256×256 wouldn't load.
I was under the impression that the max size is around 512x512 or so, thanks everyone :o
Basically, with enough VRAM, textures can be any size, given their dimensions are powers of 2.

What you can do:
Have 2 Render passes, first one in orthogonal view, drawing one screen-filling quad bound to the background image's texture.
Then, in the second pass, render your other stuff in projected view.
Using your brain doesn't hurt at all.

This topic is closed to new replies.

Advertisement