#include <GLES/gl.h>
#include <GLES/egl.h>
#endif
+#ifdef USE_GLUT_FOR_OPENGLES
+#define APIENTRY
+#define GLU_TESS_BEGIN 100100
+#define GLU_TESS_VERTEX 100101
+#define GLU_TESS_END 100102
+#define GLU_TESS_COMBINE 100105
+typedef struct GLUtesselator GLUtesselator;
+typedef double GLdouble;
+#endif
#else
#define glOrthof glOrtho
#undef USE_FLOAT
}
-#else
+#endif
+
+static void
+get_overlay_pos(struct graphics_priv *gr, struct point *point_out)
+{
+ if (gr->parent == NULL) {
+ point_out->x = 0;
+ point_out->y = 0;
+ return;
+ }
+ point_out->x = gr->p.x;
+ if (point_out->x < 0) {
+ point_out->x += gr->parent->width;
+ }
+
+ point_out->y = gr->p.y;
+ if (point_out->y < 0) {
+ point_out->y += gr->parent->height;
+ }
+}
+
+static void
+draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc,
+ struct point *p, int count)
+{
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
+#if !defined(USE_OPENGLES) || defined(USE_OPENGLES2)
+ glLineWidth(gc->linewidth);
+#endif
+ set_color(gr, gc);
+ graphics_priv_root->dirty = 1;
+
+#ifndef USE_OPENGLES
+ if (!gr->parent && 0 < gc->dash_count) {
+ glLineStipple(1, gc->dash_mask);
+ glEnable(GL_LINE_STIPPLE);
+ }
+#endif
+ draw_array(gr, p, count, GL_LINE_STRIP);
+#ifndef USE_OPENGLES
+ if (!gr->parent && 0 < gc->dash_count) {
+ glDisable(GL_LINE_STIPPLE);
+ }
+#endif
+}
+
+#if !defined(USE_OPENGLES) || defined(USE_GLUT_FOR_OPENGLES)
+static int tess_count;
+static struct point tess_array[512];
+static GLenum tess_type;
+
const char *
getPrimitiveType(GLenum type)
{
void APIENTRY
tessBeginCB(GLenum which)
{
- glBegin(which);
-
dbg(1, "glBegin( %s );\n", getPrimitiveType(which));
+ tess_type=which;
+ tess_count=0;
}
void APIENTRY
tessEndCB()
{
- glEnd();
-
dbg(1, "glEnd();\n");
+ draw_array(graphics_priv_root, tess_array, tess_count, tess_type);
}
{
// cast back to double type
const GLdouble *ptr = (const GLdouble *) data;
-
- glVertex3dv(ptr);
-
dbg(1, " glVertex3d();\n");
-}
-#endif
-
-static void
-get_overlay_pos(struct graphics_priv *gr, struct point *point_out)
-{
- if (gr->parent == NULL) {
- point_out->x = 0;
- point_out->y = 0;
- return;
- }
- point_out->x = gr->p.x;
- if (point_out->x < 0) {
- point_out->x += gr->parent->width;
- }
-
- point_out->y = gr->p.y;
- if (point_out->y < 0) {
- point_out->y += gr->parent->height;
- }
-}
-
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int count)
-{
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
-#if !defined(USE_OPENGLES) || defined(USE_OPENGLES2)
- glLineWidth(gc->linewidth);
-#endif
- set_color(gr, gc);
- graphics_priv_root->dirty = 1;
-#ifndef USE_OPENGLES
- if (!gr->parent && 0 < gc->dash_count) {
- glLineStipple(1, gc->dash_mask);
- glEnable(GL_LINE_STIPPLE);
- }
-#endif
- draw_array(gr, p, count, GL_LINE_STRIP);
-#ifndef USE_OPENGLES
- if (!gr->parent && 0 < gc->dash_count) {
- glDisable(GL_LINE_STIPPLE);
- }
-#endif
+ tess_array[tess_count].x=ptr[0];
+ tess_array[tess_count].y=ptr[1];
+ if (tess_count < 511)
+ tess_count++;
+ else
+ dbg(0,"overflow\n");
}
-#ifdef USE_OPENGLES
-#else
void APIENTRY
tessCombineCB(GLdouble c[3], void *d[4], GLfloat w[4], void **out)
{
nv[2] = c[2];
*out = nv;
}
+
#endif
&& !gr->overlay_enabled)) {
return;
}
-#ifdef USE_OPENGLES
set_color(gr, gc);
+ graphics_priv_root->dirty = 1;
+#if defined(USE_OPENGLES) && !defined(USE_GLUT_FOR_OPENGLES)
draw_array(gr, p, count, GL_LINE_STRIP);
#else
- graphics_priv_root->dirty = 1;
GLUtesselator *tess = gluNewTess(); // create a tessellator
if (!tess)
// and UV coords which are needed for actual drawing.
// Here, we are looking at only vertex coods, so the 2nd and 3rd params are
// pointing same address.
- glColor4f(gc->fr, gc->fg, gc->fb, gc->fa);
gluTessBeginPolygon(tess, 0); // with NULL data
gluTessBeginContour(tess);
for (i = 0; i < count; i++) {