Jump to content
  • Advertisement

Archived

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

Efficency

This topic is 5848 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

all rightyo, I''ve a 2d array that is 800x600. Each spot holds a number 0-4 for the color I want at that spot. When outputing this...1 pixel at a time, would it be best to: // by output here, i mean do a glVertex3f just loop through set the color every single time output each point... or set the color loop through while searching for that color output points that have the matching color repeat for every color Thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Both of those methods are going to blow. Hard. It doesn''t sound like you want to be using OpenGL for whatever you''re doing.

-- John

Share this post


Link to post
Share on other sites
Thank you for that encourging advice...but for now I am making a simple 2d tank game, and am more concerned with making the code for the game then the code for the graphics. After I finish this, I will procede to learn how to work with more 3d programs and let OpenGl do the work for me.

Could someone please tell me which of those two methods will be quicker. Thank you.

Share this post


Link to post
Share on other sites
Actually he''s right. I assume you''re doing some sort of Worms/TankWar/Take turns shooting at angle game. I would suggest two things. 1) Switch to DirectX 7 and use DirectDraw (which can be made more efficient for lots of single pixel sets) or 2) Using OpenGL, create a bunch of big (256x256) textures that can cover the screen (tiled across the screen). Modify these textures rather than trying to mess with the screen.

In response to your orignal query, the first method would seem best (though you should test both with a profiler to be sure). The second method is likely to cause alot of cache misses and more importantly the overhead of doing 4 IFs for every pixel would be huge.

Share this post


Link to post
Share on other sites
I just kind of realized something. Like right now, I am doing a deformation that creates a hole in the terrain, and I wrote the code that changes the 2d array. Would it work if I added in the code that changed the pixel colors in with this then just do a SwapBuffers when I want to output something?
(paraphrase, basically OpenGl will store the terrain for me and I just change the pixels I want changed.)

Now that this concept is in my head, it looks like it would be fairly easy to code. I'm going to take a break from coding for a while, hopefully someone will tell me if this thing I'm doing is possible.

If this new method would work, do you think the first method I listed would be best to use when I first draw the terrain at the begining (The lag would be acceptable and considered as load time)

[edited by - lessthanjoe on May 4, 2002 7:23:07 PM]

Share this post


Link to post
Share on other sites
Maybe you could treat the terrain as a large polygon / set of polygons. It''d make drawing a lot faster, and reduce memory usage, but collision detection and terrain deformation would be harder. Overall, I think it would be faster...

Share this post


Link to post
Share on other sites
Rather then just repeating to use tiles, could someone please explain to me how I am supposed to use tiles. Should I make 20 40x30 2d arrays? Then what? How would outputting these to the screen be any different.

Has anyone here made a worms game? How did you impliment the terrain?

Thanks for tolerating the unlearned.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!