opengl - what is wrong in the program below -
i trying compile using command gcc -lgl -lglut ex2_6.c -o ex2_6. error given below.i got code @ ihis link http://www.glprogramming.com/red/chapter02.html.see example 2-6 on link.
hemkar@ubuntu:~$ gcc -lgl -lglut ex2_6.c -o ex2_6 /tmp/ccrgl3y9.o:ex2_6.c:function reshape: error: undefined reference 'gluortho2d' collect2: ld returned 1 exit status
code:
#include <gl/gl.h> #include <gl/glut.h> void display(void) { glubyte fly[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x01, 0xc0, 0x06, 0xc0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, 0x04, 0x30, 0x0c, 0x20, 0x04, 0x18, 0x18, 0x20, 0x04, 0x0c, 0x30, 0x20, 0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xc0, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x66, 0x01, 0x80, 0x66, 0x33, 0x01, 0x80, 0xcc, 0x19, 0x81, 0x81, 0x98, 0x0c, 0xc1, 0x83, 0x30, 0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0, 0x03, 0x31, 0x8c, 0xc0, 0x03, 0x33, 0xcc, 0xc0, 0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30, 0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08, 0x10, 0x63, 0xc6, 0x08, 0x10, 0x30, 0x0c, 0x08, 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; glubyte halftone[] = { 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55}; glclear (gl_color_buffer_bit); glcolor3f (1.0, 1.0, 1.0); /* draw 1 solid, unstippled rectangle, */ /* 2 stippled rectangles */ glrectf (25.0, 25.0, 125.0, 125.0); glenable (gl_polygon_stipple); glpolygonstipple (fly); glrectf (125.0, 25.0, 225.0, 125.0); glpolygonstipple (halftone); glrectf (225.0, 25.0, 325.0, 125.0); gldisable (gl_polygon_stipple); glflush (); } void init (void) { glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (gl_flat); } void reshape (int w, int h) { glviewport (0, 0, (glsizei) w, (glsizei) h); glmatrixmode (gl_projection); glloadidentity (); gluortho2d (0.0, (gldouble) w, 0.0, (gldouble) h); } int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (glut_single | glut_rgb); glutinitwindowsize (350, 150); glutcreatewindow (argv[0]); init (); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); return 0; }
you trying use gluortho2d()
without linking against opengl utility library.
try this:
gcc ex2_6.c -o ex2_6 -lgl -lglut -lglu
or switch glortho()
, sidestep whole issue.
Comments
Post a Comment