From ff935ee1b0f840f404bce736b88b518154b10309 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Thu, 17 Aug 2017 13:29:32 +0200 Subject: [PATCH] libports: Mesa demos + adjust Qt5 * Adjust Qt5 to new Mesa version * Added eglgears * Adjust Mesa library build target fixes #2488 --- repos/gems/run/mixer_gui_qt_test.run | 8 +- repos/libports/lib/import/import-qt5_gui.mk | 4 +- repos/libports/run/eglgears.run | 69 ++-- repos/libports/run/qt5.run | 14 +- repos/libports/run/qt5_avplay.run | 14 +- repos/libports/run/qt5_calculatorform.run | 14 +- repos/libports/run/qt5_openglwindow.run | 11 +- repos/libports/run/qt5_qpluginwidget.run | 18 +- repos/libports/run/qt5_quicktest.run | 14 +- repos/libports/run/qt5_samegame.run | 14 +- repos/libports/run/qt5_tetrix.run | 14 +- repos/libports/run/qt5_textedit.run | 19 +- .../nitpicker/qnitpickerglcontext.cpp | 2 +- .../libports/src/test/libports/mesa/target.mk | 3 +- .../src/test/mesa_demo/eglgears/eglgears.c | 302 ++++++++++++++ .../src/test/mesa_demo/eglgears/target.mk | 12 + .../libports/src/test/mesa_demo/eglut/eglut.c | 368 ++++++++++++++++++ .../libports/src/test/mesa_demo/eglut/eglut.h | 93 +++++ .../src/test/mesa_demo/eglut/eglut_genode.cc | 143 +++++++ .../src/test/mesa_demo/eglut/eglutint.h | 103 +++++ .../src/test/mesa_demo/eglut/gl_wrap.h | 15 + repos/ports/run/arora.run | 8 +- 22 files changed, 1210 insertions(+), 52 deletions(-) create mode 100644 repos/libports/src/test/mesa_demo/eglgears/eglgears.c create mode 100644 repos/libports/src/test/mesa_demo/eglgears/target.mk create mode 100644 repos/libports/src/test/mesa_demo/eglut/eglut.c create mode 100644 repos/libports/src/test/mesa_demo/eglut/eglut.h create mode 100644 repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc create mode 100644 repos/libports/src/test/mesa_demo/eglut/eglutint.h create mode 100644 repos/libports/src/test/mesa_demo/eglut/gl_wrap.h diff --git a/repos/gems/run/mixer_gui_qt_test.run b/repos/gems/run/mixer_gui_qt_test.run index 997b9556f2..948f902ac9 100644 --- a/repos/gems/run/mixer_gui_qt_test.run +++ b/repos/gems/run/mixer_gui_qt_test.run @@ -17,6 +17,7 @@ set build_components { server/nitpicker server/fs_rom server/wm + lib/mesa/swrast app/pointer app/floating_window_layouter app/decorator @@ -203,6 +204,7 @@ append config { + } @@ -241,12 +243,16 @@ set boot_modules { qt5_widgets.lib.so qt5_xml.lib.so qt5_core.lib.so + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so zlib.lib.so stdcxx.lib.so pthread.lib.so diff --git a/repos/libports/lib/import/import-qt5_gui.mk b/repos/libports/lib/import/import-qt5_gui.mk index fe82ac2a4b..3c87f51668 100644 --- a/repos/libports/lib/import/import-qt5_gui.mk +++ b/repos/libports/lib/import/import-qt5_gui.mk @@ -9,7 +9,7 @@ include $(IMPORT_QT5_INC) # included (in 'base/mk/lib.mk') by iterating through the elements of the # 'LIBS' variable. Hence, we also need to manually import the stdcxx snippet. # -LIBS += gallium -include $(call select_from_repositories,lib/import/import-gallium.mk) +LIBS += mesa +include $(call select_from_repositories,lib/import/import-mesa.mk) QT5_INC_DIR += $(QT5_CONTRIB_DIR)/qtbase/include/QtGui diff --git a/repos/libports/run/eglgears.run b/repos/libports/run/eglgears.run index 2e9f429757..40dbb48d35 100644 --- a/repos/libports/run/eglgears.run +++ b/repos/libports/run/eglgears.run @@ -1,11 +1,14 @@ set build_components { core init drivers/timer - server/nitpicker server/nit_fb - app/launchpad app/pointer - app/eglgears - drivers/framebuffer drivers/input - lib/gallium + drivers/input + drivers/framebuffer + lib/mesa/swrast + server/nitpicker + server/nit_fb + app/launchpad + app/pointer + test/mesa_demo/eglgears } source ${genode_dir}/repos/base/run/platform_drv.inc @@ -16,25 +19,24 @@ build $build_components create_boot_directory set config { - + - + + - - + - } -append_if [have_spec sdl] config { +append_if [have_spec linux] config { @@ -45,16 +47,19 @@ append_if [have_spec sdl] config { append_platform_drv_config -append_if [have_spec framebuffer] config { - - - +append_if [expr ![have_spec linux]] config { + + + + + + } append_if [have_spec ps2] config { - - + + } append config { @@ -77,7 +82,7 @@ append config { - + @@ -93,19 +98,25 @@ append config { + - + - + - + + + + - + + + @@ -120,14 +131,16 @@ install_config $config set boot_modules { core init ld.lib.so timer nitpicker nit_fb - launchpad eglgears pointer - gallium.lib.so libc.lib.so libm.lib.so pthread.lib.so posix.lib.so + launchpad gears pointer + libc.lib.so libm.lib.so pthread.lib.so + egl.lib.so mesa.lib.so stdcxx.lib.so + expat.lib.so glapi.lib.so + egl_swrast.lib.so } -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec framebuffer] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv -lappend_if [have_spec i915] boot_modules gallium-i915.lib.so +lappend_if [have_spec linux] boot_modules fb_sdl +lappend_if [expr ![have_spec linux]] boot_modules fb_drv +lappend_if [have_spec ps2] boot_modules ps2_drv append_platform_drv_boot_modules diff --git a/repos/libports/run/qt5.run b/repos/libports/run/qt5.run index c402c84426..3eb86f869f 100644 --- a/repos/libports/run/qt5.run +++ b/repos/libports/run/qt5.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/qt_launchpad app/qt5/examples/calculatorform app/qt5/examples/tetrix @@ -36,7 +37,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -69,6 +70,11 @@ append config { + + + + + } @@ -83,14 +89,18 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { qt_launchpad + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_avplay.run b/repos/libports/run/qt5_avplay.run index ca00879c91..f581000237 100644 --- a/repos/libports/run/qt5_avplay.run +++ b/repos/libports/run/qt5_avplay.run @@ -9,6 +9,7 @@ set feature(Audio_out) 1 append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/avplay app/qt5/qt_avplay } @@ -45,7 +46,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -61,6 +62,11 @@ append config { + + + + + } @@ -75,10 +81,14 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { qt_avplay + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so + mesa.lib.so posix.lib.so libc_pipe.lib.so libm.lib.so diff --git a/repos/libports/run/qt5_calculatorform.run b/repos/libports/run/qt5_calculatorform.run index 1a2bfb5e7c..5c763196c6 100644 --- a/repos/libports/run/qt5_calculatorform.run +++ b/repos/libports/run/qt5_calculatorform.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/examples/calculatorform } @@ -33,7 +34,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -48,6 +49,11 @@ append config { + + + + + } @@ -62,14 +68,18 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { calculatorform + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_openglwindow.run b/repos/libports/run/qt5_openglwindow.run index 527bd08138..3b2ffc8b44 100644 --- a/repos/libports/run/qt5_openglwindow.run +++ b/repos/libports/run/qt5_openglwindow.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/examples/openglwindow } @@ -40,6 +41,10 @@ append config [qt5_start_nodes feature] append config { + + + + @@ -61,14 +66,18 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { openglwindow + expat.lib.so freetype.lib.so - gallium.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so + egl.lib.so + egl_swrast.lib.so + glapi.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_qpluginwidget.run b/repos/libports/run/qt5_qpluginwidget.run index 03c06bae50..c354a6348e 100644 --- a/repos/libports/run/qt5_qpluginwidget.run +++ b/repos/libports/run/qt5_qpluginwidget.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast server/loader server/tar_rom test/nitpicker @@ -35,7 +36,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -52,6 +53,10 @@ append config { + + + + @@ -62,6 +67,11 @@ append config { + + + + + } @@ -81,8 +91,11 @@ append boot_modules { tar_rom testnit test-qpluginwidget + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so @@ -91,6 +104,7 @@ append boot_modules { libpng.lib.so libssl.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_quicktest.run b/repos/libports/run/qt5_quicktest.run index 911f0cb730..20d6c1f25c 100644 --- a/repos/libports/run/qt5_quicktest.run +++ b/repos/libports/run/qt5_quicktest.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/qt_quicktest lib/qt5/qtdeclarative/src/imports/qtquick2 } @@ -33,7 +34,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -48,6 +49,11 @@ append config { + + + + + } @@ -65,8 +71,11 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { qt_quicktest + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so @@ -75,6 +84,7 @@ append boot_modules { libpng.lib.so libssl.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_samegame.run b/repos/libports/run/qt5_samegame.run index 7535e67a6f..c8b9e8586b 100644 --- a/repos/libports/run/qt5_samegame.run +++ b/repos/libports/run/qt5_samegame.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/examples/samegame lib/qt5/qtdeclarative/src/imports/qtquick2 } @@ -33,7 +34,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -48,6 +49,11 @@ append config { + + + + + } @@ -65,8 +71,11 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { samegame + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so @@ -75,6 +84,7 @@ append boot_modules { libpng.lib.so libssl.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_tetrix.run b/repos/libports/run/qt5_tetrix.run index fa227567cc..9bcb3c756c 100644 --- a/repos/libports/run/qt5_tetrix.run +++ b/repos/libports/run/qt5_tetrix.run @@ -7,6 +7,7 @@ source ${genode_dir}/repos/libports/run/qt5_common.inc append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/examples/tetrix } @@ -32,7 +33,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -47,6 +48,11 @@ append config { + + + + + } @@ -61,14 +67,18 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { tetrix + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/run/qt5_textedit.run b/repos/libports/run/qt5_textedit.run index 82ed621166..0b0d7ec071 100644 --- a/repos/libports/run/qt5_textedit.run +++ b/repos/libports/run/qt5_textedit.run @@ -12,6 +12,7 @@ if {[have_spec odroid_xu]} { append build_components [qt5_build_components feature] append build_components { + lib/mesa/swrast app/qt5/examples/textedit } @@ -45,7 +46,7 @@ append config { - + } append config [qt5_start_nodes feature] @@ -97,6 +98,11 @@ append config { + + + + + @@ -109,6 +115,11 @@ append config { + + + + + } @@ -123,14 +134,18 @@ append boot_modules [qt5_boot_modules feature] append boot_modules { textedit + egl.lib.so + egl_swrast.lib.so + expat.lib.so freetype.lib.so - gallium.lib.so + glapi.lib.so ld.lib.so libc.lib.so libc_pipe.lib.so libm.lib.so libpng.lib.so jpeg.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_component.lib.so diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp index f7223a8fd0..b889aa79d1 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp @@ -86,7 +86,7 @@ bool QNitpickerGLContext::makeCurrent(QPlatformSurface *surface) qFatal("eglDestroySurface() failed"); EGLSurface egl_surface = - eglCreateWindowSurface(_egl_display, _egl_config, &egl_window, 0); + eglCreatePixmapSurface(_egl_display, _egl_config, &egl_window, 0); if (egl_surface == EGL_NO_SURFACE) qFatal("eglCreateiWindowSurface() failed"); diff --git a/repos/libports/src/test/libports/mesa/target.mk b/repos/libports/src/test/libports/mesa/target.mk index 454327e231..8df2f83cbd 100644 --- a/repos/libports/src/test/libports/mesa/target.mk +++ b/repos/libports/src/test/libports/mesa/target.mk @@ -1,6 +1,5 @@ TARGET = test-mesa -LIBS = libc mesa mesa-egl -LIBS += $(addprefix gallium-,aux softpipe failover identity egl) +LIBS = libc mesa egl SRC_CC = main.cc vpath main.cc $(PRG_DIR)/.. diff --git a/repos/libports/src/test/mesa_demo/eglgears/eglgears.c b/repos/libports/src/test/mesa_demo/eglgears/eglgears.c new file mode 100644 index 0000000000..415d1fae8e --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglgears/eglgears.c @@ -0,0 +1,302 @@ +/* + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * This is a port of the infamous "glxgears" demo to straight EGL + * Port by Dane Rushton 10 July 2005 + * + * No command line options. + * Program runs for 5 seconds then exits, outputing framerate to console + */ + +#include +#include "gl_wrap.h" +#include +#include +#include "eglut.h" + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static GLint gear1, gear2, gear3; +static GLfloat angle = 0.0; + +/* + * + * Draw a gear wheel. You'll probably want to call this function when + * building a display list since we do a lot of trig here. + * + * Input: inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, + GLint teeth, GLfloat tooth_depth) +{ + GLint i; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + da = 2.0 * M_PI / teeth / 4.0; + + glShadeModel(GL_FLAT); + + glNormal3f(0.0, 0.0, 1.0); + + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + if (i < teeth) { + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + } + glEnd(); + + /* draw front sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + } + glEnd(); + + glNormal3f(0.0, 0.0, -1.0); + + /* draw back face */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + if (i < teeth) { + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + } + } + glEnd(); + + /* draw back sides of teeth */ + glBegin(GL_QUADS); + da = 2.0 * M_PI / teeth / 4.0; + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + } + glEnd(); + + /* draw outward faces of teeth */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i < teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + + glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); + glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); + u = r2 * cos(angle + da) - r1 * cos(angle); + v = r2 * sin(angle + da) - r1 * sin(angle); + len = sqrt(u * u + v * v); + u /= len; + v /= len; + glNormal3f(v, -u, 0.0); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); + glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + width * 0.5); + glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), + -width * 0.5); + u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); + v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); + glNormal3f(v, -u, 0.0); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + width * 0.5); + glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), + -width * 0.5); + glNormal3f(cos(angle), sin(angle), 0.0); + } + + glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); + glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); + + glEnd(); + + glShadeModel(GL_SMOOTH); + + /* draw inside radius cylinder */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= teeth; i++) { + angle = i * 2.0 * M_PI / teeth; + glNormal3f(-cos(angle), -sin(angle), 0.0); + glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); + glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); + } + glEnd(); +} + + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +#if 1 + glPushMatrix(); + glRotatef(view_rotx, 1.0, 0.0, 0.0); + glRotatef(view_roty, 0.0, 1.0, 0.0); + glRotatef(view_rotz, 0.0, 0.0, 1.0); + + glPushMatrix(); + glTranslatef(-3.0, -2.0, 0.0); + glRotatef(angle, 0.0, 0.0, 1.0); + glCallList(gear1); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(3.1, -2.0, 0.0); + glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); + glCallList(gear2); + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-3.1, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + glCallList(gear3); + glPopMatrix(); + + glPopMatrix(); +#endif +} + + +static void +idle(void) +{ + static double t0 = -1.; + double dt, t = eglutGet(EGLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + + angle += 70.0 * dt; /* 70 degrees per second */ + angle = fmod(angle, 360.0); /* prevents eventual overflow */ + + eglutPostRedisplay(); +} + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + + +static void +init(void) +{ + static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 }; + static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 }; + static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 }; + static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + + /* make the gears */ + gear1 = glGenLists(1); + glNewList(gear1, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); + gear(1.0, 4.0, 1.0, 20, 0.7); + glEndList(); + + gear2 = glGenLists(1); + glNewList(gear2, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); + gear(0.5, 2.0, 2.0, 10, 0.7); + glEndList(); + + gear3 = glGenLists(1); + glNewList(gear3, GL_COMPILE); + glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); + gear(1.3, 2.0, 0.5, 10, 0.7); + glEndList(); + + glEnable(GL_NORMALIZE); +} + +int +eglut_main(int argc, char *argv[]) +{ + eglutInitWindowSize(600, 600); + eglutInitAPIMask(EGLUT_OPENGL_BIT); + eglutInit(argc, argv); + + eglutCreateWindow("eglgears"); + + eglutIdleFunc(idle); + eglutReshapeFunc(reshape); + eglutDisplayFunc(draw); + + init(); + glDrawBuffer(GL_BACK); + + eglutMainLoop(); + + return 0; +} diff --git a/repos/libports/src/test/mesa_demo/eglgears/target.mk b/repos/libports/src/test/mesa_demo/eglgears/target.mk new file mode 100644 index 0000000000..b6decb40e5 --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglgears/target.mk @@ -0,0 +1,12 @@ +TARGET = gears +LIBS = libm libc egl mesa + +SRC_C = eglgears.c eglut.c +SRC_CC = eglut_genode.cc +LD_OPT = --export-dynamic + +INC_DIR += $(REP_DIR)/src/lib/mesa/include \ + $(PRG_DIR)/../eglut + +vpath %.c $(PRG_DIR)/../eglut +vpath %.cc $(PRG_DIR)/../eglut diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut.c b/repos/libports/src/test/mesa_demo/eglut/eglut.c new file mode 100644 index 0000000000..fa79ae30ea --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglut/eglut.c @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include +#include +#include +#include + +#include "EGL/egl.h" +#include "EGL/eglext.h" + +#include "eglutint.h" + +static struct eglut_state _eglut_state = { + .api_mask = EGLUT_OPENGL_ES1_BIT, + .window_width = 300, + .window_height = 300, + .verbose = 0, + .num_windows = 0, +}; + +struct eglut_state *_eglut = &_eglut_state; + +void +_eglutFatal(char *format, ...) +{ + va_list args; + + va_start(args, format); + + fprintf(stderr, "EGLUT: "); + vfprintf(stderr, format, args); + va_end(args); + + exit(1); +} + +/* return current time (in milliseconds) */ +int +_eglutNow(void) +{ + struct timeval tv; +#ifdef __VMS + (void) gettimeofday(&tv, NULL ); +#else + struct timezone tz; + (void) gettimeofday(&tv, &tz); +#endif + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + +static void +_eglutDestroyWindow(struct eglut_window *win) +{ + if (_eglut->surface_type != EGL_PBUFFER_BIT) + eglDestroySurface(_eglut->dpy, win->surface); + + _eglutNativeFiniWindow(win); + + eglDestroyContext(_eglut->dpy, win->context); +} + +static EGLConfig +_eglutChooseConfig(void) +{ + EGLConfig config; + EGLint config_attribs[32]; + EGLint renderable_type, num_configs, i; + + i = 0; + config_attribs[i++] = EGL_RED_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_GREEN_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_BLUE_SIZE; + config_attribs[i++] = 1; + config_attribs[i++] = EGL_DEPTH_SIZE; + config_attribs[i++] = 1; + + config_attribs[i++] = EGL_SURFACE_TYPE; + config_attribs[i++] = _eglut->surface_type; + + config_attribs[i++] = EGL_RENDERABLE_TYPE; + renderable_type = 0x0; + if (_eglut->api_mask & EGLUT_OPENGL_BIT) + renderable_type |= EGL_OPENGL_BIT; + if (_eglut->api_mask & EGLUT_OPENGL_ES1_BIT) + renderable_type |= EGL_OPENGL_ES_BIT; + if (_eglut->api_mask & EGLUT_OPENGL_ES2_BIT) + renderable_type |= EGL_OPENGL_ES2_BIT; + if (_eglut->api_mask & EGLUT_OPENVG_BIT) + renderable_type |= EGL_OPENVG_BIT; + config_attribs[i++] = renderable_type; + + config_attribs[i] = EGL_NONE; + + if (!eglChooseConfig(_eglut->dpy, + config_attribs, &config, 1, &num_configs) || !num_configs) + _eglutFatal("failed to choose a config"); + + return config; +} + +static struct eglut_window * +_eglutCreateWindow(const char *title, int x, int y, int w, int h) +{ + struct eglut_window *win; + EGLint context_attribs[4]; + EGLint api, i; + + win = calloc(1, sizeof(*win)); + if (!win) + _eglutFatal("failed to allocate window"); + + win->config = _eglutChooseConfig(); + + i = 0; + context_attribs[i] = EGL_NONE; + + /* multiple APIs? */ + + api = EGL_OPENGL_ES_API; + if (_eglut->api_mask & EGLUT_OPENGL_BIT) { + api = EGL_OPENGL_API; + } + else if (_eglut->api_mask & EGLUT_OPENVG_BIT) { + api = EGL_OPENVG_API; + } + else if (_eglut->api_mask & EGLUT_OPENGL_ES2_BIT) { + context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION; + context_attribs[i++] = 2; + } + + context_attribs[i] = EGL_NONE; + + eglBindAPI(api); + win->context = eglCreateContext(_eglut->dpy, + win->config, EGL_NO_CONTEXT, context_attribs); + if (!win->context) + _eglutFatal("failed to create context"); + + _eglutNativeInitWindow(win, title, x, y, w, h); + switch (_eglut->surface_type) { + case EGL_WINDOW_BIT: + win->surface = eglCreateWindowSurface(_eglut->dpy, + win->config, win->native.u.window, NULL); + break; + case EGL_PIXMAP_BIT: + win->surface = eglCreatePixmapSurface(_eglut->dpy, + win->config, win->native.u.pixmap, NULL); + break; + case EGL_PBUFFER_BIT: + win->surface = win->native.u.surface; + break; + default: + break; + } + if (win->surface == EGL_NO_SURFACE) + _eglutFatal("failed to create surface"); + + return win; +} + +void +eglutInitAPIMask(int mask) +{ + _eglut->api_mask = mask; +} + +void +eglutInitWindowSize(int width, int height) +{ + _eglut->window_width = width; + _eglut->window_height = height; +} + +void +eglutInit(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) + _eglut->display_name = argv[++i]; + else if (strcmp(argv[i], "-info") == 0) { + _eglut->verbose = 1; + } + } + + _eglutNativeInitDisplay(); + _eglut->dpy = eglGetDisplay(_eglut->native_dpy); + + if (!eglInitialize(_eglut->dpy, &_eglut->major, &_eglut->minor)) + _eglutFatal("failed to initialize EGL display"); + + _eglut->init_time = _eglutNow(); + + printf("EGL_VERSION = %s\n", eglQueryString(_eglut->dpy, EGL_VERSION)); + if (_eglut->verbose) { + printf("EGL_VENDOR = %s\n", eglQueryString(_eglut->dpy, EGL_VENDOR)); + printf("EGL_EXTENSIONS = %s\n", + eglQueryString(_eglut->dpy, EGL_EXTENSIONS)); + printf("EGL_CLIENT_APIS = %s\n", + eglQueryString(_eglut->dpy, EGL_CLIENT_APIS)); + } +} + +int +eglutGet(int state) +{ + int val; + + switch (state) { + case EGLUT_ELAPSED_TIME: + val = _eglutNow() - _eglut->init_time; + break; + default: + val = -1; + break; + } + + return val; +} + +void +eglutIdleFunc(EGLUTidleCB func) +{ + _eglut->idle_cb = func; +} + +void +eglutPostRedisplay(void) +{ + _eglut->redisplay = 1; +} + +void +eglutMainLoop(void) +{ + struct eglut_window *win = _eglut->current; + + if (!win) + _eglutFatal("no window is created\n"); + + if (win->reshape_cb) + win->reshape_cb(win->native.width, win->native.height); + + _eglutNativeEventLoop(); +} + +static void +_eglutFini(void) +{ + eglTerminate(_eglut->dpy); + _eglutNativeFiniDisplay(); +} + +void +eglutDestroyWindow(int win) +{ + struct eglut_window *window = _eglut->current; + + if (window->index != win) + return; + + eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + _eglutDestroyWindow(_eglut->current); +} + +static void +_eglutDefaultKeyboard(unsigned char key) +{ + if (key == 27) { + if (_eglut->current) + eglutDestroyWindow(_eglut->current->index); + _eglutFini(); + + exit(0); + } +} + +int +eglutCreateWindow(const char *title) +{ + struct eglut_window *win; + + win = _eglutCreateWindow(title, 0, 0, + _eglut->window_width, _eglut->window_height); + + win->index = _eglut->num_windows++; + win->reshape_cb = NULL; + win->display_cb = NULL; + win->keyboard_cb = _eglutDefaultKeyboard; + win->special_cb = NULL; + + if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface, win->context)) + _eglutFatal("failed to make window current"); + _eglut->current = win; + + return win->index; +} + +int +eglutGetWindowWidth(void) +{ + struct eglut_window *win = _eglut->current; + return win->native.width; +} + +int +eglutGetWindowHeight(void) +{ + struct eglut_window *win = _eglut->current; + return win->native.height; +} + +void +eglutDisplayFunc(EGLUTdisplayCB func) +{ + struct eglut_window *win = _eglut->current; + win->display_cb = func; + +} + +void +eglutReshapeFunc(EGLUTreshapeCB func) +{ + struct eglut_window *win = _eglut->current; + win->reshape_cb = func; +} + +void +eglutKeyboardFunc(EGLUTkeyboardCB func) +{ + struct eglut_window *win = _eglut->current; + win->keyboard_cb = func; +} + +void +eglutSpecialFunc(EGLUTspecialCB func) +{ + struct eglut_window *win = _eglut->current; + win->special_cb = func; +} diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut.h b/repos/libports/src/test/mesa_demo/eglut/eglut.h new file mode 100644 index 0000000000..7c07b6d8d9 --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglut/eglut.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef EGLUT_H +#define EGLUT_H + +/* used by eglutInitAPIMask */ +enum { + EGLUT_OPENGL_BIT = 0x1, + EGLUT_OPENGL_ES1_BIT = 0x2, + EGLUT_OPENGL_ES2_BIT = 0x4, + EGLUT_OPENVG_BIT = 0x8 +}; + +/* used by EGLUTspecialCB */ +enum { + /* function keys */ + EGLUT_KEY_F1, + EGLUT_KEY_F2, + EGLUT_KEY_F3, + EGLUT_KEY_F4, + EGLUT_KEY_F5, + EGLUT_KEY_F6, + EGLUT_KEY_F7, + EGLUT_KEY_F8, + EGLUT_KEY_F9, + EGLUT_KEY_F10, + EGLUT_KEY_F11, + EGLUT_KEY_F12, + + /* directional keys */ + EGLUT_KEY_LEFT, + EGLUT_KEY_UP, + EGLUT_KEY_RIGHT, + EGLUT_KEY_DOWN, +}; + +/* used by eglutGet */ +enum { + EGLUT_ELAPSED_TIME +}; + +typedef void (*EGLUTidleCB)(void); +typedef void (*EGLUTreshapeCB)(int, int); +typedef void (*EGLUTdisplayCB)(void); +typedef void (*EGLUTkeyboardCB)(unsigned char); +typedef void (*EGLUTspecialCB)(int); + +void eglutInitAPIMask(int mask); +void eglutInitWindowSize(int width, int height); +void eglutInit(int argc, char **argv); + +int eglutGet(int state); + +void eglutIdleFunc(EGLUTidleCB func); +void eglutPostRedisplay(void); + +void eglutMainLoop(void); + +int eglutCreateWindow(const char *title); +void eglutDestroyWindow(int win); + +int eglutGetWindowWidth(void); +int eglutGetWindowHeight(void); + +void eglutDisplayFunc(EGLUTdisplayCB func); +void eglutReshapeFunc(EGLUTreshapeCB func); +void eglutKeyboardFunc(EGLUTkeyboardCB func); +void eglutSpecialFunc(EGLUTspecialCB func); + +#endif /* EGLUT_H */ diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc new file mode 100644 index 0000000000..2b288e0e99 --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc @@ -0,0 +1,143 @@ +/** + * \brief eglut bindings for Genode Mesa demos + * \author Sebastian Sumpf + * \date 2017-08-17 + */ + +/* + * Copyright (C) Genode Labs GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +extern "C" { +#include "eglutint.h" +#include +} + +#include + +static bool initialized = false; +Genode::Env *genode_env; + + +struct Eglut_env +{ + Libc::Env &env; + Genode::Heap heap { env.ram(), env.rm() }; + + Eglut_env(Libc::Env &env) : env(env) { } +}; + +Genode::Constructible eglut_env; + +void _eglutNativeInitDisplay() +{ + _eglut->surface_type = EGL_WINDOW_BIT; +} + +void Window::sync_handler() +{ + struct eglut_window *win =_eglut->current; + + if (_eglut->idle_cb) + _eglut->idle_cb(); + + + if (win->display_cb) + win->display_cb(); + + if (initialized) { + eglSwapBuffers(_eglut->dpy, win->surface); + + //XXX: required till vsync interrupt + eglWaitClient(); + } +} + + +void Window::mode_handler() +{ + if (!framebuffer.is_constructed()) + return; + + initialized = true; + Framebuffer::Mode mode = framebuffer->mode(); + + eglut_window *win = _eglut->current; + if (win) { + win->native.width = mode.width(); + win->native.height = mode.height(); + + if (win->reshape_cb) + win->reshape_cb(win->native.width, win->native.height); + } + + update(); +} + + +void _eglutNativeFiniDisplay(void) +{ + PDBG("not implemented"); +} + + +void _eglutNativeInitWindow(struct eglut_window *win, const char *title, + int x, int y, int w, int h) +{ + Genode_egl_window *native = new (eglut_env->heap) Window(eglut_env->env, w, h); + win->native.u.window = native; + win->native.width = w; + win->native.height = h; +} + + +void _eglutNativeFiniWindow(struct eglut_window *win) +{ + PDBG("not implemented"); +} + + +void _eglutNativeEventLoop() +{ + while (true) { + select(0, nullptr, nullptr, nullptr, nullptr); + } +} + + +/* + * 'eglut_main' will be called instead of 'main' by component initialization + */ +extern "C" int eglut_main(int argc, char *argv[]); + + +void Libc::Component::construct(Libc::Env &env) +{ + eglut_env.construct(env); + + genode_env = &env; + + Libc::with_libc([] () { eglut_main(1, nullptr); }); +} diff --git a/repos/libports/src/test/mesa_demo/eglut/eglutint.h b/repos/libports/src/test/mesa_demo/eglut/eglutint.h new file mode 100644 index 0000000000..a4520b0e0b --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglut/eglutint.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _EGLUTINT_H_ +#define _EGLUTINT_H_ + +#include "EGL/egl.h" +#include "eglut.h" + +struct eglut_window { + EGLConfig config; + EGLContext context; + + /* initialized by native display */ + struct { + union { + EGLNativeWindowType window; + EGLNativePixmapType pixmap; + EGLSurface surface; /* pbuffer or screen surface */ + } u; + int width, height; + } native; + + EGLSurface surface; + + int index; + + EGLUTreshapeCB reshape_cb; + EGLUTdisplayCB display_cb; + EGLUTkeyboardCB keyboard_cb; + EGLUTspecialCB special_cb; +}; + +struct eglut_state { + int api_mask; + int window_width, window_height; + const char *display_name; + int verbose; + int init_time; + + EGLUTidleCB idle_cb; + + int num_windows; + + /* initialized by native display */ + EGLNativeDisplayType native_dpy; + EGLint surface_type; + + EGLDisplay dpy; + EGLint major, minor; + + struct eglut_window *current; + + int redisplay; +}; + +extern struct eglut_state *_eglut; + +void +_eglutFatal(char *format, ...); + +int +_eglutNow(void); + +void +_eglutNativeInitDisplay(void); + +void +_eglutNativeFiniDisplay(void); + +void +_eglutNativeInitWindow(struct eglut_window *win, const char *title, + int x, int y, int w, int h); + +void +_eglutNativeFiniWindow(struct eglut_window *win); + +void +_eglutNativeEventLoop(void); + +#endif /* _EGLUTINT_H_ */ diff --git a/repos/libports/src/test/mesa_demo/eglut/gl_wrap.h b/repos/libports/src/test/mesa_demo/eglut/gl_wrap.h new file mode 100644 index 0000000000..2bf4c4e170 --- /dev/null +++ b/repos/libports/src/test/mesa_demo/eglut/gl_wrap.h @@ -0,0 +1,15 @@ +#ifndef GL_WRAP_H +#define GL_WRAP_H + +#ifdef __APPLE__ +# include +# include +#else +# include +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#endif /* ! GL_WRAP_H */ diff --git a/repos/ports/run/arora.run b/repos/ports/run/arora.run index 44822a6b5d..324400861b 100644 --- a/repos/ports/run/arora.run +++ b/repos/ports/run/arora.run @@ -10,6 +10,7 @@ append build_components [qt5_build_components feature] append build_components { server/clipboard server/loader server/tar_rom server/nit_fb app/launchpad test/nitpicker + lib/mesa/swrast lib/vfs/jitterentropy app/arora } @@ -100,6 +101,7 @@ append config { + @@ -135,8 +137,12 @@ append boot_modules { # Qt5-specific boot modules # append boot_modules { - gallium.lib.so + egl.lib.so + egl_swrast.lib.so + expat.lib.so + glapi.lib.so icu.lib.so + mesa.lib.so pcre16.lib.so pthread.lib.so qt5_angle.lib.so