Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Need ideas for Software rendering

Software rendering. Currently my methods grind the CPU down to a near-hault, whereas I play duke nukem or marathon in software at 1280x1024 and don't hear a whisper from the CPU fan.
What am I doing wrong?
Currently what I'm doing is storing colour information in a 2D array with dimensions equal to the screen resolution and draw each individual colour as a pixel (Using VB.net's GDI draw).
Are there any speedier methods?
With VB.net would be appreciated.

This is my rendering code (From memory).
Code:
for y as integer = 0 to screeny - 1

 for x as integer = 0 to screenx - 1

  brushcolour = new brushes(buffer(x,y))

  e.graphics.fillrectangle(brushcolour, x, y, 1, 1)

 next

next
buffer() is my colour array.

The slowest part of this is probably the e.graphics.fillrectangle, the cycling through each colour doesn't help this at all though. Absolutely any speedier method of software rendering would be nice.
 
Try using setpixel instead of fillrect (Not sure what the exact function name is under VB.NET. Using fillrect once to fill a 640 x 480 screen is faster than using setpixel 640 x 480 times, however using setpixel 640x4380 times is faster than using fillrect that many times.

Also, there isn't a way to draw a textured rectangle from an array of data? (I've never used GDI)
 
DeM0nFiRe":65g1ookk said:
Try using setpixel instead of fillrect (Not sure what the exact function name is under VB.NET. Using fillrect once to fill a 640 x 480 screen is faster than using setpixel 640 x 480 times, however using setpixel 640x4380 times is faster than using fillrect that many times.

Also, there isn't a way to draw a textured rectangle from an array of data? (I've never used GDI)
There's a way to draw a textured rectangle from a bitmap image, I might be able to make a bitmap image with the set pixel command, not sure if that'll be faster or slower.
That's sparked my desire to experiment now, thanks.

I don't think it has a setpixel command, seeing that I originally wanted that but all people could offer me were the draw commands.
 
DeM0nFiRe":2dj827nd said:
Oh, I guess there isn't a set pixel for graphics. Well, in that case. try this: http://www.vb-helper.com/howto_setdibits.html (There are other methods to try as well, there's a list of 4 total at the bottom of the page)
My test method of simply turning it into a bitmap sped the rendering up to 16.6 frames per second from 9.1.

And that's without optimising and still uses the original color array (Which can be removed entirely)

EDIT: With removal of the original buffer it's 17.5 FPS, this is without optimised calculations.

The side effect is that the image is blurry when stretched.

EDIT2: My second rendering test has a speed of visibly instant now, thank you.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top