Sign in to follow this  

Creating Bitmaps for radar

This topic is 4309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm quite new to OpenGL, but have been experimenting and creating a clone of a great 3D game from my Amiga 500 days, called Virus. I want to create a radar screen in the upper left corner of the screen. Normally I would take a ready made image and paste it as a texture onto a quad polygon. But my terrain is randomly generated, so how do I create a colored bitmap on the fly, and use it as a texture? Also, since the land that you fly over gets "infected" gradually by flying aliens, I want the radar to reflect land that been infected "it turns from green tones to brown", which means I have to change my bitmap almost every frame. I suppose I'm a little confused how images are actually stored as an array so that I can create one from scratch within the program. Thanks, Greedo

Share this post


Link to post
Share on other sites
After creating the terrain, you can render it in the buffer from a distance that allows it to "show" the entire terrain on the screen and then save it to a texture using glCopyTexImage2D, or render-to-texture or FBO extensions. You can use that texture to display the terrain on the radar. As for infecting areas, I can't answer precisely because I don't know how you're going to handle that exactly(will you divide the terrain in sectors, and flag them as clear/infected?). In any way, I don't think you need to render the terrain again, all you will need is to render a kind of simple "map" that will be solid red in infected areas and white(or whatever) in clear areas, and overlay that map over the original texture with some kind of blending operation(probably multiplicative).

Share this post


Link to post
Share on other sites
Thanks for the help! I was thinking of using the glcopy, but I'm wondering if there is a way of directly editing image files.

For example, when you load a bitmap of unsigned bytes, RGB, is that just an array that looks like:

R0 G0 B0 R1 G1 B1 etc.
210 100 0 200 110 10 etc.

So the first three numbers represent the RGB of the first pixel, the next three are for the next pixel over etc.

I was thinking that could be a way to directly affect, even images that were preloaded, you could edit individual pixels if you knew they're location. That way, you could literally build a bitmap from scratch within the program, and display as a texture or any other kind of image.

Share this post


Link to post
Share on other sites
ok, I think I have an example of what I want to do. This is a code snippet from Lesson05 in the NeHe tutorials found in the articles and tutorials page.
I changed the DrawGLScene() to try to edit and draw a bit map to the screen as a test. However, my screen is black. What I'm expecting is a black screen with a small grey square in the middle of it. What am I doing wrong?

Thanks again,
greedo

int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity();

unsigned char imageData[3][9][9];
for(unsigned int i=0; i<9; i++)
{
for(unsigned int j=0; j<9; j++)
{
for(unsigned int k=0; k<3; k++)
imageData[k][i][j] = 128;
}
}

//glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glRasterPos2i(50, 50);
glDrawPixels(9, 9, GL_RGB, GL_UNSIGNED_BYTE, imageData);

return TRUE;
}

Share this post


Link to post
Share on other sites
You probably need to set the pixel unpack alignment to 1 if you're using RGB data, otherwise it'll jump to the next block and run out of data before it's finished drawing.

Yes, you can just make up bitmaps (and textures) in memory as arrays of bytes. My GL texture loader does exactly that, in fact.

Share this post


Link to post
Share on other sites
I tried the unpack to 1,2,4. None worked :(

Could it be another parameter that's used elsewhere that I need to not set or set explictly?

Is my array set up correctly (imageData[k][i][j] instead of [i][j][k]?)

Actually on the subject of UNPACKING, I don't really understand what that mans. "Beginning OpenGL for Game Programming" that I'm using for tutorial only glosses over it.

thanks again,
greedo

Share this post


Link to post
Share on other sites

This topic is 4309 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this