You are not logged in.

#1 2009-07-30 21:04:19

tribasic
Member

[RESOLVED] Pixel Drawing Question

Hi,

I was wondering what the fastest way is to draw the entire screen because I'm trying to see if I can make my 'plasma' program faster.

Right now I'm drawing my screen with a nested loop like this:

Code:

for(y=0;y<480;y++){
  for(x=0;x<640;x++){
     Draw Pixels (x,y,colours)
  }
}

I came up with one idea which works pretty cool. I increase the step of each loop, and draw a rectangle instead of a pixel. It works great but it makes the screen kind of 'blocky'. I wrote something like this:

Code:

for(y=0;y<480;y+=box_size){
  for(x=0;x<640;x+=box_size){
     GRRLIB_Rectangle(x*box_size,box_size,y*box_size,box_size,colours,1);
  }
}

I'm still learning 'C', but just wondered if there was a better, faster way to draw to the screen.

Thanks!

Tribasic

Offline

 

#2 2009-07-30 21:31:36

Crayon
Bad Mother Fucker

Re: [RESOLVED] Pixel Drawing Question

tribasic wrote:

I was wondering what the fastest way is to draw the entire screen because I'm trying to see if I can make my 'plasma' program faster.

Use this:

Code:

GRRLIB_FillScreen(colours);

Offline

 

#3 2009-07-30 23:18:04

tribasic
Member

Re: [RESOLVED] Pixel Drawing Question

Thanks Crayon!! I'll give that a try!

Offline

 

#4 2009-07-30 23:25:49

Crayon
Bad Mother Fucker

Re: [RESOLVED] Pixel Drawing Question

Just in case you need some nice colors for your screen:

Code:

// RGBA Colors
#define GRRLIB_BLACK   0x000000FF
#define GRRLIB_MAROON  0x800000FF
#define GRRLIB_GREEN   0x008000FF
#define GRRLIB_OLIVE   0x808000FF
#define GRRLIB_NAVY    0x000080FF
#define GRRLIB_PURPLE  0x800080FF
#define GRRLIB_TEAL    0x008080FF
#define GRRLIB_GRAY    0x808080FF
#define GRRLIB_SILVER  0xC0C0C0FF
#define GRRLIB_RED     0xFF0000FF
#define GRRLIB_LIME    0x00FF00FF
#define GRRLIB_YELLOW  0xFFFF00FF
#define GRRLIB_BLUE    0x0000FFFF
#define GRRLIB_FUCHSIA 0xFF00FFFF
#define GRRLIB_AQUA    0x00FFFFFF
#define GRRLIB_WHITE   0xFFFFFFFF

Offline

 

#5 2009-07-31 14:43:39

BlueChip
Moderator

Re: [RESOLVED] Pixel Drawing Question

You can use any HTML colour palette - google with return LOTS of hits
just add FF to the end of the colour if you want it to be solid/completely-opaque, or a lower (hex) number if you want it to be see-through/translucent

BC


I can be found on efnet, freenode, msn, gtalk, aim, ychat & icq ...PM me for details

Offline

 

Board footer

Powered by FluxBB