GL ES 2.0 headers for Freepascal


carli

Member
Joined
Jul 18, 2010
Messages
445
Hi,


I translated the gles 2.0 headers for freepascal, made some sdk and built some tutorials how to make a simple colored or textured triangle.


Even if you are no fpc-fan, you can test this to get an overview how to program gles 2.0.


If you have no pandora, no problem: These GLES 2.0 demo works on a Desktop OpenGL driver, too.


I also made a cross build for arm, but there are still some problems with SDL (SDL does not know gles, maybe the patched libSDL will help)


The hg-repos is: http://bitbucket.org/carli/gles-headers


The Attachment is the executable of the first tutorial which was made by cross compiling. Does it work on a pandora with patched libSDL? Will the patch become part of the official Pandora OS?
 

Attachments

  • gles_tutorial.tar.gz
    84.7 KB · Views: 264
Last edited by a moderator:
Looks cool, the more GL ES power the better. Plus, Pascal, being the only language I have more than limited experience with, will perhaps be useful to me when I get my Pandora.
 
Hi,


I need your help.


I tried to use EGL and SDL to create a GLES context to make the demos also running on Pandora.


I made a test program to create a GLSL context, but i get the following error:



Code:
Mesa: User error: GL_INVALID_FRAMEBUFFER_OPERATION in glDrawArrays(incomplete framebuffer)



The code is



Code:
#include <EGL/egl.h>

#include <GLES/gl.h>

#include <SDL/SDL.h>

#include <X11/Xlib.h>

#include <SDL/SDL_syswm.h>


EGLDisplay disp;

EGLConfig conf;

EGLContext cont;

EGLSurface surf;


EGLint attribList [] = {

	EGL_BUFFER_SIZE, 24, // color depth

	EGL_DEPTH_SIZE, 15, // Z-Buffer

	EGL_NONE

};


		const GLbyte KVertices []=

{

	0,1,0,

	-1,0,0,

	1,0,0

};


int main(int argc, char** argv) {

	SDL_Init(SDL_INIT_VIDEO);

	SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE | SDL_HWSURFACE);




	SDL_SysWMinfo info;

	SDL_GetWMInfo (&info);


	setenv("EGL_PLATFORM", "x11", 1);


	//Display *x11disp = XOpenDisplay(NULL);

	//disp = eglGetDisplay((EGLNativeDisplayType)x11disp);

	disp = eglGetDisplay((EGLNativeDisplayType)info.info.x11.display);

	//disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);

	if(disp == EGL_NO_DISPLAY) {

		printf("No display initialized\n");

		return 1;

	}


	if(!eglInitialize(disp, 0, 0)) {

		printf("Failed initialization of EGL\n");

		return 2;

	}


	EGLint numc;

	if(!eglChooseConfig(disp, attribList, &conf, 1, &numc)) {

		printf("Failed config\n");

		return 3;

	}


	cont = eglCreateContext(disp, conf, EGL_NO_CONTEXT, 0);

	if(!cont) {

		printf("Failed initialization of GLES context\n");

		return 4;

	}


	eglCreateWindowSurface(disp, conf,(EGLNativeWindowType)(info.info.x11.window) , 0);


	eglMakeCurrent(disp, surf, surf, cont);


	int on=10;

	while(on--) {

		glColor4f(1.0,1.0,1.0,1.0);

		glEnableClientState (GL_VERTEX_ARRAY);

		glVertexPointer (3, GL_BYTE , 0, KVertices);	

		glDrawArrays (GL_TRIANGLES, 0, 3);

		eglSwapBuffers(disp, surf);

	}


	// shutdown

	eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

	eglDestroySurface(disp, surf);

	eglDestroyContext(disp, cont);

	eglTerminate(disp);




	return 0;

}
 
Back
Top