|
Post by alexfish on Feb 3, 2016 19:18:43 GMT 1
Hi All
The Lib will stay as is for now .
Looks like the main problem was the 'glVertexAttribPointer'
have tested both the byte arrays using minimal calls to the vertex array BYTE & FLOAT + tested the colours as in glColor , both work
the following example ,
1. init a gtk window with callback 2. function to keep the egl canvas within the gtk window :: IE the egl will only draw within the scope of , win position and size
in the code . draw a background same size of the window , can test be re-sizing the window + window max
in the code. draw a rotating square , note the perspective ratio stays constant no matter the size of window , can test the by setting the depth in translate , IE that be the -150 , + test the offsets x & y
The new Test Code
INCLUDE SDC.bac
' *************************************************************
SUB QUIT() PRINT "BYE" SLEEP 500 END END SUB
' *************************************************************
SUB draw_square()
LOCAL viewport[4] TYPE int LOCAL nearp = 1.0f TYPE float LOCAL farp = 500.0f TYPE float LOCAL hht TYPE float LOCAL hwd TYPE float /* square data center at 0.0 */ LOCAL square2[] = { \ -10.0, -10.0, 10.0,-10.0, \ -10.0,-10.0,-10.0, 10.0, \ 10.0, 10.0,10.0, -10.0, \ -10.0,10.0, 10.0,10.0} TYPE static GLfloat
LOCAL t =0 TYPE float
LOCAL esContext TYPE ESContext
esInitContext ( &esContext ); esCreateWindow ( &esContext, 600, 400,ES_WINDOW_RGB ,TRUE ) eglWaitNative(EGL_CORE_NATIVE_ENGINE)
glEnable(GL_BLEND) 'glEnable(GL_CULL_FACE) glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glMatrixMode(GL_PROJECTION)
glLoadIdentity();
glClearColor(1.0f, 1.0f, 1.0f, 0.0f)
glEnableClientState( GL_VERTEX_ARRAY )
/* BeginMode GL_POINTS GL_LINES GL_LINE_LOOP GL_LINE_STRIP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN
*/
glMatrixMode(GL_MODELVIEW)
WHILE (1) DO
DOEVENTS() ALIGN() glClear ( GL_COLOR_BUFFER_BIT ); /* CALCULATE THE FUSTRUM*/ glGetIntegerv(GL_VIEWPORT, viewport) hht = nearp * (float)TAN(45.0 / 2.0 / 180.0 * PI) hwd = hht * (float)viewport[2] / (float)viewport[3] glLoadIdentity();
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp);
glTranslatef(0,0,-1); glColor4ub(255,90,214,255) glVertexPointer(2, GL_FLOAT, 0, square2); glDrawArrays (GL_TRIANGLE_FAN, 0,8)
glLoadIdentity();
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp); glVertexPointer(2, GL_FLOAT, 0, square2);
glTranslatef(0,0,-150); glRotatef(-t,0,0,1);
glColor4ub(0,255,0,255) glDrawArrays (GL_TRIANGLE_FAN, 0,8) eglSwapBuffers(Display, Surface)
INCR t , 4 WEND
END SUB ' ************************************************************* ' Main Program
' *************************************************************
ck =gtk_init_check(0,0) win = gtk_window_new(0) gtk_window_set_title(win,"EGL ES demo >> Click in window to Start") gtk_window_set_keep_above(win,TRUE) gtk_widget_set_size_request(win,600,400) g_signal_connect_data(win,"delete_event",QUIT,0,0,0) ebox = gtk_event_box_new() gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) gtk_event_box_set_visible_window(ebox,FALSE) g_signal_connect_data(ebox, "button_press_event",draw_square) gtk_container_add(win,ebox) gtk_widget_show_all(ebox) gtk_widget_show_all(win)
gtk_main()
' End All That
|
|
|
Post by alexfish on Feb 4, 2016 8:24:36 GMT 1
What " you can not see the cursor with a background colour
Here We go..
How to draw a cursor , in the lib the cursor position is in vars C_X & C_Y , now need to set the frustum to ortho coords see /*DRAW CURSOR*/ in the SUB draw square also using same array as the square , here using line-loop , to draw a cross-hair cursor
BR Alex
INCLUDE SDC.bac
' *************************************************************
SUB QUIT() PRINT "BYE" SLEEP 500 END END SUB
' *************************************************************
SUB draw_square()
LOCAL viewport[4] TYPE int LOCAL nearp = 1.0f TYPE float LOCAL farp = 500.0f TYPE float LOCAL hht TYPE float LOCAL hwd TYPE float /* square data center at 0.0 */ LOCAL square2[] = { \ -10.0, -10.0, 10.0,-10.0, \ -10.0,-10.0,-10.0, 10.0, \ 10.0, 10.0,10.0, -10.0, \ -10.0,10.0, 10.0,10.0} TYPE static GLfloat
LOCAL t =0 TYPE float
LOCAL esContext TYPE ESContext
esInitContext ( &esContext ); esCreateWindow ( &esContext, 600, 400,ES_WINDOW_RGB ,TRUE ) eglWaitNative(EGL_CORE_NATIVE_ENGINE)
glEnable(GL_BLEND) 'glEnable(GL_CULL_FACE) glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glMatrixMode(GL_PROJECTION)
glLoadIdentity();
glClearColor(1.0f, 1.0f, 1.0f, 0.0f)
glEnableClientState( GL_VERTEX_ARRAY )
/* BeginMode GL_POINTS GL_LINES GL_LINE_LOOP GL_LINE_STRIP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN
*/
glMatrixMode(GL_MODELVIEW)
WHILE (1) DO
DOEVENTS() ALIGN() glClear ( GL_COLOR_BUFFER_BIT );
/* CALCULATE THE FUSTRUM*/ glGetIntegerv(GL_VIEWPORT, viewport) hht = nearp * (float)TAN(45.0 / 2.0 / 180.0 * PI) hwd = hht * (float)viewport[2] / (float)viewport[3] glLoadIdentity();
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp);
glTranslatef(0,0,-1); glColor4ub(255,90,214,255) 'glVertexAttribPointer ( 0,2, GL_FLOAT, GL_TRUE,0,square2 ) glVertexPointer(2, GL_FLOAT, 0, square2); glDrawArrays (GL_TRIANGLE_FAN, 0,8)
glLoadIdentity();
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp); 'glVertexAttribPointer ( 0,2, GL_FLOAT, GL_TRUE,0,square2 ) glVertexPointer(2, GL_FLOAT, 0, square2);
glTranslatef(45,0,-150); glRotatef(-t,0,0,1);
glColor4ub(0,255,0,255) glDrawArrays (GL_TRIANGLE_FAN, 0,8)
/* DRAW CURSOR */ glLoadIdentity(); glFrustumf(0,(float) viewport[2], (float) viewport[3],0, 1, 2); glTranslatef((float)C_X,(float)C_Y,-1) glColor4ub(0,0,0,255) glVertexPointer(2, GL_FLOAT, 0, square2); glDrawArrays (GL_LINE_LOOP, 0,8)
eglSwapBuffers(Display, Surface)
INCR t , 4 WEND
END SUB ' ************************************************************* ' Main Program
' ************************************************************* PRINT " INIT " ck =gtk_init_check(0,0) win = gtk_window_new(0) gtk_window_set_title(win,"EGL ES demo >> Click in window to Start") gtk_window_set_keep_above(win,TRUE) gtk_widget_set_size_request(win,600,400) g_signal_connect_data(win,"delete_event",QUIT,0,0,0) ebox = gtk_event_box_new() gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) gtk_event_box_set_visible_window(ebox,FALSE) g_signal_connect_data(ebox, "button_press_event",draw_square) gtk_container_add(win,ebox) gtk_widget_show_all(ebox) gtk_widget_show_all(win)
gtk_main()
' End All That
|
|
|
Post by alexfish on Feb 4, 2016 15:56:04 GMT 1
Hi All
Here have added a button with callback to exit, click on the red button whilst the animation is running
thing of note here , the positioning of button , allways bottom right of the screen , the mouse callback will adjust to this area
also added movement of the sq in the horozontal plane.
thing of note here , the square stays in bounds of the window , center of the square
also added mouse button feature to start and stop by clicking in the window.
the basics::
canvas + 3d the basic square animation basic widget with callback using the mouse postion resizing window + redraws a cursor.
Now all that is needed , ' Imagination ..'
BR Alex
the code
INCLUDE SDC.bac
' *************************************************************
SUB QUIT() PRINT "BYE" SLEEP 500 END END SUB
' ************************************************************* GLOBAL TOG = 0 , ITS = 0 SUB draw_square()
LOCAL viewport[4] TYPE int LOCAL nearp = 1.0f TYPE float LOCAL farp = 500.0f TYPE float LOCAL hht TYPE float LOCAL hwd TYPE float /* square data center at 0.0 */ LOCAL square2[] = { \ -10.0, -10.0, 10.0,-10.0, \ -10.0,-10.0,-10.0, 10.0, \ 10.0, 10.0,10.0, -10.0, \ -10.0,10.0, 10.0,10.0} TYPE static GLfloat
/*button data */ LOCAL button[] = { \ -50.0, -13.0, 50.0,-13.0, \ -50.0,-13,-50.0, 13.0, \ 50.0,13.0,50.0, -13.0, \ -50.0,13.0, 50.0,13.0} TYPE static GLfloat
LOCAL t =0 , epos = 0 , eposi=0 TYPE float ITS = NOT(ITS) IF NOT(TOG) THEN LOCAL esContext TYPE ESContext
esInitContext ( &esContext ); esCreateWindow ( &esContext, 600, 400,ES_WINDOW_RGB ,TRUE ) eglWaitNative(EGL_CORE_NATIVE_ENGINE)
glEnable(GL_BLEND) 'glEnable(GL_CULL_FACE) glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glMatrixMode(GL_PROJECTION)
glLoadIdentity();
glClearColor(1.0f, 1.0f, 1.0f, 0.0f)
glEnableClientState( GL_VERTEX_ARRAY )
/* BeginMode GL_POINTS GL_LINES GL_LINE_LOOP GL_LINE_STRIP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN
*/
glMatrixMode(GL_MODELVIEW) TOG=1 ENDIF
WHILE (1) DO
DOEVENTS() ALIGN() glClear ( GL_COLOR_BUFFER_BIT );
/* CALCULATE THE FUSTRUM*/ glGetIntegerv(GL_VIEWPORT, viewport) hht = nearp * (float)TAN(45.0 / 2.0 / 180.0 * PI) hwd = hht * (float)viewport[2] / (float)viewport[3] glLoadIdentity()
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp)
glTranslatef(0,0,-1) glColor4ub(255,90,214,255) 'glVertexAttribPointer ( 0,2, GL_FLOAT, GL_TRUE,0,square2 ) glVertexPointer(2, GL_FLOAT, 0, square2); glDrawArrays (GL_TRIANGLE_FAN, 0,8)
glLoadIdentity()
glFrustumf(-hwd, hwd, -hht, hht, nearp, farp) 'glVertexAttribPointer ( 0,2, GL_FLOAT, GL_TRUE,0,square2 ) glVertexPointer(2, GL_FLOAT, 0, square2)
glTranslatef(epos,0,-34) glRotatef(-t,0,0,1)
glColor4ub(0,255,0,255) glDrawArrays (GL_TRIANGLE_FAN, 0,8)
/* DRAW BUTTON */ glLoadIdentity(); glColor4ub(255,0,0,255) glFrustumf(0,(float) viewport[2], (float) viewport[3],0, 1, 2) glTranslatef((float)viewport[2]-52,(float)viewport[3]-15,-1) glVertexPointer(2, GL_FLOAT, 0, button) glDrawArrays (GL_TRIANGLE_FAN, 0,8)
/* DRAW CURSOR */ glLoadIdentity(); glFrustumf(0,(float) viewport[2], (float) viewport[3],0, 1, 2) glTranslatef((float)C_X,(float)C_Y,-1) glColor4ub(0,0,0,255) glVertexPointer(2, GL_FLOAT, 0, square2) glDrawArrays (GL_LINE_LOOP, 0,8)
eglSwapBuffers(Display, Surface) IF (ITS) THEN INCR t , 1 INCR eposi , 0.01 epos = SIN(eposi)*hwd*34 END IF /* EXIT if */ IF ((C_X > (float)viewport[2]-104) && (C_Y > (float)viewport[3]-30) && (NOT(ITS))) THEN QUIT() END IF
WEND
END SUB ' ************************************************************* ' Main Program
' *************************************************************
ck =gtk_init_check(0,0) win = gtk_window_new(0) gtk_window_set_title(win,"EGL ES demo >> Click in window to Start") gtk_window_set_keep_above(win,TRUE) gtk_widget_set_size_request(win,600,400) g_signal_connect_data(win,"delete_event",QUIT,0,0,0) ebox = gtk_event_box_new() gtk_widget_set_events(ebox, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK) gtk_event_box_set_visible_window(ebox,FALSE) g_signal_connect_data(ebox, "button_press_event",draw_square) gtk_container_add(win,ebox) gtk_widget_show_all(ebox) gtk_widget_show_all(win)
gtk_main()
' End All That
|
|
|
Post by alexfish on Feb 8, 2016 15:19:48 GMT 1
Hi Vovchik + & all
Now got the basic drawing functions.
Line Square/Rectangle Poly
as U know the poly will give line , triangle , regular polygons , through to circle
all are same 0 = wire, 1 = fill
suppose the downer as far as EGL is concerned , is the likes of Font & pixbuffers + SVG graphics,
as far as can see there is no egl gl api to do these , one has to look at the VG , vector graphics + the actual EGL bits.
a little more complex than the norm? , depends on how U look at it , can achieve what can be done with say , Cairo.
to that end, now have first VG tiger on the go... render speed on Raspberry Egl surface , full screen tiger , Woosh..
think U will find the panther a No Brainer with the vg lib.
BR Alex
|
|
|
Post by vovchik on Feb 8, 2016 18:09:25 GMT 1
Dear Alex,
Very nice and keep plugging away. We will have to look at how we can make this lib work under normal desktop Linux. Should not be that hard.
With kind regards, vovchik
|
|
|
Post by alexfish on Feb 8, 2016 22:20:19 GMT 1
Hi Vovchik
have already mention on the Raspberry pi thread ' configuring bacon for raspberry pi 2' .
RE
benosteen-opengles-book-samples-5ff2dc9
there is a configuration for the X11 + other embedded devices.
one way to speed up the likes of glut would be to prep array's for drawing esp the likes of square and line,
at present all are drawn using the same routines. and loops ,
will post on the Hi performance canvas thread , details of what is working on the Raspberry PI ,
First need to convert the bits to Ctypes , IE Not using GLtypes. as defined in the headers
BR Alex
|
|
|
Post by alexfish on Feb 24, 2016 2:52:54 GMT 1
Hi All
SDC(raspian) canvas Update
Final beta testing now at post 1
many features have been added : will update some docs , next week
but this demo may help, Retro: PONG , must have py games folder / but can change the path to any image. Image with scale to the dimensions passed.
Have Fun + BR Alex
INCLUDE SDC.bac
GLOBAL ball TYPE GLfloat * GLOBAL ball_indices TYPE GLuint
GLOBAL TOGED = 0,score= 0, miss = 0 TYPE int GLOBAL scr TYPE char *
' *********************************************************** SUB QUIT() DeInit() PRINT "BYE" SLEEP 500 END END SUB
' *********************************************************** SUB DoDraw()
LOCAL eposi3=0,epos3=0,epos4=0,eposi4=0 , eposi4top=400 , toppos,tops TYPE static float WHILE 1 DO CLS(win) ORTHO TRANSLATE((float) Width/2, Height/2,-1) INK(0,255,0,255) SQUARE((float) Width/2-18, (float) Height/2-5,0)
ORTHO TRANSLATE(toppos+300,epos4+200,0) INK(255,255,255,255) DRAWPOLYGEN(ball,ball_indices,GL_TRIANGLE_FAN)
ORTHO TRANSLATE(toppos+300,5,0) INK(255,255,0,255) SQUARE(20,3,1)
ORTHO TRANSLATE(eposi4top,395,0) INK(0,0,255,255) SQUARE(30,3.0,1)
IF (TOGED) THEN
'******** IF (InKey) THEN IF (InKey == KEY_LEFT) THEN DECR eposi4top ,8 END IF IF (InKey == KEY_RIGHT) THEN INCR eposi4top ,8 END IF IF (eposi4top >= 550) THEN eposi4top = 550 END IF IF (eposi4top <= 50) THEN eposi4top = 50 END IF
END IF '********
'******** IF (score > 10 ) THEN INCR eposi4 , 0.07 INCR tops , 0.03 ELIF (score > 15 ) THEN INCR eposi4 , 0.08 INCR tops , 0.4 ELSE INCR eposi4 , 0.06 INCR tops , 0.02 END IF '********
INCR eposi3 , 0.04 epos4 = sin(eposi4)*190 toppos = cos(tops)*280 '******* check if in bounds of target on y axis IF (epos4+200 > 389.9) THEN
'******** if hit on x bounds update score IF ((toppos+300 >= eposi4top-30) && (toppos+300 <= eposi4top+30)) THEN INCR score ELSE DECR score INCR miss END IF '********
'** no - score IF (score < 0) THEN score = 0 END IF '**
scr = "<span font = 'URW Palladio L italic 20px' foreground='#001831'><b>Score :" & STR$(score) & " : Miss:" & STR$(miss)& "</b></span>"
TEXTMARK(labscore,scr)
'** if 21 win and stop IF (score == 21 ) THEN TOGED = NOT(TOGED) END IF '**
END IF ORTHO TRANSLATE(72,40,0) ROTATE(-9,0,0,1) INK(255,0,0,130) Gbutton(58,17,1) ELSE ORTHO TRANSLATE(72,40,0) ROTATE(-9,0,0,1) INK(140,255,30,120) Gbutton(58,17,1) ENDIF ' All done : Swap Buffers SYNC
WEND
END SUB ' *********************************************************** SUB But_Click ()
IF (SelectedWidget == lab1) THEN TOGED = NOT(TOGED) IF (TOGED) THEN score= 0 miss = 0 END IF END IF
ENDSUB
' ** MAIN *********************************************************
win = WINDOW("Pong-Demo",600,400)
CALLBACK(win,"delete_event",QUIT) CALLBACK(MainEvent, "button-press-event",But_Click)
img = IMAGE("/home/pi/python_games/flippyboard.png",600,400,GDK_INTERP_BILINEAR) ATTACH(Layer,img,0,0)
lab1 = MARK("<span font='URW Palladio L italic 20px' foreground='#001831'><b>Start-New</b></span>") ATTACH(Layer,lab1,20,20) MARKROTATE(lab1,9) REGEVENT(lab1, 10,10,125,42,TRUE)
labscore = MARK("<span font='URW Palladio L italic 20px' foreground='#001831'><b>Score:</b></span>") ATTACH(Layer,labscore,250,20)
lab2 = MARK("<span font='URW Palladio L italic 20px' foreground='#001831'><b>* Pong *</b></span>") ATTACH(Layer,lab2,500,20) MARKROTATE(lab2,-9)
POLYGEN(7,7,15,&ball,&ball_indices) ' loop for ever at DoDraw() ' ***********************************************************
|
|
|
Post by vovchik on Feb 24, 2016 12:42:24 GMT 1
Dear Alex,
It looks impressive and straightforward - I mean the code. Any easy way we can get this to run in Mint, for example?
With kind regards, vovchik
|
|
|
Post by alexfish on Feb 24, 2016 20:25:50 GMT 1
Hi vovchik
Fired up old faithfull , Intel Atom , this is mint16
here looking at the usr/include/
in there at least on my system there are folders
GLES2 GLES3 KHR
looking at the book examples RE Linux this is what is used , via the root x11
so thinking here that one would require the x11 devs as well ,
from here , think there should be no reason why one could not get similar on mint , I think says he.
if that be the case then only change to the libs I wrote will be the window,
now , although you can not see what I have on the Raspi , nor can I post a screen shot, all U get is the frame, Ha.
anyway If one has ever played with Minecraft , then that be the type of interface the lib gives.
can also point out , at the back end there is the gtk x11 win , that is been used for backdrop images and text via the labels save a lot of time esp on image loading = no need to redraw on every Swap of the gles, the GLES just gets on with animation , the pong dem runs at 0 to 1% cpu time. at 50 frames a second. and it be a smooth as milky butter. even at 1980 x 1080.
at this point I have already mentioned , the Benosteen examples have an X11 interface . for GLES . Interesting.
In simplistic terms Glut is not my cup of tea.
BR Alex
|
|
|
Post by vovchik on Feb 24, 2016 21:56:59 GMT 1
Dear Alex, If that is what is required, I think it should/might/can work (full of with naive optimism). Would be great. With kind regards, vovchik
|
|
|
Post by alexfish on Feb 25, 2016 0:30:07 GMT 1
Hi Vovchik
Well can only try ,
also fogot to mention...
Did a version of seven year itch as the backdrop ,
now Listen to this , since I can not post a Picky.
Marilyn on the gtk window , then the egl is in front of it,
likes of the paddles can be made to go infont or behind Marilyn .
Now you can See the real Picture...
BR Alex
|
|
|
Post by alexfish on Feb 26, 2016 1:08:42 GMT 1
Hi Vovchik
got the first x11 / egl window up on mint . need further work . IE need to patch in the rest of the libs
but need to know if this fires up on your set up
BR Alex
in two parts an all in one for the main code/lib
PRAGMA INCLUDE <EGL/egl.h> PRAGMA INCLUDE <GLES2/gl2.h> PRAGMA INCLUDE <X11/Xlib.h> PRAGMA INCLUDE <X11/Xatom.h> PRAGMA INCLUDE <X11/Xutil.h> PRAGMA INCLUDE eglinc.h
PRAGMA OPTIONS -L/usr/include PRAGMA LDFLAGS -lGLESv2 -lEGL -lm -lX11 -pipe OPTION PARSE FALSE ' esCreateWindow flag - RGB color buffer CONST ES_WINDOW_RGB = 0 ' esCreateWindow flag - ALPHA color buffer CONST ES_WINDOW_ALPHA = 1 ' esCreateWindow flag - depth buffer CONST ES_WINDOW_DEPTH = 2 ' esCreateWindow flag - stencil buffer CONST ES_WINDOW_STENCIL = 4 ' esCreateWindow flat - multi-sample buffer CONST ES_WINDOW_MULTISAMPLE = 8
GLOBAL x_display = NULL TYPE static Display *
FUNCTION CreateEGLContext ( EGLNativeWindowType hWnd, EGLDisplay* eglDisplay, \ EGLContext* eglContext, EGLSurface* eglSurface, \ EGLint attribList[])
LOCAL numConfigs TYPE EGLint LOCAL majorVersion TYPE EGLint LOCAL minorVersion TYPE EGLint LOCAL display TYPE EGLDisplay LOCAL context TYPE EGLContext LOCAL surface TYPE EGLSurface LOCAL config TYPE EGLConfig
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
display = eglGetDisplay((EGLNativeDisplayType)x_display); IF ( display == EGL_NO_DISPLAY ) THEN
RETURN (EGL_FALSE) END IF ' Initialize EGL IF ( NOT(eglInitialize(display, &majorVersion, &minorVersion) )) THEN
RETURN (EGL_FALSE) END IF
' Get configs IF ( NOT(eglGetConfigs(display, NULL, 0, &numConfigs) )) THEN
RETURN (EGL_FALSE) END IF
' Choose config IF ( NOT(eglChooseConfig(display, attribList, &config, 1, &numConfigs) )) THEN
RETURN (EGL_FALSE) END IF
'Create a surface surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL) IF ( surface == EGL_NO_SURFACE ) THEN
RETURN (EGL_FALSE) END IF
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs ) IF ( context == EGL_NO_CONTEXT ) THEN
RETURN (EGL_FALSE) END IF
' Make the context currentSurface2 IF ( NOT(eglMakeCurrent(display, surface, surface, context) )) THEN
RETURN (EGL_FALSE) END IF *eglDisplay = display *eglSurface = surface *eglContext = context
RETURN (TRUE)
END FUNCTION
FUNCTION WinCreate(ESContext *esContext, const char *title) TYPE int
LOCAL root TYPE Window LOCAL swa TYPE XSetWindowAttributes LOCAL xattr TYPE XSetWindowAttributes LOCAL wm_state TYPE Atom LOCAL hints TYPE XWMHints LOCAL xev TYPE XEvent LOCAL ecfg TYPE EGLConfig LOCAL num_config TYPE EGLint LOCAL win TYPE Window
/* * X11 native display initialization */
x_display = XOpenDisplay(NULL) IF ( x_display == NULL ) THEN RETURN ( EGL_FALSE) END IF
root = DefaultRootWindow(x_display)
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask; win = XCreateWindow(x_display, root,0, 0, esContext->width, esContext->height, 0,CopyFromParent, InputOutput,CopyFromParent, CWEventMask,&swa )
xattr.override_redirect = FALSE ' XChangeWindowAttributes( x_display, win, CWOverrideRedirect, &xattr )
XChangeWindowAttributes( x_display, win, CWOverrideRedirect, &xattr )
hints.input = TRUE hints.flags = InputHint XSetWMHints(x_display, win, &hints)
' make the window visible on the screen XMapWindow (x_display, win) XStoreName (x_display, win, title)
' get identifiers for the provided atom name strings wm_state = XInternAtom (x_display, "_NET_WM_STATE", FALSE)
memset ( &xev, 0, sizeof(xev) ) xev.type = ClientMessage xev.xclient.window = win xev.xclient.message_type = wm_state xev.xclient.format = 32 xev.xclient.data.l[0] = 1 xev.xclient.data.l[1] = FALSE XSendEvent (x_display,DefaultRootWindow ( x_display ),FALSE,SubstructureNotifyMask,&xev )
esContext->hWnd = (EGLNativeWindowType) win RETURN (EGL_TRUE) END FUNCTION
' ************************************************************* FUNCTION esInitContext(ESContext *esContext) TYPE int
IF ( esContext != NULL ) THEN memset( esContext, 0, sizeof( ESContext) ) RETURN (TRUE) END IF
RETURN (FALSE)
END FUNCTION
FUNCTION esCreateWindow( ESContext *esContext, char* title, GLint width, GLint height, GLuint flags ) TYPE int
LOCAL attribList[] ={EGL_RED_SIZE, 8,EGL_GREEN_SIZE, 8,EGL_BLUE_SIZE, 8, \ EGL_ALPHA_SIZE, 8,EGL_SURFACE_TYPE, EGL_WINDOW_BIT,EGL_NONE} TYPE EGLint IF ( esContext == NULL ) THEN RETURN (GL_FALSE) END IF
esContext->width = width esContext->height = height
IF NOT(WinCreate ( esContext, title) ) THEN RETURN (GL_FALSE) END IF
IF NOT( CreateEGLContext ( esContext->hWnd, &esContext->eglDisplay,&esContext->eglContext,&esContext->eglSurface,attribList) ) THEN RETURN (GL_FALSE) END IF RETURN (GL_TRUE) END FUNCTION
LOCAL esContext TYPE ESContext
esInitContext ( &esContext ) esCreateWindow ( &esContext, "Hello Triangle", 320, 240, ES_WINDOW_RGB );
WHILE 1 DO
WEND
the include = eglinc.h
typedef struct _escontext { // Put your user data here... void* userData;
// Window width GLint width;
// Window height GLint height;
// Window handle EGLNativeWindowType hWnd;
// EGL display EGLDisplay eglDisplay; // EGL context EGLContext eglContext;
// EGL surface EGLSurface eglSurface;
} ESContext;
|
|
|
Post by alexfish on Feb 26, 2016 5:23:02 GMT 1
Hi Vovchik
think can save your breath,
mint16 egl2 and raspi egl2 is a different as chalk & cheese
below is the bits I put in that work on the raspy and have commented out the bits that do not work here
from what I be seeing , it be as much good as tits to a bull.
BR Alex
LOCAL esContext TYPE ESContext
esInitContext ( &esContext ) esCreateWindow ( &esContext, "Hello Triangle", 320, 240, ES_WINDOW_RGB ); glEnable(GL_BLEND) ' glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
' glBlendFunc(GL_SRC_ALPHA) 'glEnable(GL_MULTISAMPLE) glEnable(GL_DEPTH_TEST) 'glEnable(GL_COLOR_MATERIAL) 'glMatrixMode(GL_PROJECTION)
' Pixel rendering 'glHint(GL_POINT_SMOOTH_HINT, GL_NICEST) 'glHint(GL_LINE_SMOOTH_HINT, GL_NICEST) ' glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
'glLoadIdentity() 'glMatrixMode(GL_MODELVIEW) 'glEnableClientState( GL_VERTEX_ARRAY )
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) glClearColor(1.0f, 1.0f, 1.0f, 0.0f) glClearColor ( 1.0f, 0.0f, 1.0f, 0.0f ); eglSwapBuffers(Display1, Surface) WHILE 1 DO 'PRINT " loop " glClearColor ( 1.0f, 0.0f, 1.0f, 1.0f ); eglSwapBuffers(Display1, Surface) SLEEP 50 WEND
|
|
|
Post by vovchik on Feb 26, 2016 11:04:55 GMT 1
Dear Alex, With the first test, I get a window. Nothing gets draw, however, and I am looking at the code. With kind regards, vovchik
|
|
|
Post by alexfish on Feb 26, 2016 11:21:28 GMT 1
Hi Vovchik
If the window black then U'r in. if no the try to increase the SLEEP ,
from there , depending on egl version , but at least should be able to use the shaders,
the benosteen examples work with exception of the particals..
BR Alex
|
|