Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL in Visual Studios C++ Edition
    primarykey
    data
    text
    <p>Basically, I have included the block of code which Compiles &amp; appears to run for that matter, but the graphics does not display on the menus I have initialized. I know the code should display, because it compiles, runs &amp; displays what it's suppose to on Linux. However, after transferring the code to Visual Studios, &amp; going through a heavy amount of adjustments( glu, glut, &amp; compatability adjustments ) it finally compiled, but now another problem has arised, which is no graphics that clearly displayed on another machine. :(</p> <pre><code>#include "stdafx.h" #define GLUT_DISABLE_ATEXIT_HACK #include"SDL.h" #include"SDL_opengl.h" #include"glut.h" #include &lt; tchar.h &gt; #include &lt; cstdlib &gt; #include &lt; ctime &gt; #include &lt; iostream &gt; #include &lt; fstream &gt; #include &lt; stdlib.h &gt; #include &lt; stdio.h &gt; #include &lt; string &gt; using namespace std; #ifdef GL_VERSION_1_1 #define POINTER 1 #define INTERLEAVED 2 #define DRAWARRAY 1 #define ARRAYELEMENT 2 #define DRAWELEMENTS 3 int setupMethod = POINTER; int derefMethod = DRAWARRAY; static int legs = 0; void setupPointers( void ); void init( void ); void display( void ); void reshape( int, int ); void keyboard( unsigned char, int, int ); int _tmain( int argc, char **argv ) { glutInit( &amp;argc, argv ); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB ); glutInitWindowSize ( 500, 500 ); glutInitWindowPosition ( 100, 100 ); glutCreateWindow ( argv[0] ); init( ); glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutKeyboardFunc( keyboard ); glutMainLoop( ); return 0; } void setupPointers( void ) { static GLint vertices[ ] = { //spiderbody -10, 35, 10, 35, 20, 55, 10, 75, -10, 75, -20, 55, -10,35, -30,25, -30,-25, -10,-35, 10,-35, 30,-25, 30,25, 10,35, //legs //leg1 position1 20,30, 40,42.5,32.5,77.5,47.5,42.5,30,25, //leg2pos1 30,12.5,50,22.5,55,42.5,56,17.5,30,5, //leg3pos1 30,-12.5,50,-22.5,55,-42.5,56,-17.5,30,-5, //leg4pos1 20,-30, 40,-42.5,32.5,-77.5,47.5,-42.5,30,-25, //leg5pos1 -20,30, -40,42.5,-32.5,77.5,-47.5,42.5,-30,25, //leg6pos1 -30,12.5,-50,22.5,-55,42.5,-56,17.5,-30,5, //leg7pos1 -30,-12.5,-50,-22.5,-55,-42.5,-56,-17.5,-30,-5, //leg8pos1 -20,-30, -40,-42.5,-32.5,-77.5,-47.5,-42.5,-30,-25, //leg1pos2 20,30,45,37.5,50,75,50,32.5,30,25, //leg2pos2 30,12.5,51,12.5,47.5,22.5,60,5,30,5, //leg3pos2 30,-12.5,51,-12.5,47.5,-22.5,60,-5,30,-5, //leg4pos2 20,-30,45,-37.5,50,-75,50,-32.5,30,-25, //leg5pos2 -20,30,-45,37.5,-50,75,-50,32.5,-30,25, //leg6pos2 -30,12.5,-51,12.5,-47.5,22.5,-60,5,-30,5, //leg7pos2 -30,-12.5,-51,-12.5,-47.5,-22.5,-60,-5,-30,-5, //leg8pos2 -20,-30,-45,-37.5,-50,-75,-50,-32.5,-30,-25 }; static GLfloat colors[ ] = { 0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 1, 0, 0, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 1, 0, 0, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 1, 0, 0, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 1, 0, 0, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 1, 0, 0, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,0.37, 0.35, 0.62, 0.5, 0.75, 0.25, 0.75, 0.75,0, 0.35, 0.35, 0.35, 0.5, 0.75, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.35, 0.35, 0.5, 0.28, 0.35 }; // COLORS glEnableClientState ( GL_VERTEX_ARRAY ); glEnableClientState ( GL_COLOR_ARRAY ); glVertexPointer ( 2, GL_INT, 0, vertices ); glColorPointer ( 3, GL_FLOAT, 0, colors ); } void init(void) { glColor3f( 1,1,1 ); glutWireSphere( 100,100,100 ); glShadeModel( GL_SMOOTH ); setupPointers ( ); } void display( void ) { glClear (GL_COLOR_BUFFER_BIT); glDrawArrays (GL_POLYGON, 0, 14); if( legs % 5 == 0 || legs &lt; 5 || legs%5==1 ) { glDrawArrays (GL_POLYGON,15,4); glDrawArrays (GL_POLYGON,20,4); glDrawArrays (GL_POLYGON,25,4); glDrawArrays (GL_POLYGON,30,4); glDrawArrays (GL_POLYGON,35,4); glDrawArrays (GL_POLYGON,40,4); glDrawArrays (GL_POLYGON,45,4); glDrawArrays (GL_POLYGON,50,4); } //second position of legs else if( legs % 5 !=0 &amp;&amp; legs%5!=1 ) { glDrawArrays (GL_POLYGON,55,4); glDrawArrays (GL_POLYGON,60,4); glDrawArrays (GL_POLYGON,65,4); glDrawArrays (GL_POLYGON,70,4); glDrawArrays (GL_POLYGON,75,4); glDrawArrays (GL_POLYGON,80,4); glDrawArrays (GL_POLYGON,85,4); glDrawArrays (GL_POLYGON,90,4); } } void reshape ( int w, int h ) { glViewport ( 0, 0, (GLsizei) w, (GLsizei) h ); gluOrtho2D ( -60.0, (GLdouble) w, -60.0, (GLdouble) h ); } void keyboard ( unsigned char key, int x, int y ) { switch ( key ) { case 'd': glTranslatef( 1,1,0 ); glRotatef( -5,0,0,1.0 ); legs++; break; case 'a': glTranslatef( 1,1,0 ); glRotatef( 5,0,0,1.0 );legs++; break; case 'w': glTranslatef( 0,5,0 );legs++; break; case 's': glTranslatef( 0,-5,0 );legs++; break; case 27: exit(0); break; default: break; } glutPostRedisplay( ); } #else #endif </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload