From: Jay Link (jlink@interlink-bbs.com)
Date: Tue 30 Nov 1999 - 15:08:59 IST
And make sure you include <math.h>. You shouldn't have to define PI, but that might be a problem on some systems. Here's an example of a complete semi-circle program: #include <stdlib.h> #include <math.h> #include <vga.h> #include <vgagl.h> void semi_circle(int xc, int yc, int radius, int color); int main(void) { vga_init(); vga_setmode(G640x480x256); gl_setcontextvga(G640x480x256); semi_circle(100, 100, 50, 3); vga_getch(); vga_setmode(TEXT); return 0; } void semi_circle(int xc, int yc, int radius, int color) { double theta, costheta, sintheta; int i, y; for (i = 0; i < 180; i++) { theta = (PI / 360) * i; costheta = cos(theta); sintheta = sin(theta); y = yc + radius * costheta; gl_hline(xc - radius * sintheta, y, xc + radius * sintheta, color); } }
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST