[fpc-pascal] OpenGL ES bitmap drawing
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Sat Nov 26 21:32:45 CET 2011
Hello,
Ok, so now I read a couple of tutorials more and I am trying to first
draw a simple rectangle, but still nothing shows. I have put
glGetError calls before every single call and yet nothing is returned
as wrong by OpenGL ES.
Here is my routine:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/customdrawn/customdrawnobject_android.inc?revision=33807&root=lazarus
procedure engine_draw_frame(engine: Pengine);
const
vertices: array[0..7] of GLfloat =
(0, 300,
300, 300,
0, 0,
300, 0);
var
lError: GLenum;
begin
if engine^.display = nil then exit;
LOGW('[engine_draw_frame]'); // <<<--- I see this tons of times
// Set a projection which matches the screen size
glMatrixMode(GL_PROJECTION);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 1
Error='+IntToStr(Integer(lError))));
glLoadIdentity();
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 2
Error='+IntToStr(Integer(lError))));
glOrthof(0, engine^.width, engine^.height, 0, 0, 1);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 3
Error='+IntToStr(Integer(lError))));
glMatrixMode(GL_MODELVIEW);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 4
Error='+IntToStr(Integer(lError))));
glLoadIdentity();
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 5
Error='+IntToStr(Integer(lError))));
// Displacement trick for exact pixelization
glTranslatef(0.357, 0.357, 0);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 6
Error='+IntToStr(Integer(lError))));
// Turn on 2D mode
glDisable(GL_DEPTH_TEST);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 7
Error='+IntToStr(Integer(lError))));
glClear(GL_COLOR_BUFFER_BIT);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 8
Error='+IntToStr(Integer(lError))));
// Draw a square
glVertexPointer(2, GL_FLOAT, 0, @vertices[0]);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 9
Error='+IntToStr(Integer(lError))));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 10
Error='+IntToStr(Integer(lError))));
eglSwapBuffers(engine^.display, engine^.surface);
lError := glGetError();
if lError <> GL_NO_ERROR then LOGW(PChar('[engine_draw_frame] 11
Error='+IntToStr(Integer(lError))));
end;
--
Felipe Monteiro de Carvalho
More information about the fpc-pascal
mailing list