Author Topic: Keypresses in EGL examples?  (Read 2267 times)

Optimus (OP)

  • Posts: 107
Keypresses in EGL examples?
« on: August 06, 2014, 10:40:30 pm »
So, I installed the windows toolchain and I managed to compile the examples here.

I am trying to make some project where I need proper button and timer. My problem is, nothing seems to work so far (I even have a nframe++ that automatically exits after 480 frames, 8 secs, because I can't even exit on keypress).

First there is an esRegisterKeyFunc(&esContext, Key) function, which takes your callback for keyboard controll (input for gcw0 buttons too? Doesn't seem so). There is an example that also uses it, but doesn't seem to respond either on gcw0. I tried to do something, anyting when pressed, even get key number and display it on screen (with my own text draw routine on OpenGL ES). Nothing absolutely!

Then my second thought is to include SDL and use the key events there. It doesn't seem to respond to anything. Even the event loop doesn't seem to. I am not sure if it's correct to init SDL while EGL has been init.

I also tried some conio.h and conio.cpp equivalent for linux, that replaces kbhit. Absolutely nothing! I say to my code to draw something or exit if any key is pressed, nothing in all three cases.

What is the proper way to have input with those EGL context examples? In GCW0. It's breaking my nerves, any easy way or example code to solve this?

pcercuei

  • Posts: 1667
    • My devblog
Re: Keypresses in EGL examples?
« Reply #1 on: August 07, 2014, 12:10:24 am »
So, I installed the windows toolchain and I managed to compile the examples here.

I am trying to make some project where I need proper button and timer. My problem is, nothing seems to work so far (I even have a nframe++ that automatically exits after 480 frames, 8 secs, because I can't even exit on keypress).

First there is an esRegisterKeyFunc(&esContext, Key) function, which takes your callback for keyboard controll (input for gcw0 buttons too? Doesn't seem so). There is an example that also uses it, but doesn't seem to respond either on gcw0. I tried to do something, anyting when pressed, even get key number and display it on screen (with my own text draw routine on OpenGL ES). Nothing absolutely!

Then my second thought is to include SDL and use the key events there. It doesn't seem to respond to anything. Even the event loop doesn't seem to. I am not sure if it's correct to init SDL while EGL has been init.

I also tried some conio.h and conio.cpp equivalent for linux, that replaces kbhit. Absolutely nothing! I say to my code to draw something or exit if any key is pressed, nothing in all three cases.

What is the proper way to have input with those EGL context examples? In GCW0. It's breaking my nerves, any easy way or example code to solve this?

The esRegisterKeyFunc function does not exist in the toolchain. Which means that if your program compiled, you probably pointed it to include your host's headers for EGL/SDL/etc instead of the toolchain's.

EGL is a library that can be used to create a GLES context. It does not provide anything else. If you want to use GLES2 and have handy functions to read key presses or joystick events, you should use SDL2, that's the easiest way.

Optimus (OP)

  • Posts: 107
Re: Keypresses in EGL examples?
« Reply #2 on: August 07, 2014, 10:48:22 pm »
Ok, thanks! I wasn't sure if I could mix SDL with EGL.

Yesterday I also made some mistakes. I thought I shouldn't init SDL screen at all because it could mess in my mind the graphics context of EGL and I don't need the SDL screen. And I thought, if I only want input, I should init input or joystick. But no, in a separate SDL test, making it as minimalistic as possible, I realized that input will work if I at least run SDL_SetVideoMode. I don't even need to run SDL_INIT. But I have to run SDL_SetVideoMode once, just before the EGL init. Then input events work. Not my initial understanding of SDL, but anyway, I hope in the new SDL2 these are more separated.

mth

  • Posts: 317
Re: Keypresses in EGL examples?
« Reply #3 on: August 09, 2014, 02:56:17 am »
It is possible to mix SDL with EGL: Pickle did it, but it requires quite some setup code. I'd recommend to go for SDL2 instead. I'll pm you links to an experimental toolchain and firmware version in which SDL2 works. We want to release an update soon so everyone has access to that, but there are still some bugs left to squash.

 

Post a new topic