2D artillery game

Started by
7 comments, last by Marty666 19 years, 7 months ago
Hi all. First, I know the basics of opengl since i've been doing it a while ago. I forgot some things though and have never been coding anything in 2D. Now I'm busy working on a classic 2D artillery game in ortho2d using glut. My question: I need to draw a lot of pixels very fast, since the landscape needs to be able to collapse and changes all the time. I have a few options. - Use a texture on a quad and change the texture every time the landscape is updated (seems slow) - Use glPoint (was it glPoint anyways?!? I mean the one where glPointSize works with) - something a lot better. ?!? Please help. Thanx, Marty
_____ /____ /|| | || MtY | ||_____|/Marty
Advertisement
Just make the landscape a mesh, it will be easy to draw/warp the vertex points.
hehehehe. new technology, old problems. when i created that game in basic :), the whole mountain between tanks was a bitmap. pixels was drawn only when the missile explode (tank move etc). next to all explodes, create texture with any changes, and use it to display it when you change weapons, angle and move (per pixel color). this is a very fast method. it works on amstrad cpc (remember that?), so i think it will works on 2GHz processor too :)
Ok, thanks. I'll use a landscape texture which i'll update when the landscape is hit in any way. The missiles, tanks, explotions, etc. wil be sprites. I'll just do an alpha check on the landscape texture to for collision detection.

Now for another question: How do i manipulate a texture per pixel? Can I keep the aux_rgbimagerec and modify that (i think it's just a bitmap) and then reload the texture from the map? Then: What exactly is the rgb imagemap... Does it have a header, like : with, height, data... Or is it just plain data? Are RGB values just bytes, or floats or something?

Thanks, Marty.
_____ /____ /|| | || MtY | ||_____|/Marty
Yes what you can do is keep the data and modify that and create a texture every "hit."

First of all I think OpenGL has a function like glBitmap(); (look it up in the red book), and it basically renders a bitmap directly from memory, so you have direct acces to modify the bitmap.

Or you can just do render to texture in OpenGL. I don't know which way is faster.
thanks snisarenko, i'll look it up and try both ways.
_____ /____ /|| | || MtY | ||_____|/Marty
I looked it up. glBitmap is really a bitmap, so it's bichromatic. glDrawPixels is what i'm going to use. The problem is i'm getting strange results. The image is on it's side and interlaced (looks like scanlines of some sort). It's probably the way i set up the array, so i'm going to try to mess around with that. It looks like this now:

GLubute landscape[width][height][4]
And I use the GL_RGBA mode, so that isn't it. Got any clues?

Thanx,
Marty
_____ /____ /|| | || MtY | ||_____|/Marty
and it should be:

[height][width][4]

thanks again all!
_____ /____ /|| | || MtY | ||_____|/Marty

This topic is closed to new replies.

Advertisement