libMini OpenGL to OpenGL ES

This topic contains 1 reply, has 2 voices, and was last updated by  Joe Davis 6 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30478

    peter2211
    Member

    Hi everybody,

    I’m trying to port libMini terrain rendering engine to an embedded system with OpenGL ES 1.1. I’m having some trouble converting the code below to work with ES. I would really appreciate it if someone could help me with this…

    extern int fancnt,vtxcnt;

    void beginfans()

       {

       fancnt=vtxcnt=0;

       }

    inline void beginfan()

       {

       if (fancnt++>0) glEnd();

       glBegin(GL_TRIANGLE_FAN);

       }

    inline void normal(const float dx,const float dy,const float dz)

       {

       glNormal3f(dx,dy,dz);

       }

    inline void texcoord(const float s,const float t,const float r)

       {

       glTexCoord(s,t,r);

       }

    inline void fanvertex(const float x,const float y,const float z)

       {

       glVertex3f(x,y,z);

       vtxcnt++;

       }

    void endfans()

       {

       if (fancnt>0) glEnd();

       }

    inline void renderline(const float x1,const float y1,const float z1,const float x2,const float y2,const float z2)

       {

       glBegin(GL_LINES);

       glVertex3f(x1,y1,z1);

       glVertex3f(x2,y2,z2);

       glEnd();

       }

    inline void renderpoint(const float x,const float y,const float z)

       {

       glBegin(GL_POINTS);

       glVertex3f(x,y,z);

       glEnd();

       }

    }

    Thank you in advance,

    Peter

    #34796

    Joe Davis
    Member

    Hi Peter,

    You can find the OpenGL ES 1.1 manual page here

    Some of the calls you are trying to use are not available in the OpenGL ES 1.x API. Instead of using glBegin(), glVertex<>() and glEnd(), you should use glDrawArrays() or glDrawElements() with GL_POINTS/GL_LINES/GL_TRIANGLE_FAN etc as arguments.

    If you look through our ES 1.x training courses, we have fully commented source code for example applications from the basics of using the API to more complex use cases. You can use this to familiarise yourself with the differences between the fixed-function embedded API and desktop OpenGL.

    Let us know how you get on with the source code, and please post again if you have further questions 🙂

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.