maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Xlib+OpenGLES performace (https://talk.maemo.org/showthread.php?t=37356)

javispedro 2010-02-17 17:40

Re: Xlib+OpenGLES performace
 
BTW, you no longer need the HILDON_NON_COMPOSITED stuff.

misiak 2010-02-19 02:18

Re: Xlib+OpenGLES performace
 
I managed to get keyboard working in your example :)

you need to change:

Code:

\\swa.event_mask  =  ExposureMask | PointerMotionMask;
swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask;

and

Code:

while (!quit) {
XSetInputFocus( x_display, root, RevertToParent, CurrentTime);
XSetInputFocus( x_display, win, RevertToParent, CurrentTime);
XFlush( x_display );
while(XPending( x_display )) { ...

And then the main loop with xev.type will be able to handle: MotionNotify, ButtonPress, ButtonRelease and KeyPress events :)

note: you may need to add
Code:

#include <X11/Xutil.h>
after line with X11/Xlib.h , but I'm not sure, my code is a little bit longer at the moment... Can I change this in your code at wiki? do you agree? : ) I've spent 3 days on this silly little problem, but finally solved it, with help of this page (and other pages it links to, and so on) : http://talk.maemo.org/showthread.php?t=36952

It seems you need to setup this ButtonPressMask and manualy call XSetInputFocus to get keyboard running in X app... I will post in near future very simple code with implemented handling of keyboard, mouse (touchscreen), accelerometer and opengles 2.0, as I'm still working on it :) it's also very modular, splitted into files like "accelerometer.h", "glinit.h", "glrender.h", etc. ; ) Hope this helps many developers to start developing :D ( because this whole setup is the hardest part I think... )

endboss 2010-02-19 10:55

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by misiak (Post 535779)
I managed to get keyboard working in your example :)

you need to change:

Code:

\\swa.event_mask  =  ExposureMask | PointerMotionMask;
swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask;

and

Code:

while (!quit) {
XSetInputFocus( x_display, root, RevertToParent, CurrentTime);
XSetInputFocus( x_display, win, RevertToParent, CurrentTime);
XFlush( x_display );
while(XPending( x_display )) { ...

And then the main loop with xev.type will be able to handle: MotionNotify, ButtonPress, ButtonRelease and KeyPress events :)

note: you may need to add
Code:

#include <X11/Xutil.h>
after line with X11/Xlib.h , but I'm not sure, my code is a little bit longer at the moment... Can I change this in your code at wiki? do you agree? : ) I've spent 3 days on this silly little problem, but finally solved it, with help of this page (and other pages it links to, and so on) : http://talk.maemo.org/showthread.php?t=36952

It seems you need to setup this ButtonPressMask and manualy call XSetInputFocus to get keyboard running in X app... I will post in near future very simple code with implemented handling of keyboard, mouse (touchscreen), accelerometer and opengles 2.0, as I'm still working on it :) it's also very modular, splitted into files like "accelerometer.h", "glinit.h", "glrender.h", etc. ; ) Hope this helps many developers to start developing :D ( because this whole setup is the hardest part I think... )

Thank you for your work. Of course one needs to activate the KeyPressEvent to get key presses delivered.
I edited the example already. I tested this on my phone and it works as desired.

javispedro 2010-02-19 14:49

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by misiak (Post 535779)
Code:

while (!quit) {
XSetInputFocus( x_display, root, RevertToParent, CurrentTime);
XSetInputFocus( x_display, win, RevertToParent, CurrentTime);
XFlush( x_display );
while(XPending( x_display )) { ...



Argh, you don't need the above. Please set the proper WM_HINTS (the input hint at least), read http://tronche.com/gui/x/xlib/ICC/cl.../wm-hints.html

javispedro 2010-03-05 01:30

Re: Xlib+OpenGLES performace
 
I've rewritten Exoticorn's sample to make it use my "new" library (which I call SDL_gles) that allows you to easily use OpenGL|ES (either 1.1 or 2.0) within your SDL applications.

Check it out here: http://git.maemo.org/git/sdlhildon/?...egl.cc;hb=HEAD .

The entire initialization code gets reduced to
Code:

SDL_Init(SDL_INIT_VIDEO);
SDL_GLES_Init(SDL_GLES_VERSION_2_0);
screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE | SDL_FULLSCREEN);
SDL_WM_SetCaption("SimpleGL", "SimpleGL");
SDL_ShowCursor(SDL_DISABLE);
context = SDL_GLES_CreateContext();
SDL_GLES_MakeCurrent(context);

(start of OpenGL|ES code)
glClearColor(0.08, 0.06, 0.07, 1.0);        // background color

GLuint vertexShader = load_shader(vertex_src, GL_VERTEX_SHADER);        // load vertex shader
...

and that is already doing more stuff than the previous Xlib "example", since it's hiding the mouse pointer, calculating the screen size (screen->w, screen->h), setting all the appropriate atoms and WmHints, etc. And you don't have to write a single Xlib call (not even a single EGL call if the application is simple enough).

As you can guess, the event handling code is also very much simplified (getting keyboard input, mouse events, is as easy as with any SDL app).

The library is already available on extras-devel (package name is "libsdl-gles1.2-dev", garage project is "sdlhildon"). For now, best documentation is the header itself on SDL_gles.h, but I plan to put some simpler examples later (or see the tests directory in git)

Master of Gizmo 2010-03-15 10:38

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by javispedro (Post 556269)
The library is already available on extras-devel (package name is "libsdl-gles1.2-dev", garage project is "sdlhildon"). For now, best documentation is

Hmm, seems to want to be allowed to exclusively create /opt. Unfortunately espeak does the same:

Code:

Unpacking libsdl-gles1.2-1 (from .../libsdl-gles1.2-1_1.0.0_armel.deb) ...
dpkg: error processing /var/cache/apt/archives/libsdl-gles1.2-1_1.0.0_armel.deb (--unpack):
 trying to overwrite `/opt', which is also in package espeak-data
Selecting previously deselected package libsdl-gles1.2-dev.


javispedro 2010-03-20 00:19

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by Master of Gizmo (Post 567583)
Hmm, seems to want to be allowed to exclusively create /opt. Unfortunately espeak does the same:

I am sorry, but I've not managed to reproduce this even though I've tried quite a few times...

Code:

Nokia-N900-02-8:~# dpkg -l espeak-data libsdl-gles1.2-1
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name          Version        Description
+++-==============-==============-============================================
ii  espeak-data    1.43.03        eSpeak speech data files
ii  libsdl-gles1.2 1.0.0          OpenGL|ES library for Simple DirectMedia Lay

Can you give me a hint over how to reproduce it? As of now, I don't even know what could cause that, since I'm using the autobuilder optifier.

If this is scratchbox you're talking about, I think there was a FAQ item about something like that but iirc was fixed in recent PR1.1 onwards rootstraps.

JanJordan 2010-04-22 11:56

Re: Xlib+OpenGLES performace
 
small remark regarding that example as shown on http://wiki.maemo.org/SimpleGL_example:

It uses GL_TRIANGLE_STRIP to draw a quad, but since 5 vertices are given, it actually draws 3 triangles. For triangle srtip, only 4 are needed, but you need to reorder the vertices. Or you just remove the last vertices and draw a GL_TRIANGLE_FAN

Stumbled across this while porting the example to Python using ctypes,
http://orgetik.de/wp/wordpress/?p=131
if anyone is interested.


All times are GMT. The time now is 21:35.

vBulletin® Version 3.8.8