Welcome! Log In Create A New Profile

Advanced

Devkit pro question

Posted by durda_dan 
Devkit pro question
February 26, 2009 12:26PM
I just started devkit pro. I had a bug before that stopped me from compiling the programs.
But now everything is good, And i see that there is
DrawHLine
DrawVLine
DrawBox,
But is tehre anyway to do diagonal lines?
Re: Devkit pro question
February 26, 2009 12:52PM
Where exactly are those functions?
Re: Devkit pro question
February 26, 2009 09:22PM
Yes, I'd also like to know what header files have those functions in them. I took a quick scan through and I couldnt find them anywhere (unless maybe they're buried in the GX headers somewhere?).
Re: Devkit pro question
February 27, 2009 10:29AM
those are draw functions coded by Softdev some years ago, which directly write pixels in the video framebuffer
obviously, depending on the way you put pixels on screen, you get lines


void fntDrawHLine (int x1, int x2, int y, int color)
{
  int i;
  y = 320 * y;
  x1 >>= 1;
  x2 >>= 1;
  for (i = x1; i <= x2; i++) xfb[whichfb][y + i] = color;
}

void fntDrawVLine (int x, int y1, int y2, int color)
{
  int i;
  x >>= 1;
  for (i = y1; i <= y2; i++) xfb[whichfb][x + (640 * i) / 2] = color;
}

void fntDrawBox (int x1, int y1, int x2, int y2, int color)
{
  fntDrawHLine (x1, x2, y1, color);
  fntDrawHLine (x1, x2, y2, color);
  fntDrawVLine (x1, y1, y2, color);
  fntDrawVLine (x2, y1, y2, color);
}

this is to draw vertical and horizontal lines, a box being two of them each
if you want to draw diagonal lines, your ONLY WAY is to code your own similar function
this can be a good coding exercise, you only have to understand how those functions are actually doing to put a pixel on screen, which is quite easy



Edited 1 time(s). Last edit at 02/27/2009 10:32AM by ekeeke.
Sorry, only registered users may post in this forum.

Click here to login