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