PDA

View Full Version : Draw Matrix



GLman
05-13-2002, 02:26 AM
How can I get some example of drawing a matrix or table in OpenGL??? Then I want to select a column of that table to draw a ball inside.
For example I select the cell 2x4 of the table, and in that position it's draw a ball or sphere.

How can I do this? Or where can I get some example?


Thanks

Robbo
05-13-2002, 03:05 AM
Hi,

It seems to me that you might be running before you can walk. Drawing a table is easy using GDI (on windows, or similar) and does not require OpenGL, which is primarily a 3D API.

You simply need to draw a grid of lines, spaced by some amount and then check mouse co-ordinates when the button is pressed to find the grid cell (x,y).

If you don't know how to do this, giving OpenGL examples probably won't teach you much.

Heres an example, in psuedo code:

for ( int x = 0; x < TABLE_WIDTH; x += CELL_WIDTH )
{
draw_a_line ( x, 0, x, TABLE_HEIGHT );
}

for ( int y = 0; y < TABLE_HEIGHT; y += CELL_HEIGHT )
{
draw_a_line ( 0, y, TABLE_WIDTH, y );
}

and then........

if MouseClicked ()
{
Cell_x = Mouse_x / CELL_WIDTH;
Cell_y = Mouse_y / CELL_HEIGHT;
}


Something like that anyway.....