<br><br><div class="gmail_quote">2009/3/27 Arvind K <span dir="ltr">&lt;<a href="mailto:arvindkhadri@gmail.com">arvindkhadri@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br clear="all"><br>
&gt; i got a program from this link<br>
&gt;<br>
&gt; <a href="http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html" target="_blank">http://people.sc.fsu.edu/~burkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html</a>&lt;<a href="http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html" target="_blank">http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html</a>&gt;<br>


&gt;<br>
&gt;<br>
&gt; <a href="http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html" target="_blank">http://people.sc.fsu.edu/~burkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html</a>&lt;<a href="http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html" target="_blank">http://people.sc.fsu.edu/%7Eburkardt/cpp_src/rotating_cube_display_open_gl/rotating_cube_display_open_gl.html</a>&gt;<br>


&gt;<br>
<br>
the program i have pasted below -- might be missing some lines as i removed<br>
few lines ( comments ) while pasting here , the actual program is at the<br>
bottom of the page ( link provided above )<br>
<br>
&gt;<br>
&gt; # include &lt;cstdlib&gt;<br>
&gt; # include &lt;cmath&gt;<br>
&gt; # include &lt;iostream&gt;<br>
&gt; # include &lt;iomanip&gt;<br>
&gt; # include &lt;fstream&gt;<br>
&gt;<br>
&gt; # include &lt;GL/glut.h&gt;<br>
&gt;<br>
&gt; using namespace std;<br>
&gt;<br>
&gt; GLfloat vertices[][3] = {<br>
&gt;   { -1.0, -1.0, -1.0 },<br>
&gt;   {  1.0, -1.0, -1.0 },<br>
&gt;   {  1.0,  1.0, -1.0 },<br>
&gt;   { -1.0,  1.0, -1.0 },<br>
&gt;   { -1.0, -1.0,  1.0 },<br>
&gt;   {  1.0, -1.0,  1.0 },<br>
&gt;   {  1.0,  1.0,  1.0 },<br>
&gt;   { -1.0,  1.0,  1.0 } };<br>
&gt;<br>
&gt; GLfloat normals[][3] = {<br>
&gt;   { -1.0, -1.0, -1.0 },<br>
&gt;   {  1.0, -1.0, -1.0 },<br>
&gt;   {  1.0,  1.0, -1.0 },<br>
&gt;   { -1.0,  1.0, -1.0 },<br>
&gt;   { -1.0, -1.0,  1.0 },<br>
&gt;   {  1.0, -1.0,  1.0 },<br>
&gt;   {  1.0,  1.0,  1.0 },<br>
&gt;   { -1.0,  1.0,  1.0 } };<br>
&gt;<br>
&gt; GLfloat colors[][3] = {<br>
&gt;   { 0.0, 0.0, 0.0 },<br>
&gt;   { 1.0, 0.0, 0.0 },<br>
&gt;   { 1.0, 1.0, 0.0 },<br>
&gt;   { 0.0, 1.0, 0.0 },<br>
&gt;   { 0.0, 0.0, 1.0 },<br>
&gt;   { 1.0, 0.0, 1.0 },<br>
&gt;   { 1.0, 1.0, 1.0 },<br>
&gt;   { 0.0, 1.0, 1.0 } };<br>
&gt;<br>
&gt; static GLint axis = 2;<br>
&gt; static GLfloat theta[3] = { 0.0, 0.0, 0.0 };<br>
&gt;<br>
&gt; int main ( int argc, char *argv[] );<br>
&gt; void colorcube ( );<br>
&gt; void display ( );<br>
&gt; void mouse ( int btn, int state, int x, int y );<br>
&gt; void myReshape ( int w, int h );<br>
&gt; void polygon ( int a, int b, int c, int d );<br>
&gt; void spinCube ( );<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; int main ( int argc, char *argv[] )<br>
&gt; {<br>
&gt;   glutInit ( &amp;argc, argv );<br>
&gt;   glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );<br>
&gt;   glutInitWindowSize ( 500, 500 );<br>
&gt;   glutInitWindowPosition ( 0, 0 );<br>
&gt;   glutCreateWindow ( &quot;Rotating cube&quot; );<br>
&gt;   glutReshapeFunc ( myReshape );<br>
&gt;   glutDisplayFunc ( display );<br>
&gt;   glutIdleFunc ( spinCube );<br>
&gt;   glutMouseFunc ( mouse );<br>
&gt;   glEnable ( GL_DEPTH_TEST );<br>
&gt;   glutMainLoop ( );<br>
&gt;<br>
&gt;   return 0;<br>
&gt; }<br>
&gt; void colorcube ( )<br>
&gt;<br>
&gt; {<br>
&gt;   polygon ( 0, 3, 2, 1 );<br>
&gt;   polygon ( 2, 3, 7, 6 );<br>
&gt;   polygon ( 0, 4, 7, 3 );<br>
&gt;   polygon ( 1, 2, 6, 5 );<br>
&gt;   polygon ( 4, 5, 6, 7 );<br>
&gt;   polygon ( 0, 1, 5, 4 );<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt; void display ( )<br>
&gt;<br>
&gt;   glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );<br>
&gt;<br>
&gt;   glLoadIdentity ( );<br>
&gt;<br>
&gt;   glRotatef ( theta[0], 1.0, 0.0, 0.0 );<br>
&gt;   glRotatef ( theta[1], 0.0, 1.0, 0.0 );<br>
&gt;   glRotatef ( theta[2], 0.0, 0.0, 1.0 );<br>
&gt;<br>
&gt;   colorcube ( );<br>
&gt;   glFlush ( );<br>
&gt;   glutSwapBuffers ( );<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; void mouse ( int btn, int state, int x, int y )<br>
&gt; {<br>
&gt;   if ( btn == GLUT_LEFT_BUTTON &amp;&amp; state == GLUT_DOWN )<br>
&gt;   {<br>
&gt;     axis = axis + 1;<br>
&gt;   }<br>
&gt;   if ( btn == GLUT_MIDDLE_BUTTON &amp;&amp; state == GLUT_DOWN )<br>
&gt;   {<br>
&gt;     axis = axis + 1;<br>
&gt;   }<br>
&gt;   if ( btn == GLUT_RIGHT_BUTTON &amp;&amp; state == GLUT_DOWN )<br>
&gt;   {<br>
&gt;     axis = axis + 1;<br>
&gt;   }<br>
&gt;   axis = axis % 3;<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt; void myReshape ( int w, int h )<br>
&gt; {<br>
&gt;   glViewport ( 0, 0, w, h );<br>
&gt;   glMatrixMode ( GL_PROJECTION );<br>
&gt;   glLoadIdentity ( );<br>
&gt;<br>
&gt;   if ( w &lt;= h )<br>
&gt;   {<br>
&gt;     glOrtho (<br>
&gt;       -2.0, 2.0,<br>
&gt;       -2.0 * ( GLfloat ) h / ( GLfloat ) w, 2.0 * ( GLfloat ) h / ( GLfloat<br>
&gt; ) w,<br>
&gt;       -10.0, 10.0 );<br>
&gt;   }<br>
&gt;   else<br>
&gt;   {<br>
&gt;     glOrtho (<br>
&gt;       -2.0 * ( GLfloat ) h / ( GLfloat ) w, 2.0 * ( GLfloat ) h / ( GLfloat<br>
&gt; ) w,<br>
&gt;       -2.0, 2.0,<br>
&gt;       -10.0, 10.0 );<br>
&gt;   }<br>
&gt;<br>
&gt;   glMatrixMode ( GL_MODELVIEW );<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; void polygon ( int a, int b, int c, int d )<br>
&gt;<br>
&gt; {<br>
&gt;   glBegin ( GL_POLYGON );<br>
&gt;<br>
&gt;   glColor3fv ( colors[a] );<br>
&gt;   glNormal3fv ( normals[a] );<br>
&gt;   glVertex3fv ( vertices[a] );<br>
&gt;<br>
&gt;   glColor3fv ( colors[b] );<br>
&gt;   glNormal3fv ( normals[b] );<br>
&gt;   glVertex3fv ( vertices[b] );<br>
&gt;<br>
&gt;   glColor3fv ( colors[c] );<br>
&gt;   glNormal3fv ( normals[c] );<br>
&gt;   glVertex3fv ( vertices[c] );<br>
&gt;<br>
&gt;   glColor3fv ( colors[d] );<br>
&gt;   glNormal3fv ( normals[d] );<br>
&gt;   glVertex3fv ( vertices[d] );<br>
&gt;<br>
&gt;   glEnd ( );<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; void spinCube ( )<br>
&gt;<br>
&gt; {<br>
&gt;   theta[axis] = theta[axis] + 0.020;<br>
&gt;   if ( 360.0 &lt; theta[axis] )<br>
&gt;   {<br>
&gt;     theta[axis] = theta[axis] - 360.0;<br>
&gt;   }<br>
&gt;   glutPostRedisplay ( );<br>
&gt;<br>
&gt;   return;<br>
&gt; }<br>
&gt;<br>
&gt; ------------------------------<div>-<br>
&gt;<br>
&gt; I compiled using command<br>
&gt; rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ g++<br>
&gt; rotating_cube_display_open_gl.C -lm -lGL -lGLU -lglut<br>
&gt;<br>
&gt; then i tried  this<br>
&gt;<br>
&gt; ./a.out<br>
&gt; X Error of failed request:  BadRequest (invalid request code or no such<br>
&gt; operation)<br>
&gt;   Major opcode of failed request:  143 (GLX)<br>
&gt;   Minor opcode of failed request:  19 (X_GLXQueryServerString)<br>
&gt;   Serial number of failed request:  12<br>
&gt;   Current serial number in output stream:  12<br>
&gt; rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$<br>
&gt;<br>
&gt; i want solution for any of the following problems<br>
&gt;<br>
&gt;<br>
&gt; ------------------ this is for one of the labs for BE ( computer science<br>
&gt; students -- VI semester )<br>
&gt;  Implement the following programs in C / C++<br>
&gt;<br>
&gt;<br>
&gt;    1. Program to recursively subdivide a tetrahedron to from 3D Sierpinski<br>
&gt;    gasket. The number of recursive steps is to be specified by the user.<br>
&gt;    2. Program to implement Liang-Barsky line clipping algorithm.<br>
&gt;<br>
&gt; 3.     Program to draw a color cube and spin it using OpenGL transformation<br>
&gt; matrices.<br>
&gt;<br>
&gt; 4.   Program to create a house like figure and rotate it about a given<br>
&gt; fixed point using   OpenGL functions.<br>
&gt;<br>
&gt; 5.    Program to implement the Cohen-Sutherland line-clipping algorithm.<br>
&gt; Make provision    to specify the input line, window for clipping and view<br>
&gt; port for displaying the clipped image.<br>
&gt;<br>
&gt; 6.    Program to create a cylinder and a parallelepiped by extruding a<br>
&gt; circle and<br>
&gt;<br>
&gt;      quadrilateral respectively. Allow the user to specify the circle and<br>
&gt; the quadrilateral.<br>
&gt;<br>
&gt; 7    Program, using OpenGL functions, to draw a simple shaded scene<br>
&gt; consisting of a tea pot on a table. Define suitably the position and<br>
&gt; properties of the light source along with the properties of the properties<br>
&gt; of the surfaces of the solid object used in the scene.<br>
&gt;<br>
&gt;    1. Program to draw a color cube and allow the user to move the camera<br>
&gt;    suitably to experiment with perspective viewing. Use OpenGL functions.<br>
&gt;    2. Program to fill any given polygon using scan-line area filling<br>
&gt;    algorithm. (Use appropriate data structures.)<br>
&gt;    3.  Program to display a set of values { fij } as a rectangular mesh.<br>
&gt;<br>
&gt;<br>
&gt; Part B<br>
&gt;<br>
&gt; Develop a suitable Graphics package to implement the skills learnt in the<br>
&gt; theory and the exercises indicated in Part A. Use the OpenGL.<br>
&gt;<br>
&gt;<br>
&gt;<br><br>i have ran opengl progs :) i ran it as <br>gcc -lglut &lt;filename.c&gt; -o &lt;output file name &gt;<br><br>more on this blog <br><a href="http://techietipsandtricks.blogspot.com/2009/03/opengl-using-gcc-in-ubuntu.html" target="_blank">http://techietipsandtricks.blogspot.com/2009/03/opengl-using-gcc-in-ubuntu.html</a><br>

</div></blockquote><div><br>i followed your instructions, <br>still i am getting the following error ,<br><br>rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ g++ -lm -lGL -lGLU -lglut rotating_cube_display_open_gl.C -o out3d<br>
rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ ls<br>a.out                              rotating_cube_display_open_gl.csh~<br>out3d                              rotating_cube_display_open_gl.o<br>rotating_cube_display_open_gl.C    rotating_cube.png<br>
rotating_cube_display_open_gl.csh<br>rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ out3d<br>bash: out3d: command not found<br>rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ ./out3d<br>X Error of failed request:  BadRequest (invalid request code or no such operation)<br>
  Major opcode of failed request:  143 (GLX)<br>  Minor opcode of failed request:  19 (X_GLXQueryServerString)<br>  Serial number of failed request:  12<br>  Current serial number in output stream:  12<br>rvcemcabrp@rvcemcabrp-laptop:~/Desktop/opengl$ <br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>-- <br>My Fingerprint:1024D/67CF3C40 :7C43 BB90 1E92 2E8D 647A  5DB0 DC64 0799 67CF 3C40<br>
Arvind: <a href="https://launchpad.net/%7Earvindkhadri" target="_blank">https://launchpad.net/~arvindkhadri</a><br>The box said Windoze or better,so i installed Linux<br>
<a href="http://techietipsandtricks.blogspot.com" target="_blank">http://techietipsandtricks.blogspot.com</a><br><a href="http://xkcd.com/272/" target="_blank">http://xkcd.com/272/</a><br>Registered Linux User #46760<br>
arvind_khadri (on <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a>)<br>

<br>_______________________________________________<br>
FSUG-Bangalore mailing list<br>
<a href="mailto:FSUG-Bangalore@mm.gnu.org.in">FSUG-Bangalore@mm.gnu.org.in</a><br>
<a href="http://mm.gnu.org.in/cgi-bin/mailman/listinfo/fsug-bangalore" target="_blank">http://mm.gnu.org.in/cgi-bin/mailman/listinfo/fsug-bangalore</a><br>
<br></blockquote></div><br>