Reply
Thread Tools
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#21
BTW, you no longer need the HILDON_NON_COMPOSITED stuff.
 

The Following User Says Thank You to javispedro For This Useful Post:
Posts: 804 | Thanked: 1,598 times | Joined on Feb 2010 @ Gdynia, Poland
#22
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 ( because this whole setup is the hardest part I think... )

Last edited by misiak; 2010-02-19 at 02:35. Reason: code was not working after switching to another window and going back, needed to change a little
 
Posts: 30 | Thanked: 16 times | Joined on Jan 2010 @ Berlin
#23
Originally Posted by misiak View Post
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 ( 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's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#24
Originally Posted by misiak View Post
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's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#25
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)

Last edited by javispedro; 2010-03-05 at 01:34.
 

The Following 6 Users Say Thank You to javispedro For This Useful Post:
Posts: 345 | Thanked: 467 times | Joined on Nov 2007 @ Germany
#26
Originally Posted by javispedro View Post
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.
 

The Following User Says Thank You to Master of Gizmo For This Useful Post:
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#27
Originally Posted by Master of Gizmo View Post
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.
 
Posts: 1 | Thanked: 1 time | Joined on Apr 2010
#28
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.

Last edited by JanJordan; 2010-04-22 at 15:39.
 

The Following User Says Thank You to JanJordan For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 09:40.