void drawRect(int x, int y, int w, int h, unsigned int color) { GLfloat points[12]; points[0] = x; points [1] = y; points[2] = x; points[3] = y + h; points[4] = x + w; points[5] = y; points[6] = x + w; points[7] = y; points[8] = x; points[9] = y + h; points[10] = x + w; points[11] = y + h; GLubyte colors[6*4]; buildGLColorArray(colors, color, 6); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_FLOAT, 0, points); glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableClientState(GL_BLEND); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_COLOR_ARRAY); }
void drawRect(int x, int y, int w, int h, unsigned int color, GLenum blend_sfactor, GLenum blend_dfactor) { #ifdef USE_OPENGL_ES GLshort points[12]; #else GLint points[12]; #endif points[0] = x; points [1] = y; points[2] = x; points[3] = y + h; points[4] = x + w; points[5] = y; points[6] = x + w; points[7] = y; points[8] = x; points[9] = y + h; points[10] = x + w; points[11] = y + h; GLubyte colors[6*4]; buildGLColorArray(colors, color, 6); glEnable(GL_BLEND); glBlendFunc(blend_sfactor, blend_dfactor); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); #ifdef USE_OPENGL_ES glVertexPointer(2, GL_SHORT, 0, points); #else glVertexPointer(2, GL_INT, 0, points); #endif glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors); glDrawArrays(GL_TRIANGLES, 0, 6); glDisable(GL_BLEND); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); }