[fpc-pascal] OpenGL ES bitmap drawing

Jeppe Græsdal Johansen jjohan07 at student.aau.dk
Fri Nov 25 19:00:36 CET 2011


Den 25-11-2011 17:53, Felipe Monteiro de Carvalho skrev:
> Hello,
>
> This is a kind of "take a look at my code please" question. Normally I
> avoid that kind of question, but in this case my cluelessness is big
> enough that it would really be excellent if someone could throw some
> light here.
>
> Well, basically it is simple, I have a working Android application
> which draws a green gradient in the screen. Of course that a green
> gradient is useless, I want to draw a bitmap.
>
> There are lots of tutorials on the web, but they are mostly in Java
> and I am battling with the C ones to see if I can figure someone out.
>
> So far I managed to get this:
>
> http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/customdrawn/customdrawnobject_android.inc?view=markup&root=lazarus
>
> The relevant code goes only up to line 300 aprox. and the real drawing
> is in the procedure engine_draw_frame
>
> I draw the image at line 108, it should be a red rectangle on a black
> background. There do is a pixel format missmatch, but I still would
> expect to see something, even if a malformed image, but here I get
> nothing... =(
>
> I would be immensely greatful if someone could take a look and throw
> some hints here at what is necessary to get this working.
>
I don't quite understand what problem you are having, but I did notice 
that you use

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, engine^.width, engine^.height, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, Pointer(engine^.RawImage.Data));

Are you sure width and height are powers of two here?

And shouldn't you be calling glDrawArrays at line 158 instead of line 148?



More information about the fpc-pascal mailing list