Showing posts with label gtkgl. Show all posts
Showing posts with label gtkgl. Show all posts

06 October 2014

ubuntu 14.4, opengl, touch, gtkmm

http://vbkaisetsu.sky-air.net/wordpress/2012/03/gtk-3-4-%E3%81%AE%E3%82%BF%E3%83%83%E3%83%81%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%82%92%E8%A9%A6%E3%81%99/
g++ `pkg-config --cflags gtk+-3.0` a.cpp -o hello `pkg-config --libs gtk+-3.0` -fpermissive

https://gist.github.com/chergert/4344205
python touchy.py

chromium-browser --touch-events=enabled

http://blog.vucica.net/2014/03/ubuntu-touchscreen-and-multiscreen-hd-touchscreen-on-the-left-laptop-on-the-right.html

install GL
sudo apt-get install freeglut3 freeglut3-dev

install gtkgl
sudo apt-get install gtkgl-dev
example for gtkgl
http://gtkglarea.sourcearchive.com/documentation/1.2.3-2.2/simple_8c-source.html
compile
g++ `pkg-config --cflags gtkgl-2.0` simple.cpp -o hello `pkg-config --libs gtkgl-2.0` -fpermissive -Wformat-security

g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2


gl with gtk3

https://github.com/tdz/gtkglext

http://stackoverflow.com/questions/12076648/is-there-a-way-to-have-an-opengl-context-inside-a-gtk3-application

https://www.youtube.com/watch?v=CvBbphubIGo
https://github.com/andrepiske/tegtkgl
gcc -Wall -g `pkg-config --cflags gtk+-3.0` main.c tegtkgl.c -o hello2 `pkg-config --libs gtk+-3.0` -lX11 -lGL -lm

15 November 2012

transparent object (weird depth problem)



The possible causes are:
no glEnable(GL_DEPTH_TEST);
no glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); in every frame
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.0f,100.0f);
0 for near (should be 0.1f)

But the culprit of my problem is:
glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE ); 
which is called before you run openGL
If you don't put GLUT_DEPTH in here, depth won't be calculated!

To check whether you've defined depth or not in your program:
int depth;
glGetIntegerv(GL_DEPTH_BITS, &depth);
std::cout << "depth " << depth << std::endl;
if the result is 0, that means the depth is not defined.
This GL_DEPTH_BITS seems to be deprecated in openGL 3.3 / 4, though. I don't know what my version is but it worked (was 0, is now non 0).

I'm using gtkglarea, and the setting for it is:
int attrlist[] = {
    GDK_GL_RGBA,
    GDK_GL_RED_SIZE,1,
    GDK_GL_GREEN_SIZE,1,
    GDK_GL_BLUE_SIZE,1,
    GDK_GL_DOUBLEBUFFER,
    GDK_GL_DEPTH_SIZE,16,
    GDK_GL_NONE
};
which is used by  glArea = GTK_WIDGET(gtk_gl_area_new(attrlist)); to create new open widget in GTK.
Not sure why the size is 16, though, but putting on 32 results in a blank screen for mine.

Beware that some computer may work by default without this depth setting. Ugh. @_@