PDA

View Full Version : C++ OPENGL help wanted to port glbegin and end



chilunliu
11-01-2013, 03:31 PM
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?


#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();
}

tonyo_au
11-02-2013, 07:18 PM
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/opengl-es-2-0-for-iphone-tutorial

mhagain
11-03-2013, 04:38 PM
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.

chilunliu
11-04-2013, 01:22 AM
Thanks very much for everyone's advice. I'll look into a few gl es tutorials.