Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: C++ OPENGL help wanted to port glbegin and end

  1. #1
    Newbie Newbie
    Join Date
    Oct 2013
    Posts
    3

    C++ OPENGL help wanted to port glbegin and end

    Hi;

    I have this code in openGL, which works, but I would like to eliminate the glbegin and glend to meet OpenGL ES standards.
    Can anyone out there help?

    Code :
    #include "painter.hpp"
    #include "GL/glut.h"
     
     
    void Painter::bar(int x1, int y1, int x2, int y2)
    {
      glColor3f(0, 1, 0);
      glBegin(GL_QUADS);
      glVertex2f(x1, y1);
      glVertex2f(x2, y1);
      glVertex2f(x2, y2);
      glVertex2f(x1, y2);
      glEnd();
    }
     
    void Painter::circle(int x, int y, int radius)
    {
      glColor3f(1, 0, 0);
      glBegin(GL_POLYGON);
      glVertex2f(x + radius, y);
      glVertex2f(x, y + radius);
      glVertex2f(x - radius, y); 
      glVertex2f(x, y - radius);
      glEnd();
    }

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    You need to read about vertex buffer objects. I would search for "OpenGL ES tutorials" you will find things like http://www.raywenderlich.com/3664/op...phone-tutorial

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,180
    For GL ES you don't actually need buffer objects; you can use vertex arrays from client memory too. In this case, since it looks as though the vertex data is going to be fully dynamic, I'd suggest client memory rather than buffer objects as otherwise you get into the complexity of how to dynamically update them without synchronization/contention.

  4. #4
    Newbie Newbie
    Join Date
    Oct 2013
    Posts
    3
    Thanks very much for everyone's advice. I'll look into a few gl es tutorials.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •