Hi,

On 27 June 2011 09:12, John Tsiombikas <nuclear@member.fsf.org> wrote:
What we're discussing here is about finding a way to implement the same
functionality, on top of OpenGL ES 2, or pure OpenGL 4 context-using
programs. And what I was just saying is that it seems like it can't be
done for the glut primitives.

How about implementation like this one? Which part(s) are offending GLUT specification API 3, if this is looked as a black box?


#if defined(OPENGL_ES2)
# if !defined( GLdouble )
#  if defined( double )
#   define GLdouble    double
#  else
#   define GLdouble    GLfloat
#  endif
# endif
#endif

...

void FGAPIENTRY glutSolidCube( GLdouble dSize )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube" );

#if
...
#elif defined(OPENGL_ES2)
   glutSolidCube_ext( dSize );
#endif
}

// Or would glutSolidCubef() be better ....
void FGAPIENTRY glutSolidCube_ext( GLfloat fSize )
{
    float size = fSize * 0.5f;

    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube_ext" );

   {
     const float  vertices3[ 6*2*3 ] = {...};
     const float  normals3[ 6*2*3 ] = {...};
     GlInt cp, val;

     glGetIntegerv( GL_CURRENT_PROGRAM, &cp );

     val = glGetAttribLocation( cp, glutGetVertexAttributeName( GLUT_ATTRIBUTE_NAME_FOR_VERTEX ) );
     glEnableVertexAttribArray( val );
     glVertexAttribPointer( val, 3, GL_FLOAT, GL_TRUE, 0, verticies3 );

     val = glGetAttribLocation( cp, glutGetVertexAttributeName( GLUT_ATTRIBUTE_NAME_FOR_NORMAL ) );
     if( val != -1 )
     {
       // Shader program needs normals as input
       glEnableVertexAttribArray( val );
       glVertexAttribPointer( val, 3, GL_FLOAT, GL_TRUE, 0, normals3 );
     }

     glDrawArrays( GL_TRIANGLES, 0, 6*2*3 );
  }
}

 
Yes, as I said the most important service provided by GLUT is in my
opinion the window-system abstraction, which is apparently the only
thing you're using.

Actually, the application is using also other non-rendering related services of freeglut.

Lehtonen, Matti
--
Life is complex. It has real and imaginary parts.