summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-21 16:07:01 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-11-21 16:07:01 +0900
commit4b804ef94306fe237899aa9ebc5b031631aea2c7 (patch)
treebe217cbb302360e467128591bc3d702072bf071d
This is a test app for Evas GL.
Some things don't work on PC
-rw-r--r--CMakeLists.txt60
-rw-r--r--cmake/EDbus/EDbusConfig.cmake66
-rw-r--r--cmake/EDbus/EDbusConfigVersion.cmake11
-rw-r--r--cmake/Ecore/EcoreConfig.cmake66
-rw-r--r--cmake/Ecore/EcoreConfigVersion.cmake11
-rw-r--r--cmake/Efreet/EfreetConfig.cmake32
-rw-r--r--cmake/Efreet/EfreetConfigVersion.cmake11
-rw-r--r--cmake/Eina/EinaConfig.cmake32
-rw-r--r--cmake/Eina/EinaConfigVersion.cmake11
-rw-r--r--cmake/Elementary/ElementaryConfig.cmake32
-rw-r--r--cmake/Elementary/ElementaryConfigVersion.cmake11
-rw-r--r--cmake/Evas/EvasConfig.cmake32
-rw-r--r--cmake/Evas/EvasConfigVersion.cmake11
-rwxr-xr-xcompile.sh10
-rw-r--r--evasgl_test.h114
-rw-r--r--glcube.c520
-rw-r--r--glesgears.c412
-rw-r--r--glview.c373
-rw-r--r--main.c420
-rwxr-xr-xpackage.sh13
-rw-r--r--packaging/evgltest.spec73
-rw-r--r--tests.c52
22 files changed, 2373 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d58ee61
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,60 @@
1project(evasgl_test)
2cmake_minimum_required(VERSION 2.8)
3aux_source_directory(. SRC_LIST)
4
5set(CMAKE_SKIP_BUILD_RPATH TRUE)
6set(CMAKE_BUILD_TYPE Debug)
7set(Eina_DIR ${CMAKE_SOURCE_DIR}/cmake/Eina)
8set(Ecore_DIR ${CMAKE_SOURCE_DIR}/cmake/Ecore)
9set(Evas_DIR ${CMAKE_SOURCE_DIR}/cmake/Evas)
10set(EDbus_DIR ${CMAKE_SOURCE_DIR}/cmake/EDbus)
11set(Elementary_DIR ${CMAKE_SOURCE_DIR}/cmake/Elementary)
12set(Efreet_DIR ${CMAKE_SOURCE_DIR}/cmake/Efreet)
13
14
15find_package(Eina REQUIRED)
16find_package(Evas REQUIRED)
17find_package(Ecore REQUIRED)
18find_package(Ecore COMPONENTS Evas)
19find_package(Ecore COMPONENTS X)
20find_package(EDbus REQUIRED)
21find_package(Elementary REQUIRED)
22find_package(Efreet REQUIRED)
23
24set(EO_FOUND "FALSE")
25find_package(Eo)
26if(${EO_FOUND} STREQUAL "FALSE")
27 set(EO_LIBRARIES "")
28endif(${EO_FOUND} STREQUAL "FALSE")
29
30add_definitions(-Wall -Wextra)
31
32include_directories(
33 ${EINA_INCLUDE_DIRS}
34 ${ECORE_INCLUDE_DIRS}
35 ${EVAS_INCLUDE_DIRS}
36 ${ECORE_EVAS_INCLUDE_DIRS}
37 ${ECORE_X_INCLUDE_DIRS}
38 ${ELEMENTARY_INCLUDE_DIRS}
39 ${EO_INCLUDE_DIRS}
40 ${EDBUS_INCLUDE_DIRS}
41 ${EFREET_INCLUDE_DIRS}
42 )
43
44add_executable(${PROJECT_NAME} ${SRC_LIST})
45target_link_libraries(${PROJECT_NAME}
46 ${EINA_LIBRARIES}
47 ${ECORE_LIBRARIES}
48 ${EVAS_LIBRARIES}
49 ${ECORE_EVAS_LIBRARIES}
50 ${ECORE_X_LIBRARIES}
51 ${ELEMENTARY_LIBRARIES}
52 ${EO_LIBRARIES}
53 -lm -lX11
54 )
55
56add_definitions(-fpie)
57# C99 doesn't compile, wtf. -std=gnu99
58set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -pie)
59
60install(TARGETS ${PROJECT_NAME} DESTINATION bin)
diff --git a/cmake/EDbus/EDbusConfig.cmake b/cmake/EDbus/EDbusConfig.cmake
new file mode 100644
index 0000000..844cef3
--- /dev/null
+++ b/cmake/EDbus/EDbusConfig.cmake
@@ -0,0 +1,66 @@
1# - Try to find edbus
2# Once done this will define
3#
4# EDBUS_FOUND - System has edbus
5# EDBUS_INCLUDE_DIRS - The edbus include directories
6# EDBUS_LIBRARIES - The libraries needed to use edbus
7# EDBUS_DEFINITIONS - Compiler switches required for using edbus
8#
9# When the COMPONENTS keyword was passed to find_package(),
10# the following variables are defined for additional EDbus modules
11# such as Evas, X, Imf, Imf_Evas.
12#
13# EDBUS_*_FOUND - System has edbus *
14# EDBUS_*_INCLUDE_DIRS - The edbus include directories
15# EDBUS_*_LIBRARIES - The libraries needed to use edbus
16# EDBUS_*_DEFINITIONS - Compiler switches required for using edbus * module.
17
18set(MY_PKG edbus)
19
20find_package(PkgConfig)
21if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
22 # "QUIET" was introduced in 2.8.2
23 set(_QUIET QUIET)
24endif ()
25pkg_check_modules(PC_LIBEDBUS ${_QUIET} ${MY_PKG})
26
27find_library(EDBUS_LIBRARY
28 NAMES ${PC_LIBEDBUS_LIBRARIES}
29 HINTS ${PC_LIBEDBUS_LIBDIR} ${PC_LIBEDBUS_LIBRARY_DIRS} )
30
31set(EDBUS_DEFINITIONS ${PC_LIBEDBUS_CFLAGS_OTHER})
32set(EDBUS_LIBRARIES ${EDBUS_LIBRARY})
33set(EDBUS_INCLUDE_DIRS ${PC_LIBEDBUS_INCLUDE_DIRS})
34
35include(FindPackageHandleStandardArgs)
36# handle the QUIETLY and REQUIRED arguments and set EDBUS_FOUND to TRUE
37# if all listed variables are TRUE
38find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
39 EDBUS_LIBRARIES EDBUS_INCLUDE_DIRS)
40
41mark_as_advanced(EDBUS_INCLUDE_DIRS EDBUS_LIBRARY EDBUS_LIBRARIES EDBUS_DEFINITIONS)
42
43if (EDbus_FIND_COMPONENTS)
44 foreach(_component ${EDbus_FIND_COMPONENTS})
45 string(TOUPPER ${_component} _COMPONENT)
46 string(TOLOWER ${_component} _component)
47 string(REGEX REPLACE "_" "-" _MODULE_PKGNAME "edbus-${_component}")
48
49 pkg_check_modules(PC_LIBEDBUS_${_COMPONENT} ${_QUIET} ${_MODULE_PKGNAME})
50
51 find_library(EDBUS_${_COMPONENT}_LIBRARY
52 NAMES ${PC_LIBEDBUS_${_COMPONENT}_LIBRARIES}
53 HINTS ${PC_LIBEDBUS_${_COMPONENT}_LIBDIR}
54 ${PC_LIBEDBUS_${_COMPONENT}_LIBRARY_DIRS})
55
56 set(EDBUS_${_COMPONENT}_DEFINITIONS ${PC_LIBEDBUS_${_COMPONENT}_CFLAGS_OTHER})
57 set(EDBUS_${_COMPONENT}_LIBRARIES ${EDBUS_${_COMPONENT}_LIBRARY})
58 set(EDBUS_${_COMPONENT}_INCLUDE_DIRS ${PC_LIBEDBUS_${_COMPONENT}_INCLUDE_DIRS})
59
60 include(FindPackageHandleStandardArgs)
61 # handle the QUIETLY and REQUIRED arguments and set EDBUS_*_FOUND to TRUE
62 # if all listed variables are TRUE
63 find_package_handle_standard_args(edbus_${_component} DEFAULT_MSG
64 EDBUS_${_COMPONENT}_LIBRARIES EDBUS_${_COMPONENT}_INCLUDE_DIRS)
65 endforeach(_component)
66endif(EDbus_FIND_COMPONENTS)
diff --git a/cmake/EDbus/EDbusConfigVersion.cmake b/cmake/EDbus/EDbusConfigVersion.cmake
new file mode 100644
index 0000000..9891495
--- /dev/null
+++ b/cmake/EDbus/EDbusConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.26707")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/cmake/Ecore/EcoreConfig.cmake b/cmake/Ecore/EcoreConfig.cmake
new file mode 100644
index 0000000..dc84ec4
--- /dev/null
+++ b/cmake/Ecore/EcoreConfig.cmake
@@ -0,0 +1,66 @@
1# - Try to find ecore
2# Once done this will define
3#
4# ECORE_FOUND - System has ecore
5# ECORE_INCLUDE_DIRS - The ecore include directories
6# ECORE_LIBRARIES - The libraries needed to use ecore
7# ECORE_DEFINITIONS - Compiler switches required for using ecore
8#
9# When the COMPONENTS keyword was passed to find_package(),
10# the following variables are defined for additional Ecore modules
11# such as Evas, X, Imf, Imf_Evas.
12#
13# ECORE_*_FOUND - System has ecore *
14# ECORE_*_INCLUDE_DIRS - The ecore include directories
15# ECORE_*_LIBRARIES - The libraries needed to use ecore
16# ECORE_*_DEFINITIONS - Compiler switches required for using ecore * module.
17
18set(MY_PKG ecore)
19
20find_package(PkgConfig)
21if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
22 # "QUIET" was introduced in 2.8.2
23 set(_QUIET QUIET)
24endif ()
25pkg_check_modules(PC_LIBECORE ${_QUIET} ${MY_PKG})
26
27find_library(ECORE_LIBRARY
28 NAMES ${PC_LIBECORE_LIBRARIES}
29 HINTS ${PC_LIBECORE_LIBDIR} ${PC_LIBECORE_LIBRARY_DIRS} )
30
31set(ECORE_DEFINITIONS ${PC_LIBECORE_CFLAGS_OTHER})
32set(ECORE_LIBRARIES ${ECORE_LIBRARY})
33set(ECORE_INCLUDE_DIRS ${PC_LIBECORE_INCLUDE_DIRS})
34
35include(FindPackageHandleStandardArgs)
36# handle the QUIETLY and REQUIRED arguments and set ECORE_FOUND to TRUE
37# if all listed variables are TRUE
38find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
39 ECORE_LIBRARIES ECORE_INCLUDE_DIRS)
40
41mark_as_advanced(ECORE_INCLUDE_DIRS ECORE_LIBRARY ECORE_LIBRARIES ECORE_DEFINITIONS)
42
43if (Ecore_FIND_COMPONENTS)
44 foreach(_component ${Ecore_FIND_COMPONENTS})
45 string(TOUPPER ${_component} _COMPONENT)
46 string(TOLOWER ${_component} _component)
47 string(REGEX REPLACE "_" "-" _MODULE_PKGNAME "ecore-${_component}")
48
49 pkg_check_modules(PC_LIBECORE_${_COMPONENT} ${_QUIET} ${_MODULE_PKGNAME})
50
51 find_library(ECORE_${_COMPONENT}_LIBRARY
52 NAMES ${PC_LIBECORE_${_COMPONENT}_LIBRARIES}
53 HINTS ${PC_LIBECORE_${_COMPONENT}_LIBDIR}
54 ${PC_LIBECORE_${_COMPONENT}_LIBRARY_DIRS})
55
56 set(ECORE_${_COMPONENT}_DEFINITIONS ${PC_LIBECORE_${_COMPONENT}_CFLAGS_OTHER})
57 set(ECORE_${_COMPONENT}_LIBRARIES ${ECORE_${_COMPONENT}_LIBRARY})
58 set(ECORE_${_COMPONENT}_INCLUDE_DIRS ${PC_LIBECORE_${_COMPONENT}_INCLUDE_DIRS})
59
60 include(FindPackageHandleStandardArgs)
61 # handle the QUIETLY and REQUIRED arguments and set ECORE_*_FOUND to TRUE
62 # if all listed variables are TRUE
63 find_package_handle_standard_args(ecore_${_component} DEFAULT_MSG
64 ECORE_${_COMPONENT}_LIBRARIES ECORE_${_COMPONENT}_INCLUDE_DIRS)
65 endforeach(_component)
66endif(Ecore_FIND_COMPONENTS)
diff --git a/cmake/Ecore/EcoreConfigVersion.cmake b/cmake/Ecore/EcoreConfigVersion.cmake
new file mode 100644
index 0000000..9891495
--- /dev/null
+++ b/cmake/Ecore/EcoreConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.26707")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/cmake/Efreet/EfreetConfig.cmake b/cmake/Efreet/EfreetConfig.cmake
new file mode 100644
index 0000000..cb39d97
--- /dev/null
+++ b/cmake/Efreet/EfreetConfig.cmake
@@ -0,0 +1,32 @@
1# - Try to find efreet
2# Once done this will define
3# EFREET_FOUND - System has efreet
4# EFREET_INCLUDE_DIRS - The efreet include directories
5# EFREET_LIBRARIES - The libraries needed to use efreet
6# EFREET_DEFINITIONS - Compiler switches required for using efreet
7
8set(MY_PKG efreet)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBEFREET ${_QUIET} ${MY_PKG})
16
17find_library(EFREET_LIBRARY
18 NAMES ${PC_LIBEFREET_LIBRARIES}
19 HINTS ${PC_LIBEFREET_LIBDIR} ${PC_LIBEFREET_LIBRARY_DIRS} )
20
21set(EFREET_DEFINITIONS ${PC_LIBEFREET_CFLAGS_OTHER})
22set(EFREET_LIBRARIES ${EFREET_LIBRARY})
23set(EFREET_INCLUDE_DIRS ${PC_LIBEFREET_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set EFREET_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 EFREET_LIBRARIES EFREET_INCLUDE_DIRS)
30
31mark_as_advanced(EFREET_INCLUDE_DIRS EFREET_LIBRARY EFREET_LIBRARIES EFREET_DEFINITIONS)
32
diff --git a/cmake/Efreet/EfreetConfigVersion.cmake b/cmake/Efreet/EfreetConfigVersion.cmake
new file mode 100644
index 0000000..9891495
--- /dev/null
+++ b/cmake/Efreet/EfreetConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.26707")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/cmake/Eina/EinaConfig.cmake b/cmake/Eina/EinaConfig.cmake
new file mode 100644
index 0000000..5fa8a5a
--- /dev/null
+++ b/cmake/Eina/EinaConfig.cmake
@@ -0,0 +1,32 @@
1# - Try to find eina
2# Once done this will define
3# EINA_FOUND - System has eina
4# EINA_INCLUDE_DIRS - The eina include directories
5# EINA_LIBRARIES - The libraries needed to use eina
6# EINA_DEFINITIONS - Compiler switches required for using eina
7
8set(MY_PKG eina)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBEINA ${_QUIET} ${MY_PKG})
16
17find_library(EINA_LIBRARY
18 NAMES ${PC_LIBEINA_LIBRARIES}
19 HINTS ${PC_LIBEINA_LIBDIR} ${PC_LIBEINA_LIBRARY_DIRS} )
20
21set(EINA_DEFINITIONS ${PC_LIBEINA_CFLAGS_OTHER})
22set(EINA_LIBRARIES ${EINA_LIBRARY})
23set(EINA_INCLUDE_DIRS ${PC_LIBEINA_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 EINA_LIBRARIES EINA_INCLUDE_DIRS)
30
31mark_as_advanced(EINA_INCLUDE_DIRS EINA_LIBRARY EINA_LIBRARIES EINA_DEFINITIONS)
32
diff --git a/cmake/Eina/EinaConfigVersion.cmake b/cmake/Eina/EinaConfigVersion.cmake
new file mode 100644
index 0000000..9891495
--- /dev/null
+++ b/cmake/Eina/EinaConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.26707")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/cmake/Elementary/ElementaryConfig.cmake b/cmake/Elementary/ElementaryConfig.cmake
new file mode 100644
index 0000000..e41759d
--- /dev/null
+++ b/cmake/Elementary/ElementaryConfig.cmake
@@ -0,0 +1,32 @@
1# - Try to find elementary
2# Once done this will define
3# ELEMENTARY_FOUND - System has elementary
4# ELEMENTARY_INCLUDE_DIRS - The elementary include directories
5# ELEMENTARY_LIBRARIES - The libraries needed to use elementary
6# ELEMENTARY_DEFINITIONS - Compiler switches required for using elementary
7
8set(MY_PKG elementary)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBELEMENTARY ${_QUIET} ${MY_PKG})
16
17find_library(ELEMENTARY_LIBRARY
18 NAMES ${PC_LIBELEMENTARY_LIBRARIES}
19 HINTS ${PC_LIBELEMENTARY_LIBDIR} ${PC_LIBELEMENTARY_LIBRARY_DIRS} )
20
21set(ELEMENTARY_DEFINITIONS ${PC_LIBELEMENTARY_CFLAGS_OTHER})
22set(ELEMENTARY_LIBRARIES ${ELEMENTARY_LIBRARY})
23set(ELEMENTARY_INCLUDE_DIRS ${PC_LIBELEMENTARY_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set ELEMENTARY_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 ELEMENTARY_LIBRARIES ELEMENTARY_INCLUDE_DIRS)
30
31mark_as_advanced(ELEMENTARY_INCLUDE_DIRS ELEMENTARY_LIBRARY ELEMENTARY_LIBRARIES ELEMENTARY_DEFINITIONS)
32
diff --git a/cmake/Elementary/ElementaryConfigVersion.cmake b/cmake/Elementary/ElementaryConfigVersion.cmake
new file mode 100644
index 0000000..5c41034
--- /dev/null
+++ b/cmake/Elementary/ElementaryConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.10306")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/cmake/Evas/EvasConfig.cmake b/cmake/Evas/EvasConfig.cmake
new file mode 100644
index 0000000..11510f1
--- /dev/null
+++ b/cmake/Evas/EvasConfig.cmake
@@ -0,0 +1,32 @@
1# - Try to find evas
2# Once done this will define
3# EVAS_FOUND - System has evas
4# EVAS_INCLUDE_DIRS - The evas include directories
5# EVAS_LIBRARIES - The libraries needed to use evas
6# EVAS_DEFINITIONS - Compiler switches required for using evas
7
8set(MY_PKG evas)
9
10find_package(PkgConfig)
11if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
12 # "QUIET" was introduced in 2.8.2
13 set(_QUIET QUIET)
14endif ()
15pkg_check_modules(PC_LIBEVAS ${_QUIET} ${MY_PKG})
16
17find_library(EVAS_LIBRARY
18 NAMES ${PC_LIBEVAS_LIBRARIES}
19 HINTS ${PC_LIBEVAS_LIBDIR} ${PC_LIBEVAS_LIBRARY_DIRS} )
20
21set(EVAS_DEFINITIONS ${PC_LIBEVAS_CFLAGS_OTHER})
22set(EVAS_LIBRARIES ${EVAS_LIBRARY})
23set(EVAS_INCLUDE_DIRS ${PC_LIBEVAS_INCLUDE_DIRS})
24
25include(FindPackageHandleStandardArgs)
26# handle the QUIETLY and REQUIRED arguments and set EVAS_FOUND to TRUE
27# if all listed variables are TRUE
28find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
29 EVAS_LIBRARIES EVAS_INCLUDE_DIRS)
30
31mark_as_advanced(EVAS_INCLUDE_DIRS EVAS_LIBRARY EVAS_LIBRARIES EVAS_DEFINITIONS)
32
diff --git a/cmake/Evas/EvasConfigVersion.cmake b/cmake/Evas/EvasConfigVersion.cmake
new file mode 100644
index 0000000..9891495
--- /dev/null
+++ b/cmake/Evas/EvasConfigVersion.cmake
@@ -0,0 +1,11 @@
1set(PACKAGE_VERSION "1.10.99.26707")
2
3# Check whether the requested PACKAGE_FIND_VERSION is compatible
4if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6else ()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif ()
11endif ()
diff --git a/compile.sh b/compile.sh
new file mode 100755
index 0000000..0cecccc
--- /dev/null
+++ b/compile.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3export PKG_CONFIG_PATH=/opt/efl17/lib/pkgconfig
4
5cd `dirname $0` || exit 1
6mkdir -p build
7cd build
8cmake .. || exit 1
9make
10
diff --git a/evasgl_test.h b/evasgl_test.h
new file mode 100644
index 0000000..1c8f57a
--- /dev/null
+++ b/evasgl_test.h
@@ -0,0 +1,114 @@
1#ifndef EVASGL_TEST_H
2#define EVASGL_TEST_H
3
4#include <Eina.h>
5
6#if (EINA_VERSION_MAJOR > 1) || (EINA_VERSION_MINOR >= 12)
7# include <Efl_Config.h>
8# if defined(EFL_VERSION_MINOR)
9# define EFL_EO_API_SUPPORT 1
10# define EFL_BETA_API_SUPPORT 1
11# endif
12#endif
13
14#include <Evas_GL.h>
15#include <Elementary.h>
16//#include <Elementary_GL_Helpers.h>
17
18#define APPDATA_KEY "AppData"
19
20#define ENABLE_IMAGE_TEST 0
21
22typedef struct _AppData AppData;
23typedef struct _PrivData PrivData;
24
25void init_shaders(AppData *ad);
26void glview_init(AppData *ad);
27void init_vertices(AppData *ad);
28void destroy_context(AppData *ad);
29void draw_gl(AppData *ad, int w, int h, int rotation);
30void win_rotate_cb(AppData *ad);
31void resize_gl(AppData *ad, int w, int h);
32void draw_rectangle(AppData *ad, int w, int h, int rotation, int tex);
33void init_gles1(AppData *ad);
34void destroy_gles1(AppData *ad);
35void run_gears(AppData *ad, int w, int h);
36void resize_gles1(AppData *ad, int w, int h);
37void on_error(const char *func, int line);
38void test_extensions(AppData *ad);
39void title_set(AppData *ad, const char *title);
40
41#define APPDATA_GET(obj) evas_object_data_get(obj, APPDATA_KEY)
42#define GLERR() do { on_error(__FUNCTION__, __LINE__); } while (0)
43
44#ifdef ELEMENTARY_GLVIEW_GLOBAL_DEFINE
45ELEMENTARY_GLVIEW_GLOBAL_DECLARE()
46#define GL()
47#else
48extern Evas_GL_API *__evas_gl_glapi;
49#define ELEMENTARY_GLVIEW_GLOBAL_DEFINE() \
50 Evas_GL_API *__evas_gl_glapi = NULL;
51#define ELEMENTARY_GLVIEW_GLOBAL_USE(glview) \
52 do { __evas_gl_glapi = elm_glview_gl_api_get(glview); } while (0)
53#define GL() __evas_gl_glapi->
54#endif
55
56typedef struct
57{
58 GLfloat pos[3];
59 GLfloat norm[3];
60} vertex_t;
61
62typedef struct
63{
64 vertex_t *vertices;
65 GLshort *indices;
66 GLfloat color[4];
67 int nvertices, nindices;
68 GLuint ibo;
69} gear_t;
70
71struct _AppData
72{
73 PrivData *pd;
74
75 Evas_Object *glview;
76 Evas_GL *evasgl;
77 GLuint vtx_shader[3], fgmt_shader[3], program[3], vbo[4];
78 float xangle, yangle;
79 float view[16];
80 int rotation, view_rotation;
81
82 struct {
83 Evas_GL_Surface *sfc;
84 EvasGLImage img;
85 GLuint tex; // for main compositing
86 GLuint fbo, fbo_tex, depth_stencil_rb; // for rendering
87 int w, h;
88 Eina_Bool rgba : 1;
89 Eina_Bool enabled : 1;
90 } pbuffer;
91
92 struct {
93 int w, h;
94 GLuint fbo, fbo_tex;
95 EvasGLImage *img;
96 Eina_Bool enabled : 1;
97 } evglimg;
98
99 gear_t *gear1, *gear2, *gear3;
100 GLfloat angle;
101 int frames;
102 double st, ct, seconds;
103
104 Eina_Bool direct : 1;
105 Eina_Bool client_side : 1;
106 Eina_Bool enable_depth : 1;
107 Eina_Bool enable_stencil : 1;
108 Eina_Bool transparent : 1;
109 Eina_Bool gles1 : 1;
110 Eina_Bool tizen : 1;
111 Eina_Bool enable_depth_was_auto : 1;
112};
113
114#endif // EVASGL_TEST_H
diff --git a/glcube.c b/glcube.c
new file mode 100644
index 0000000..d993288
--- /dev/null
+++ b/glcube.c
@@ -0,0 +1,520 @@
1// This is only for auto-completion in QtCreator
2#ifdef INCLUDE_OPENGL
3# include <GLES2/gl2.h>
4#endif
5
6// The real includes come here
7#include "evasgl_test.h"
8#include <math.h>
9
10#include "assert.h"
11
12
13/* Define the cube's vertices
14 Each vertex consist of x, y, z, r, g, b */
15const float cube_vertices[] =
16{
17 /* front surface is blue */
18 0.5, 0.5, 0.5, 0.5, 0.5, 1.0,
19 -.5, -.5, 0.5, 0.0, 0.0, 1.0,
20 0.5, -.5, 0.5, 0.3, 0.3, 1.0,
21 0.5, 0.5, 0.5, 0.5, 0.5, 1.0,
22 -.5, 0.5, 0.5, 0.3, 0.3, 1.0,
23 -.5, -.5, 0.5, 0.0, 0.0, 1.0,
24 /* left surface is green */
25 -.5, 0.5, 0.5, 0.5, 1.0, 0.5,
26 -.5, -.5, -.5, 0.0, 1.0, 0.0,
27 -.5, -.5, 0.5, 0.3, 1.0, 0.3,
28 -.5, 0.5, 0.5, 0.5, 1.0, 0.5,
29 -.5, 0.5, -.5, 0.3, 1.0, 0.3,
30 -.5, -.5, -.5, 0.0, 1.0, 0.0,
31 /* top surface is red */
32 -.5, 0.5, 0.5, 1.0, 0.5, 0.5,
33 0.5, 0.5, -.5, 1.0, 0.0, 0.0,
34 -.5, 0.5, -.5, 1.0, 0.3, 0.3,
35 -.5, 0.5, 0.5, 1.0, 0.5, 0.5,
36 0.5, 0.5, 0.5, 1.0, 0.3, 0.3,
37 0.5, 0.5, -.5, 1.0, 0.0, 0.0,
38 /* right surface is yellow */
39 0.5, 0.5, -.5, 1.0, 1.0, 0.7,
40 0.5, -.5, 0.5, 1.0, 1.0, 0.0,
41 0.5, -.5, -.5, 1.0, 1.0, 0.4,
42 0.5, 0.5, -.5, 1.0, 1.0, 0.7,
43 0.5, 0.5, 0.5, 1.0, 1.0, 0.4,
44 0.5, -.5, 0.5, 1.0, 1.0, 0.0,
45 /* back surface is cyan */
46 -.5, 0.5, -.5, 0.0, 0.5, 0.5,
47 0.5, -.5, -.5, 0.0, 1.0, 1.0,
48 -.5, -.5, -.5, 0.0, 0.8, 0.8,
49 -.5, 0.5, -.5, 0.0, 0.5, 0.5,
50 0.5, 0.5, -.5, 0.0, 0.8, 0.8,
51 0.5, -.5, -.5, 0.0, 1.0, 1.0,
52 /* bottom surface is magenta */
53 -.5, -.5, -.5, 0.8, 0.5, 0.8,
54 0.5, -.5, 0.5, 0.8, 0.0, 0.8,
55 -.5, -.5, 0.5, 0.8, 0.3, 0.8,
56 -.5, -.5, -.5, 0.8, 0.5, 0.8,
57 0.5, -.5, -.5, 0.8, 0.3, 0.8,
58 0.5, -.5, 0.5, 0.8, 0.0, 0.8
59};
60
61/* This rect is pretty basic. 3D coords, Z = 0. */
62const float stencil_mask_vertices[] =
63{
64 0.6, 0.4, 0.4,
65 -0.6, -0.4, 0.4,
66 0.6, -0.4, 0.4,
67 0.6, 0.4, 0.4,
68 -0.6, 0.4, 0.4,
69 -0.6, -0.4, 0.4,
70};
71
72const float rectangle_fullscreen_vertices[] =
73{
74 1.0, 1.0, 0.0,
75 -1.0, -1.0, 0.0,
76 1.0, -1.0, 0.0,
77 1.0, 1.0, 0.0,
78 -1.0, 1.0, 0.0,
79 -1.0, -1.0, 0.0
80};
81
82const float texture_vertices[] =
83{
84 1.0, 1.0,
85 0.0, 0.0,
86 1.0, 0.0,
87 1.0, 1.0,
88 0.0, 1.0,
89 0.0, 0.0,
90};
91
92/* Vertext Shader Source */
93static const char vertex_shader[] =
94 "attribute vec4 vPosition;\n"
95 "attribute vec3 inColor;\n"
96 "uniform mat4 mvpMatrix;"
97 "varying vec3 outColor;\n"
98 "void main()\n"
99 "{\n"
100 " outColor = inColor;\n"
101 " gl_Position = mvpMatrix * vPosition;\n"
102 "}\n";
103
104/* Fragment Shader Source */
105static const char fragment_shader[] =
106 "#ifdef GL_ES\n"
107 "precision mediump float;\n"
108 "#endif\n"
109 "varying vec3 outColor;\n"
110 "uniform float alpha;\n"
111 "void main()\n"
112 "{\n"
113 " gl_FragColor = alpha * vec4 (outColor, 1.0);\n"
114 "}\n";
115
116/* Shaders for the stencil test case */
117static const char vertex_stenciltest[] =
118 "attribute vec4 vPosition;\n"
119 "uniform mat4 mvpMatrix;"
120 "void main()\n"
121 "{\n"
122 " gl_Position = mvpMatrix * vPosition;\n"
123 "}\n";
124
125static const char fragment_stenciltest[] =
126 "void main()\n"
127 "{\n"
128 " gl_FragColor = vec4 (1,1,1,1);\n"
129 "}\n";
130
131static const char vertex_texture[] =
132 "attribute vec4 vPosition;\n"
133 "attribute vec2 vTexCoord;\n"
134 "uniform mat4 mvpMatrix;"
135 "varying vec2 texcoord;\n"
136 "void main()\n"
137 "{\n"
138 " gl_Position = mvpMatrix * vPosition;\n"
139 " texcoord = vTexCoord;\n"
140 "}\n";
141
142static const char fragment_texture[] =
143 "#ifdef GL_ES\n"
144 "precision mediump float;\n"
145 "#endif\n"
146 "uniform sampler2D tex;\n"
147 "varying vec2 texcoord;\n"
148 "void main()\n"
149 "{\n"
150 " gl_FragColor = texture2D(tex, texcoord);\n"
151 "}\n";
152
153/* Rotation Operation related functions here... */
154static void
155init_matrix(float matrix[16])
156{
157 matrix[0] = 1.0f;
158 matrix[1] = 0.0f;
159 matrix[2] = 0.0f;
160 matrix[3] = 0.0f;
161
162 matrix[4] = 0.0f;
163 matrix[5] = 1.0f;
164 matrix[6] = 0.0f;
165 matrix[7] = 0.0f;
166
167 matrix[8] = 0.0f;
168 matrix[9] = 0.0f;
169 matrix[10] = 1.0f;
170 matrix[11] = 0.0f;
171
172 matrix[12] = 0.0f;
173 matrix[13] = 0.0f;
174 matrix[14] = 0.0f;
175 matrix[15] = 1.0f;
176}
177
178static void
179multiply_matrix(float matrix[16], const float matrix0[16], const float matrix1[16])
180{
181 int i;
182 int row;
183 int column;
184 float temp[16];
185
186 for (column = 0; column < 4; column++)
187 for (row = 0; row < 4; row++)
188 {
189 temp[column * 4 + row] = 0.0f;
190 for (i = 0; i < 4; i++)
191 temp[column * 4 + row] += matrix0[i * 4 + row] * matrix1[column * 4 + i];
192 }
193
194 for (i = 0; i < 16; i++)
195 matrix[i] = temp[i];
196}
197
198static void
199rotate_xyz(float matrix[16], const float anglex, const float angley, const float anglez)
200{
201 float temp[16];
202 float rz = M_PI * anglez / 180.0f;
203 float rx = M_PI * anglex / 180.0f;
204 float ry = M_PI * angley / 180.0f;
205 float sy = sinf(ry);
206 float cy = cosf(ry);
207 float sx = sinf(rx);
208 float cx = cosf(rx);
209 float sz = sinf(rz);
210 float cz = cosf(rz);
211
212 init_matrix(temp);
213
214 temp[0] = cy * cz - sx * sy * sz;
215 temp[1] = cz * sx * sy + cy * sz;
216 temp[2] = -cx * sy;
217
218 temp[4] = -cx * sz;
219 temp[5] = cx * cz;
220 temp[6] = sx;
221
222 temp[8] = cz * sy + cy * sx * sz;
223 temp[9] = -cy * cz * sx + sy * sz;
224 temp[10] = cx * cy;
225
226 multiply_matrix(matrix, matrix, temp);
227}
228
229static int
230view_set_ortho(float result[16], const float left, const float right,
231 const float bottom, const float top, const float near,
232 const float far)
233{
234 if ((right - left) == 0.0f || (top - bottom) == 0.0f || (far - near) == 0.0f) return 0;
235
236 result[0] = 2.0f / (right - left);
237 result[1] = 0.0f;
238 result[2] = 0.0f;
239 result[3] = 0.0f;
240 result[4] = 0.0f;
241 result[5] = 2.0f / (top - bottom);
242 result[6] = 0.0f;
243 result[7] = 0.0f;
244 result[8] = 0.0f;
245 result[9] = 0.0f;
246 result[10] = -2.0f / (far - near);
247 result[11] = 0.0f;
248 result[12] = -(right + left) / (right - left);
249 result[13] = -(top + bottom) / (top - bottom);
250 result[14] = -(far + near) / (far - near);
251 result[15] = 1.0f;
252 return 1;
253}
254
255static void
256_shader_verify(GLuint shader, const char *str)
257{
258 GLint status;
259 GLsizei len;
260 char buf[4096];
261
262 GL()glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
263 if (!status)
264 {
265 GLERR();
266 GL()glGetShaderInfoLog(shader, sizeof(buf), &len, buf);
267 fprintf(stderr, "Shader compilation failed:\n%s\nFailed with: %s\n", str, buf);
268 abort();
269 }
270}
271
272void
273init_shaders(AppData *ad)
274{
275 const char *p;
276
277 p = vertex_shader;
278 ad->vtx_shader[0] = GL()glCreateShader(GL_VERTEX_SHADER);
279 GL()glShaderSource(ad->vtx_shader[0], 1, &p, NULL);
280 GL()glCompileShader(ad->vtx_shader[0]);
281 _shader_verify(ad->vtx_shader[0], p);
282
283 p = fragment_shader;
284 ad->fgmt_shader[0] = GL()glCreateShader(GL_FRAGMENT_SHADER);
285 GL()glShaderSource(ad->fgmt_shader[0], 1, &p, NULL);
286 GL()glCompileShader(ad->fgmt_shader[0]);
287 _shader_verify(ad->fgmt_shader[0], p);
288
289 ad->program[0] = GL()glCreateProgram();
290 GL()glAttachShader(ad->program[0], ad->vtx_shader[0]);
291 GL()glAttachShader(ad->program[0], ad->fgmt_shader[0]);
292 GL()glBindAttribLocation(ad->program[0], 0, "vPosition");
293 GL()glBindAttribLocation(ad->program[0], 1, "inColor");
294 GL()glLinkProgram(ad->program[0]); GLERR();
295
296 // Stencil test rectangle
297 p = vertex_stenciltest;
298 ad->vtx_shader[1] = GL()glCreateShader(GL_VERTEX_SHADER);
299 GL()glShaderSource(ad->vtx_shader[1], 1, &p, NULL);
300 GL()glCompileShader(ad->vtx_shader[1]); GLERR();
301
302 p = fragment_stenciltest;
303 ad->fgmt_shader[1] = GL()glCreateShader(GL_FRAGMENT_SHADER);
304 GL()glShaderSource(ad->fgmt_shader[1], 1, &p, NULL);
305 GL()glCompileShader(ad->fgmt_shader[1]); GLERR();
306
307 ad->program[1] = GL()glCreateProgram();
308 GL()glAttachShader(ad->program[1], ad->vtx_shader[1]);
309 GL()glAttachShader(ad->program[1], ad->fgmt_shader[1]);
310 GL()glBindAttribLocation(ad->program[1], 0, "vPosition");
311 GL()glLinkProgram(ad->program[1]); GLERR();
312
313 // Texture draw -- TODO
314 p = vertex_texture;
315 ad->vtx_shader[2] = GL()glCreateShader(GL_VERTEX_SHADER);
316 GL()glShaderSource(ad->vtx_shader[2], 1, &p, NULL);
317 GL()glCompileShader(ad->vtx_shader[2]); GLERR();
318
319 p = fragment_texture;
320 ad->fgmt_shader[2] = GL()glCreateShader(GL_FRAGMENT_SHADER);
321 GL()glShaderSource(ad->fgmt_shader[2], 1, &p, NULL);
322 GL()glCompileShader(ad->fgmt_shader[2]); GLERR();
323
324 ad->program[2] = GL()glCreateProgram();
325 GL()glAttachShader(ad->program[2], ad->vtx_shader[2]);
326 GL()glAttachShader(ad->program[2], ad->fgmt_shader[2]);
327 GL()glBindAttribLocation(ad->program[2], 0, "vPosition");
328 GL()glBindAttribLocation(ad->program[2], 1, "vTexCoord");
329 GL()glLinkProgram(ad->program[2]); GLERR();
330}
331
332void
333init_vertices(AppData *ad)
334{
335 GL()glGenBuffers(4, ad->vbo);
336 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[0]);
337 GL()glBufferData(GL_ARRAY_BUFFER, 3 * 72 * 4, cube_vertices, GL_STATIC_DRAW);
338 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[1]);
339 GL()glBufferData(GL_ARRAY_BUFFER, 3 * 6 * 4, stencil_mask_vertices, GL_STATIC_DRAW);
340 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[2]);
341 GL()glBufferData(GL_ARRAY_BUFFER, 3 * 6 * 4, rectangle_fullscreen_vertices, GL_STATIC_DRAW);
342 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[3]);
343 GL()glBufferData(GL_ARRAY_BUFFER, 2 * 6 * 4, texture_vertices, GL_STATIC_DRAW);
344}
345
346void
347destroy_context(AppData *ad)
348{
349 GL()glDeleteShader(ad->vtx_shader[0]);
350 GL()glDeleteShader(ad->fgmt_shader[0]);
351 GL()glDeleteProgram(ad->program[0]);
352 GL()glDeleteShader(ad->vtx_shader[1]);
353 GL()glDeleteShader(ad->fgmt_shader[1]);
354 GL()glDeleteProgram(ad->program[1]);
355 GL()glDeleteShader(ad->vtx_shader[2]);
356 GL()glDeleteShader(ad->fgmt_shader[2]);
357 GL()glDeleteProgram(ad->program[2]);
358 GL()glDeleteBuffers(4, ad->vbo);
359}
360
361void
362resize_gl(AppData *ad, int w, int h)
363{
364 float aspect;
365
366 if (w > h)
367 {
368 aspect = (float)w/h;
369 view_set_ortho(ad->view, -1.0 * aspect, 1.0 * aspect, -1.0, 1.0, -1.0, 1.0);
370 }
371 else
372 {
373 aspect = (float)h/w;
374 view_set_ortho(ad->view, -1.0, 1.0, -1.0 * aspect, 1.0 *aspect, -1.0, 1.0);
375 }
376 ad->view_rotation = 0;
377}
378
379void
380draw_gl(AppData *ad, int w, int h, int rotation)
381{
382 float model[16], mvp[16];
383 GLuint u, clearbit = 0;
384
385 GL()glViewport(0, 0, w, h); GLERR();
386
387#if 0
388 if (ad->pbuffer.enabled)
389 {
390 GL()glClearColor(0, 1, 1, 1);
391 GL()glClear(GL_COLOR_BUFFER_BIT);
392 return;
393 }
394#endif
395
396 if (rotation != ad->view_rotation)
397 rotate_xyz(ad->view, 0, 0, (rotation - ad->view_rotation));
398 ad->view_rotation = rotation;
399
400 clearbit = GL_COLOR_BUFFER_BIT;
401 if (ad->enable_depth)
402 {
403 clearbit |= GL_DEPTH_BUFFER_BIT;
404 GL()glDepthMask(EINA_TRUE); GLERR();
405 GL()glEnable(GL_DEPTH_TEST); GLERR();
406 }
407 else
408 GL()glDisable(GL_DEPTH_TEST);
409
410 if (ad->enable_stencil)
411 clearbit |= GL_STENCIL_BUFFER_BIT;
412 else
413 GL()glDisable(GL_STENCIL_TEST);
414 GLERR();
415
416 // Enable blending with premultiplied alpha
417 GL()glEnable(GL_BLEND); GLERR();
418 GL()glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); GLERR();
419
420 GL()glClearColor(0.0, 0.0, 0.0, ad->transparent ? 0.0 : 1.0); GLERR();
421 GL()glClear(clearbit); GLERR();
422
423 // Draw 1s in the stencil buffer
424 GL()glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); GLERR();
425 GL()glDepthMask(GL_FALSE); GLERR();
426 GL()glStencilMask(0xFF); GLERR();
427 GL()glStencilFunc(GL_NEVER, 1, 0xFF); GLERR();
428 GL()glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); GLERR();
429
430 // Draw small rectangle (values will be 1)
431 GL()glUseProgram(ad->program[1]); GLERR();
432 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[1]); GLERR();
433 GL()glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); GLERR();
434 GL()glEnableVertexAttribArray(0); GLERR();
435
436 init_matrix(model);
437 multiply_matrix(mvp, ad->view, model);
438 u = GL()glGetUniformLocation(ad->program[1], "mvpMatrix"); GLERR();
439 GL()glUniformMatrix4fv(u, 1, GL_FALSE, mvp); GLERR();
440 GL()glDrawArrays(GL_TRIANGLES, 0, 6); GLERR();
441
442 // Restore previous state
443 GL()glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); GLERR();
444 if (ad->enable_depth)
445 {
446 GL()glDepthMask(GL_TRUE);
447 GLERR();
448 }
449 GL()glStencilMask(0x00); GLERR();
450 GL()glStencilFunc(GL_EQUAL, 1, 0xFF); GLERR();
451
452 if (ad->enable_stencil)
453 {
454 GL()glEnable(GL_STENCIL_TEST);
455 GLERR();
456 }
457
458 //Draw cube
459 init_matrix(model);
460 rotate_xyz(model, ad->xangle, ad->yangle, 0);
461 multiply_matrix(mvp, ad->view, model);
462
463 GL()glUseProgram(ad->program[0]); GLERR();
464 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[0]); GLERR();
465 GL()glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, 0); GLERR();
466 GL()glEnableVertexAttribArray(0); GLERR();
467
468 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[0]); GLERR();
469 GL()glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, (void*)(sizeof(float)*3)); GLERR();
470 GL()glEnableVertexAttribArray(1); GLERR();
471
472 u = GL()glGetUniformLocation(ad->program[0], "alpha"); GLERR();
473 GL()glUniform1f(u, ad->transparent ? 0.666f : 1.0f); GLERR();
474 u = GL()glGetUniformLocation(ad->program[0], "mvpMatrix"); GLERR();
475 GL()glUniformMatrix4fv(u, 1, GL_FALSE, mvp); GLERR();
476 GL()glDrawArrays(GL_TRIANGLES, 0, 36); GLERR();
477}
478
479void
480draw_rectangle(AppData *ad, int w, int h, int rotation, int tex)
481{
482 float model[16], mvp[16];
483 GLuint u;
484
485 GLERR();
486 GL()glViewport(0, 0, w, h); GLERR();
487 GL()glClearColor(0.0, 0.0, 0.0, 0.0); GLERR();
488 GL()glClear(GL_COLOR_BUFFER_BIT); GLERR();
489
490 GL()glEnable(GL_BLEND); GLERR();
491 GL()glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); GLERR();
492
493 if (rotation != ad->view_rotation)
494 rotate_xyz(ad->view, 0, 0, (rotation - ad->view_rotation));
495 ad->view_rotation = rotation;
496
497 GL()glUseProgram(ad->program[2]); GLERR();
498
499 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[2]); GLERR();
500 GL()glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); GLERR();
501 GL()glEnableVertexAttribArray(0); GLERR();
502
503 GL()glBindBuffer(GL_ARRAY_BUFFER, ad->vbo[3]); GLERR();
504 GL()glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); GLERR();
505 GL()glEnableVertexAttribArray(1); GLERR();
506
507 init_matrix(model);
508 multiply_matrix(mvp, ad->view, model);
509 u = GL()glGetUniformLocation(ad->program[2], "mvpMatrix"); GLERR();
510 GL()glUniformMatrix4fv(u, 1, GL_FALSE, mvp); GLERR();
511
512 u = GL()glGetUniformLocation(ad->program[2], "tex"); GLERR();
513 GL()glUniform1i(u, 0); GLERR();
514
515 GL()glActiveTexture(GL_TEXTURE0);
516 GL()glBindTexture(GL_TEXTURE_2D, tex);
517
518 GL()glDrawArrays(GL_TRIANGLES, 0, 6); GLERR();
519
520}
diff --git a/glesgears.c b/glesgears.c
new file mode 100644
index 0000000..e37d3be
--- /dev/null
+++ b/glesgears.c
@@ -0,0 +1,412 @@
1/*
2 * NOTICE for the original code:
3 *
4 * 3-D gear wheels. This program is in the public domain.
5 *
6 * Command line options:
7 * -info print GL()gl implementation information
8 * -exit automatically exit after 30 seconds
9 *
10 *
11 * Brian Paul
12 */
13
14#include "evasgl_test.h"
15
16/* Conversion to use vertex buffer objects by Michael J. Clark */
17#ifdef EVAS_GL_GLES1
18
19#include <assert.h>
20#include <math.h>
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24
25#define MAX_CONFIGS 10
26#define MAX_MODES 100
27
28#ifdef _WIN32
29#define WIN32_LEAN_AND_MEAN 1
30#include <windows.h>
31
32static double
33current_time(void)
34{
35 DWORD tv;
36 tv = GetTickCount();
37 return (tv/1000.0);
38}
39
40#else
41#include <sys/time.h>
42#include <unistd.h>
43
44/* return current time (in seconds) */
45static double
46current_time(void)
47{
48 struct timeval tv;
49#ifdef __VMS
50 (void) gettimeofday(&tv, NULL );
51#else
52 struct timezone tz;
53 (void) gettimeofday(&tv, &tz);
54#endif
55 return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
56}
57#endif
58
59#ifndef M_PI
60#define M_PI 3.14159265
61#endif
62
63
64/**
65
66 Draw a gear wheel. You'll probably want to call this function when
67 building a display list since we do a lot of trig here.
68
69 Input: inner_radius - radius of hole at center
70 outer_radius - radius at center of teeth
71 width - width of gear
72 teeth - number of teeth
73 tooth_depth - depth of tooth
74
75 **/
76
77static gear_t*
78gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
79 GLint teeth, GLfloat tooth_depth, const GLfloat color[])
80{
81 GLint i, j;
82 GLfloat r0, r1, r2;
83 GLfloat ta, da;
84 GLfloat u1, v1, u2, v2, len;
85 GLfloat cos_ta, cos_ta_1da, cos_ta_2da, cos_ta_3da, cos_ta_4da;
86 GLfloat sin_ta, sin_ta_1da, sin_ta_2da, sin_ta_3da, sin_ta_4da;
87 GLshort ix0, ix1, ix2, ix3, ix4, ix5;
88 vertex_t *vt, *nm;
89 GLshort *ix;
90
91 gear_t *gear = calloc(1, sizeof(gear_t));
92 gear->nvertices = teeth * 40;
93 gear->nindices = teeth * 66 * 3;
94 gear->vertices = calloc(gear->nvertices, sizeof(vertex_t));
95 gear->indices = calloc(gear->nindices, sizeof(GLshort));
96 memcpy(&gear->color[0], &color[0], sizeof(GLfloat) * 4);
97
98 r0 = inner_radius;
99 r1 = outer_radius - tooth_depth / 2.0;
100 r2 = outer_radius + tooth_depth / 2.0;
101 da = 2.0 * M_PI / teeth / 4.0;
102
103 vt = gear->vertices;
104 nm = gear->vertices;
105 ix = gear->indices;
106
107#define VERTEX(x,y,z) ((vt->pos[0] = x),(vt->pos[1] = y),(vt->pos[2] = z), \
108 (vt++ - gear->vertices))
109#define NORMAL(x,y,z) ((nm->norm[0] = x),(nm->norm[1] = y),(nm->norm[2] = z), \
110 (nm++))
111#define INDEX(a,b,c) ((*ix++ = a),(*ix++ = b),(*ix++ = c))
112
113 for (i = 0; i < teeth; i++)
114 {
115 ta = i * 2.0 * M_PI / teeth;
116
117 cos_ta = cos(ta);
118 cos_ta_1da = cos(ta + da);
119 cos_ta_2da = cos(ta + 2 * da);
120 cos_ta_3da = cos(ta + 3 * da);
121 cos_ta_4da = cos(ta + 4 * da);
122 sin_ta = sin(ta);
123 sin_ta_1da = sin(ta + da);
124 sin_ta_2da = sin(ta + 2 * da);
125 sin_ta_3da = sin(ta + 3 * da);
126 sin_ta_4da = sin(ta + 4 * da);
127
128 u1 = r2 * cos_ta_1da - r1 * cos_ta;
129 v1 = r2 * sin_ta_1da - r1 * sin_ta;
130 len = sqrt(u1 * u1 + v1 * v1);
131 u1 /= len;
132 v1 /= len;
133 u2 = r1 * cos_ta_3da - r2 * cos_ta_2da;
134 v2 = r1 * sin_ta_3da - r2 * sin_ta_2da;
135
136 /* front face */
137 ix0 = VERTEX(r0 * cos_ta, r0 * sin_ta, width * 0.5);
138 ix1 = VERTEX(r1 * cos_ta, r1 * sin_ta, width * 0.5);
139 ix2 = VERTEX(r0 * cos_ta, r0 * sin_ta, width * 0.5);
140 ix3 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, width * 0.5);
141 ix4 = VERTEX(r0 * cos_ta_4da, r0 * sin_ta_4da, width * 0.5);
142 ix5 = VERTEX(r1 * cos_ta_4da, r1 * sin_ta_4da, width * 0.5);
143 for (j = 0; j < 6; j++)
144 {
145 NORMAL(0.0, 0.0, 1.0);
146 }
147 INDEX(ix0, ix1, ix2);
148 INDEX(ix1, ix3, ix2);
149 INDEX(ix2, ix3, ix4);
150 INDEX(ix3, ix5, ix4);
151
152 /* front sides of teeth */
153 ix0 = VERTEX(r1 * cos_ta, r1 * sin_ta, width * 0.5);
154 ix1 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, width * 0.5);
155 ix2 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, width * 0.5);
156 ix3 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, width * 0.5);
157 for (j = 0; j < 4; j++)
158 {
159 NORMAL(0.0, 0.0, 1.0);
160 }
161 INDEX(ix0, ix1, ix2);
162 INDEX(ix1, ix3, ix2);
163
164 /* back face */
165 ix0 = VERTEX(r1 * cos_ta, r1 * sin_ta, -width * 0.5);
166 ix1 = VERTEX(r0 * cos_ta, r0 * sin_ta, -width * 0.5);
167 ix2 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, -width * 0.5);
168 ix3 = VERTEX(r0 * cos_ta, r0 * sin_ta, -width * 0.5);
169 ix4 = VERTEX(r1 * cos_ta_4da, r1 * sin_ta_4da, -width * 0.5);
170 ix5 = VERTEX(r0 * cos_ta_4da, r0 * sin_ta_4da, -width * 0.5);
171 for (j = 0; j < 6; j++)
172 {
173 NORMAL(0.0, 0.0, -1.0);
174 }
175 INDEX(ix0, ix1, ix2);
176 INDEX(ix1, ix3, ix2);
177 INDEX(ix2, ix3, ix4);
178 INDEX(ix3, ix5, ix4);
179
180 /* back sides of teeth */
181 ix0 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, -width * 0.5);
182 ix1 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, -width * 0.5);
183 ix2 = VERTEX(r1 * cos_ta, r1 * sin_ta, -width * 0.5);
184 ix3 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, -width * 0.5);
185 for (j = 0; j < 4; j++)
186 {
187 NORMAL(0.0, 0.0, -1.0);
188 }
189 INDEX(ix0, ix1, ix2);
190 INDEX(ix1, ix3, ix2);
191
192 /* draw outward faces of teeth */
193 ix0 = VERTEX(r1 * cos_ta, r1 * sin_ta, width * 0.5);
194 ix1 = VERTEX(r1 * cos_ta, r1 * sin_ta, -width * 0.5);
195 ix2 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, width * 0.5);
196 ix3 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, -width * 0.5);
197 for (j = 0; j < 4; j++)
198 {
199 NORMAL(v1, -u1, 0.0);
200 }
201 INDEX(ix0, ix1, ix2);
202 INDEX(ix1, ix3, ix2);
203 ix0 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, width * 0.5);
204 ix1 = VERTEX(r2 * cos_ta_1da, r2 * sin_ta_1da, -width * 0.5);
205 ix2 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, width * 0.5);
206 ix3 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, -width * 0.5);
207 for (j = 0; j < 4; j++)
208 {
209 NORMAL(cos_ta, sin_ta, 0.0);
210 }
211 INDEX(ix0, ix1, ix2);
212 INDEX(ix1, ix3, ix2);
213 ix0 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, width * 0.5);
214 ix1 = VERTEX(r2 * cos_ta_2da, r2 * sin_ta_2da, -width * 0.5);
215 ix2 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, width * 0.5);
216 ix3 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, -width * 0.5);
217 for (j = 0; j < 4; j++)
218 {
219 NORMAL(v2, -u2, 0.0);
220 }
221 INDEX(ix0, ix1, ix2);
222 INDEX(ix1, ix3, ix2);
223 ix0 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, width * 0.5);
224 ix1 = VERTEX(r1 * cos_ta_3da, r1 * sin_ta_3da, -width * 0.5);
225 ix2 = VERTEX(r1 * cos_ta_4da, r1 * sin_ta_4da, width * 0.5);
226 ix3 = VERTEX(r1 * cos_ta_4da, r1 * sin_ta_4da, -width * 0.5);
227 for (j = 0; j < 4; j++)
228 {
229 NORMAL(cos_ta, sin_ta, 0.0);
230 }
231 INDEX(ix0, ix1, ix2);
232 INDEX(ix1, ix3, ix2);
233
234 /* draw inside radius cylinder */
235 ix0 = VERTEX(r0 * cos_ta, r0 * sin_ta, -width * 0.5);
236 ix1 = VERTEX(r0 * cos_ta, r0 * sin_ta, width * 0.5);
237 ix2 = VERTEX(r0 * cos_ta_4da, r0 * sin_ta_4da, -width * 0.5);
238 ix3 = VERTEX(r0 * cos_ta_4da, r0 * sin_ta_4da, width * 0.5);
239 NORMAL(-cos_ta, -sin_ta, 0.0);
240 NORMAL(-cos_ta, -sin_ta, 0.0);
241 NORMAL(-cos_ta_4da, -sin_ta_4da, 0.0);
242 NORMAL(-cos_ta_4da, -sin_ta_4da, 0.0);
243 INDEX(ix0, ix1, ix2);
244 INDEX(ix1, ix3, ix2);
245 }
246
247 return gear;
248}
249
250void
251draw_gear(AppData *ad EINA_UNUSED, const gear_t* gear)
252{
253 assert(GL()glLightfv); // GL()glES 1.1
254
255 // TODO/FIXME: Check rotation and fix rendering
256
257 GL()glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, gear->color);
258 GL()glVertexPointer(3, GL_FLOAT, sizeof(vertex_t), gear->vertices[0].pos);
259 GL()glNormalPointer(GL_FLOAT, sizeof(vertex_t), gear->vertices[0].norm);
260 GL()glDrawElements(GL_TRIANGLES, gear->nindices/3, GL_UNSIGNED_SHORT, gear->indices);
261}
262static const GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
263
264
265static void
266draw(AppData *ad, int w, int h)
267{
268 static const GLfloat viewDist = 40.0;
269 int clearbit = GL_COLOR_BUFFER_BIT;
270
271 assert(GL()glLightfv); // GL()glES 1.1
272
273 GL()glViewport(0, 0, w, h);
274
275 GL()glClearColor(0.0, 0.0, 0.0, ad->transparent ? 0.0 : 1.0);
276 if (ad->enable_depth)
277 {
278 clearbit |= GL_DEPTH_BUFFER_BIT;
279 // We do this at every frame because the flag can change from the UI
280 GL()glEnable(GL_DEPTH_TEST);
281 }
282 else
283 GL()glDisable(GL_DEPTH_TEST);
284 GL()glClear(clearbit);
285 GL()glEnable(GL_TEXTURE_2D);
286 GL()glEnable(GL_BLEND);
287 GL()glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
288
289 GL()glPushMatrix();
290 {
291 GL()glTranslatef(0.0, 0.0, -viewDist);
292
293 GL()glRotatef(view_rotx, 1.0, 0.0, 0.0);
294 GL()glRotatef(view_roty, 0.0, 1.0, 0.0);
295 GL()glRotatef(view_rotz, 0.0, 0.0, 1.0);
296
297 GL()glPushMatrix();
298 {
299 GL()glTranslatef(-3.0, -2.0, 0.0);
300 GL()glRotatef(ad->angle, 0.0, 0.0, 1.0);
301 draw_gear(ad, ad->gear1);
302 }
303 GL()glPopMatrix();
304
305 GL()glPushMatrix();
306 {
307 GL()glTranslatef(3.1, -2.0, 0.0);
308 GL()glRotatef(-2.0 * ad->angle - 9.0, 0.0, 0.0, 1.0);
309 draw_gear(ad, ad->gear2);
310 }
311 GL()glPopMatrix();
312
313 GL()glPushMatrix();
314 {
315 GL()glTranslatef(-3.1, 4.2, 0.0);
316 GL()glRotatef(-2.0 * ad->angle - 25.0, 0.0, 0.0, 1.0);
317 draw_gear(ad, ad->gear3);
318 }
319 GL()glPopMatrix();
320 }
321 GL()glPopMatrix();
322}
323
324void
325resize_gles1(AppData *ad EINA_UNUSED, int w, int h)
326{
327 GLfloat ar = (GLfloat) h / (GLfloat) w;
328
329 assert(GL()glLightfv); // GL()glES 1.1
330
331 GL()glViewport(0, 0, (GLint) w, (GLint) h);
332 GL()glMatrixMode(GL_PROJECTION);
333 GL()glLoadIdentity();
334 GL()glFrustumf(-1.0, 1.0, -ar, ar, 5.0, 200.0);
335 GL()glMatrixMode(GL_MODELVIEW);
336}
337
338void
339init_gles1(AppData *ad)
340{
341 static const GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
342 static const GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
343 static const GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
344 static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
345
346
347 assert(GL()glLightfv); // GL()glES 1.1
348
349 GL()glLightfv(GL_LIGHT0, GL_POSITION, pos);
350 GL()glEnable(GL_CULL_FACE);
351 GL()glEnable(GL_LIGHTING);
352 GL()glEnable(GL_LIGHT0);
353 if (ad->enable_depth)
354 GL()glEnable(GL_DEPTH_TEST);
355
356 GL()glShadeModel(GL_SMOOTH);
357
358 GL()glEnableClientState(GL_NORMAL_ARRAY);
359 GL()glEnableClientState(GL_VERTEX_ARRAY);
360
361 // Print some info.
362 printf("GL_RENDERER = %s\n", (char *) GL()glGetString(GL_RENDERER));
363 printf("GL_VERSION = %s\n", (char *) GL()glGetString(GL_VERSION));
364 printf("GL_VENDOR = %s\n", (char *) GL()glGetString(GL_VENDOR));
365 printf("GL_EXTENSIONS = %s\n", (char *) GL()glGetString(GL_EXTENSIONS));
366 fflush(stdout);
367
368 ad->gear1 = gear(1.0, 4.0, 1.0, 20, 0.7, red);
369 ad->gear2 = gear(0.5, 2.0, 2.0, 10, 0.7, green);
370 ad->gear3 = gear(1.3, 2.0, 0.5, 10, 0.7, blue);
371
372 ad->st = current_time();
373 ad->ct = ad->st;
374 ad->seconds = ad->st;
375}
376
377void
378run_gears(AppData *ad, int w, int h)
379{
380 double fps;
381 double tt = current_time();
382 double dt = tt - ad->ct;
383 ad->ct = tt;
384
385 // TODO: Handle evas_gl rotation.
386
387 ad->angle += 70.0 * dt; /* 70 degrees per second */
388 if (ad->angle > 3600.0)
389 ad->angle -= 3600.0;
390 draw(ad, w, h);
391 ad->frames++;
392 dt = ad->ct - ad->seconds;
393 if (dt >= 5.0)
394 {
395 fps = ad->frames / dt;
396 printf("%d frames in %3.1f seconds = %6.3f FPS\n", ad->frames, dt, fps);
397 ad->seconds = ad->ct;
398 ad->frames = 0;
399 }
400}
401
402void
403destroy_gles1(AppData *ad)
404{
405 free(ad->gear1);
406 free(ad->gear2);
407 free(ad->gear3);
408 ad->gear1 = ad->gear2 = ad->gear3 = NULL;
409 ad->frames = 0;
410}
411
412#endif
diff --git a/glview.c b/glview.c
new file mode 100644
index 0000000..2ea076a
--- /dev/null
+++ b/glview.c
@@ -0,0 +1,373 @@
1#include "evasgl_test.h"
2
3#include<X11/Xlib.h>
4
5#include "assert.h"
6
7ELEMENTARY_GLVIEW_GLOBAL_DEFINE()
8
9static void
10_init_gl(Evas_Object *obj)
11{
12 AppData *ad = APPDATA_GET(obj);
13 static Eina_Bool tests_run = EINA_FALSE;
14
15 ad->evasgl = elm_glview_evas_gl_get(ad->glview);
16 init_shaders(ad);
17 init_vertices(ad);
18
19 // Print some info.
20 printf("GL_RENDERER = %s\n", (char *) GL()glGetString(GL_RENDERER));
21 printf("GL_VERSION = %s\n", (char *) GL()glGetString(GL_VERSION));
22 printf("GL_VENDOR = %s\n", (char *) GL()glGetString(GL_VENDOR));
23 printf("GL_EXTENSIONS = %s\n", (char *) GL()glGetString(GL_EXTENSIONS));
24 fflush(stdout);
25
26 // Run some tests.
27 if (!tests_run)
28 test_extensions(ad);
29 tests_run = EINA_TRUE;
30}
31
32static void
33_del_gl(Evas_Object *obj)
34{
35 AppData *ad = APPDATA_GET(obj);
36 destroy_context(ad);
37}
38
39static void
40_resize_gl(Evas_Object *obj)
41{
42 AppData *ad = APPDATA_GET(obj);
43 int w, h;
44
45 elm_glview_size_get(obj, &w, &h);
46 if (w <= 0 || h <= 0) return;
47
48 resize_gl(ad, w, h);
49}
50
51#ifdef EVAS_GL_GLES1
52static void
53_init_gl1(Evas_Object *obj)
54{
55 AppData *ad = APPDATA_GET(obj);
56
57 ad->evasgl = elm_glview_evas_gl_get(ad->glview);
58 init_gles1(ad);
59}
60
61static void
62_del_gl1(Evas_Object *obj)
63{
64 AppData *ad = APPDATA_GET(obj);
65 destroy_gles1(ad);
66}
67
68static void
69_resize_gl1(Evas_Object *obj)
70{
71 AppData *ad = APPDATA_GET(obj);
72 int w, h;
73
74 elm_glview_size_get(obj, &w, &h);
75 if (w <= 0 || h <= 0) return;
76
77 resize_gles1(ad, w, h);
78}
79
80static void
81_draw_gl1(Evas_Object *obj)
82{
83 AppData *ad = APPDATA_GET(obj);
84 int w, h;
85
86 elm_glview_size_get(obj, &w, &h);
87 if (w <= 0 || h <= 0) return;
88
89 run_gears(ad, w, h);
90
91 //Display *dpy = XOpenDisplay(NULL);
92 //XFlush(dpy);
93}
94#endif
95
96static void
97_draw_gl(Evas_Object *obj)
98{
99 AppData *ad = APPDATA_GET(obj);
100 int w, h, rotation;
101 char title[128];
102
103 elm_glview_size_get(obj, &w, &h);
104 rotation = evas_gl_rotation_get(ad->evasgl);
105 sprintf(title, "<font=Mono>Evas GL Rotation: %3d</>", rotation);
106 title_set(ad, title);
107
108 /*
109 void *surface = evas_gl_current_surface_get(ad->evasgl);
110 int texture_target = 0;
111 int result = evas_gl_surface_query(ad->evasgl, surface, EVAS_GL_TEXTURE_TARGET, &texture_target);
112
113 void *addr = evas_gl_proc_address_get(ad->evasgl, "lol");
114
115 evas_gl_current_context_get(NULL);
116 const char *qry = evas_gl_string_query(ad->evasgl, EVAS_GL_EXTENSIONS);
117 */
118
119 // FIXME: This needs to be checked a little bit. It works but it's ugly :)
120 if (ad->direct && (rotation % 180))
121 resize_gl(ad, h, w);
122
123#if ENABLE_IMAGE_TEST
124 if (ad->evglimg.enabled)
125 {
126 if (!ad->evglimg.img)
127 {
128 const int BUFFER_WIDTH = 64;
129 const int BUFFER_HEIGHT = 64;
130 ad->evglimg.w = BUFFER_WIDTH;
131 ad->evglimg.h = BUFFER_HEIGHT;
132
133 glGenFramebuffers(1, &ad->evglimg.fbo); GLERR();
134 glBindFramebuffer(GL_FRAMEBUFFER, ad->evglimg.fbo); GLERR();
135 glGenTextures(1, &ad->evglimg.fbo_tex); GLERR();
136 glBindTexture(GL_TEXTURE_2D, ad->evglimg.fbo_tex); GLERR();
137 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GLERR();
138 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GLERR();
139 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GLERR();
140 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GLERR();
141 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ad->evglimg.w, ad->evglimg.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); GLERR();
142 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ad->evglimg.fbo_tex, 0); GLERR();
143 //glGenRenderbuffers(1, &td->depth_stencil_rb);
144 //glBindRenderbuffer(GL_RENDERBUFFER, td->depth_stencil_rb);
145 //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, BUFFER_WIDTH, BUFFER_HEIGHT);
146 //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, td->depth_stencil_rb);
147 //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, td->depth_stencil_rb);
148 const int attr[] = {
149 EVAS_GL_TEXTURE_LEVEL, 0,
150 EVAS_GL_IMAGE_PRESERVED, 0,
151 EVAS_GL_NONE
152 };
153 ad->evglimg.img = evasglCreateImage
154 (EVAS_GL_TEXTURE_2D, (void *)(intptr_t) ad->evglimg.fbo_tex, attr);
155 GLERR();
156 }
157
158 // draw gl
159 glBindFramebuffer(GL_FRAMEBUFFER, ad->evglimg.fbo); GLERR();
160 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ad->evglimg.fbo_tex, 0); GLERR();
161 resize_gl(ad, ad->evglimg.w, ad->evglimg.h); GLERR();
162 draw_gl(ad, ad->evglimg.w, ad->evglimg.h, 0); GLERR();
163
164 // render to screen.
165 //not now!
166 glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERR();
167 draw_rectangle(ad, w, h, rotation, ad->evglimg.fbo_tex);
168 }
169 else
170#endif
171 if (!ad->pbuffer.enabled)
172 {
173 draw_gl(ad, w, h, rotation);
174 if (ad->pbuffer.img)
175 GL()evasglDestroyImage(ad->pbuffer.img);
176 if (ad->pbuffer.sfc)
177 evas_gl_surface_destroy(ad->evasgl, ad->pbuffer.sfc);
178 memset(&ad->pbuffer, 0, sizeof(ad->pbuffer));
179 }
180 else
181 {
182 // Let's try to render into the PBuffer. We'll glFinish and swap that later.
183 Evas_GL_Context *ctx;
184 Evas_GL_Surface *sfc;
185
186 GLERR();
187 ctx = evas_gl_current_context_get(ad->evasgl); GLERR();
188 sfc = evas_gl_current_surface_get(ad->evasgl); GLERR();
189 if (!ctx)
190 printf("hello\n");
191
192
193 if (!ad->pbuffer.sfc)
194 {
195 Evas_GL_Config *cfg = evas_gl_config_new();
196
197 /* Note: it's safe to do our GL stuff here since the "GL thread"
198 * is nothing else than the main thread.
199 */
200
201 ad->pbuffer.rgba = EINA_TRUE;
202#if 0
203 cfg->color_format = EVAS_GL_RGBA_8888;
204 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_8;
205 cfg->depth_bits = EVAS_GL_DEPTH_BIT_24;
206#else
207 cfg->color_format = EVAS_GL_NO_FBO;
208 cfg->stencil_bits = EVAS_GL_STENCIL_NONE;
209 cfg->depth_bits = EVAS_GL_DEPTH_NONE;
210#endif
211
212 ad->pbuffer.w = 32;
213 ad->pbuffer.h = 32;
214 ad->pbuffer.sfc = evas_gl_pbuffer_surface_create
215 (ad->evasgl, cfg, ad->pbuffer.w, ad->pbuffer.h, NULL);
216 evas_gl_config_free(cfg);
217 }
218
219 /* Get the current context, and make our context with pbuffer current */
220 evas_gl_make_current(ad->evasgl, ad->pbuffer.sfc, ctx); GLERR();
221
222 if (!ad->pbuffer.fbo)
223 {
224 GL()glGenFramebuffers(1, &ad->pbuffer.fbo); GLERR();
225 GL()glBindFramebuffer(GL_FRAMEBUFFER, ad->pbuffer.fbo); GLERR();
226
227 GL()glGenTextures(1, &ad->pbuffer.fbo_tex); GLERR();
228 GL()glBindTexture(GL_TEXTURE_2D, ad->pbuffer.fbo_tex); GLERR();
229 GL()glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GLERR();
230 GL()glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GLERR();
231 GL()glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GLERR();
232 GL()glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GLERR();
233 GL()glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ad->pbuffer.w, ad->pbuffer.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); GLERR();
234
235 GL()glGenRenderbuffers(1, &ad->pbuffer.depth_stencil_rb); GLERR();
236 GL()glBindRenderbuffer(GL_RENDERBUFFER, ad->pbuffer.depth_stencil_rb); GLERR();
237 GL()glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, ad->pbuffer.w, ad->pbuffer.h); GLERR();
238 }
239
240 GL()glBindFramebuffer(GL_FRAMEBUFFER, ad->pbuffer.fbo); GLERR();
241 GL()glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ad->pbuffer.fbo_tex, 0); GLERR();
242 GL()glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, ad->pbuffer.depth_stencil_rb); GLERR();
243 GL()glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, ad->pbuffer.depth_stencil_rb); GLERR();
244 resize_gl(ad, ad->pbuffer.w, ad->pbuffer.h);
245 draw_gl(ad, ad->pbuffer.w, ad->pbuffer.h, 0);
246 GL()glBindFramebuffer(GL_FRAMEBUFFER, 0);
247
248 /* Share the image with our main context */
249 if (!ad->pbuffer.img)
250 {
251#if 0 // Old code assuming an FBO is created by evas
252 Evas_Native_Surface ns;
253 int attrib_list[] = {
254 EVAS_GL_IMAGE_PRESERVED, EINA_TRUE,
255 0
256 };
257
258 memset(&ns, 0, sizeof(ns));
259 evas_gl_native_surface_get(ad->evasgl, ad->pbuffer.sfc, &ns);
260
261#if 0
262 ad->pbuffer.img = evasglCreateImage
263 (EVAS_GL_TEXTURE_2D, (void *)(intptr_t)ns.data.opengl.texture_id,
264 attrib_list);
265#endif
266 ad->pbuffer.img = evasglCreateImageForContext
267 (ad->evasgl, ctx, EVAS_GL_TEXTURE_2D,
268 (void *)(intptr_t)ns.data.opengl.texture_id, attrib_list);
269 ad->pbuffer.tex = ns.data.opengl.texture_id;
270#else
271 const int attrib_list[] = {
272 EVAS_GL_TEXTURE_LEVEL, 0,
273 EVAS_GL_IMAGE_PRESERVED, EINA_TRUE,
274 0 // This could also be EVAS_GL_NONE
275 };
276
277 if (GL()evasglCreateImageForContext)
278 {
279 ad->pbuffer.img = GL()evasglCreateImageForContext
280 (ad->evasgl, ctx, EVAS_GL_TEXTURE_2D,
281 (void *)(intptr_t)ad->pbuffer.fbo_tex, attrib_list);
282 }
283 else fprintf(stderr, "evasglCreateImage is not supported. GLX?\n");
284#endif
285 }
286
287 GLERR();
288 evas_gl_make_current(ad->evasgl, sfc, ctx); GLERR();
289
290 if (!ad->pbuffer.tex)
291 {
292 //glGenTextures(1, &ad->pbuffer.tex); GLERR();
293 //glBindTexture(GL_TEXTURE_2D, ad->pbuffer.tex); GLERR();
294 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GLERR();
295 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLERR();
296 //glEvasGLImageTargetTexture2DOES(GL_TEXTURE_2D, ad->pbuffer.img); GLERR();
297 ad->pbuffer.tex = ad->pbuffer.fbo_tex;
298 }
299
300 resize_gl(ad, w, h);
301 draw_rectangle(ad, w, h, rotation, ad->pbuffer.tex);
302 }
303}
304
305void
306win_rotate_cb(AppData *ad)
307{
308 _resize_gl(ad->glview);
309}
310
311void
312glview_init(AppData *ad)
313{
314 Evas_Object *o = ad->glview;
315 Eina_Bool pbuf;
316 if (!o) return;
317 assert(o);
318
319 ELEMENTARY_GLVIEW_GLOBAL_USE(o);
320#ifdef EVAS_GL_GLES2_API_CHECK
321 if (!EVAS_GL_GLES2_API_CHECK())
322 abort();
323#endif
324
325 pbuf = ad->pbuffer.enabled;
326 memset(&ad->pbuffer, 0, sizeof(ad->pbuffer));
327 ad->pbuffer.enabled = pbuf;
328
329 ad->evasgl = elm_glview_evas_gl_get(o);
330 elm_glview_mode_set(o,
331 ELM_GLVIEW_ALPHA |
332 ELM_GLVIEW_DEPTH |
333 ELM_GLVIEW_STENCIL |
334 (ad->direct ? ELM_GLVIEW_DIRECT : 0) |
335 (ad->client_side ? ELM_GLVIEW_CLIENT_SIDE_ROTATION : 0)
336 );
337 elm_glview_resize_policy_set(o, ELM_GLVIEW_RESIZE_POLICY_RECREATE);
338 elm_glview_render_policy_set(o, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
339
340 // POLICY_ALWAYS does not support direct rendering by design.
341 //elm_glview_render_policy_set(o, ELM_GLVIEW_RENDER_POLICY_ALWAYS);
342
343 if (!ad->gles1)
344 {
345 elm_glview_init_func_set(o, _init_gl);
346 elm_glview_del_func_set(o, _del_gl);
347 elm_glview_resize_func_set(o, _resize_gl);
348 elm_glview_render_func_set(o, _draw_gl);
349 }
350 else
351#ifdef EVAS_GL_GLES1
352 {
353 elm_glview_init_func_set(o, _init_gl1);
354 elm_glview_del_func_set(o, _del_gl1);
355 elm_glview_resize_func_set(o, _resize_gl1);
356 elm_glview_render_func_set(o, _draw_gl1);
357 }
358#else
359 abort();
360#endif
361}
362
363void
364on_error(const char *func, int line)
365{
366 int _e = GL()glGetError();
367 if (_e)
368 {
369 fprintf(stderr, "%s:%d: GL error 0x%04x\n", func, line, _e);
370 //abort();
371 }
372 return;
373}
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..a7d047b
--- /dev/null
+++ b/main.c
@@ -0,0 +1,420 @@
1#include "evasgl_test.h"
2#include <Ecore_X.h>
3
4#define S(a) evas_object_show(a)
5#define SX(a) do { \
6 evas_object_size_hint_align_set(a, EVAS_HINT_FILL, EVAS_HINT_FILL); \
7 evas_object_size_hint_weight_set(a, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); \
8 evas_object_show(a); \
9 } while (0)
10#define SF(a) do { \
11 evas_object_size_hint_align_set(a, EVAS_HINT_FILL, EVAS_HINT_FILL); \
12 evas_object_size_hint_weight_set(a, 0.00001, 0.00001); \
13 evas_object_show(a); \
14 } while (0)
15
16struct _PrivData
17{
18 Evas_Object *table, *bg, *title;
19 Evas_Object *win;
20 Evas_Object *pbuffer_checkbox, *stencil_checkbox, *depth_checkbox;
21 Ecore_Animator *anim;
22};
23
24void
25title_set(AppData *ad, const char *title)
26{
27 elm_object_text_set(ad->pd->title, title);
28}
29
30static void
31_glview_create(AppData *ad)
32{
33 Evas_Object *o = NULL;
34
35 ad->evasgl = NULL;
36 if (!ad->gles1)
37 ad->glview = o = elm_glview_add(ad->pd->win);
38 else
39#ifdef EVAS_GL_GLES1
40 ad->glview = o = elm_glview_version_add(ad->pd->win, EVAS_GL_GLES_1_X);
41#else
42 {
43 fprintf(stderr, "OpenGL ES 1 is not supported.\n");
44 abort();
45 }
46#endif
47 elm_table_pack(ad->pd->table, o, 1, 1, 3, 1);
48 SX(o);
49
50 evas_object_data_set(o, APPDATA_KEY, ad);
51 evas_object_size_hint_min_set(o, 200, 200);
52 glview_init(ad);
53
54 fprintf(stderr, "Current evas gl error: %#x\n", evas_gl_error_get(ad->evasgl));
55}
56
57static void
58_win_resize_cb(void *data, Evas *e EINA_UNUSED,
59 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
60{
61 AppData *ad = data;
62 int w, h;
63
64 evas_object_geometry_get(ad->pd->win, NULL, NULL, &w, &h);
65 evas_object_resize(ad->pd->table, w, h);
66 evas_object_resize(ad->pd->bg, w, h);
67}
68
69static void
70_close_cb(void *data EINA_UNUSED,
71 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
72{
73 elm_exit();
74}
75
76static void
77_transparent_check_cb(void *data, Evas_Object *obj,
78 void *event_info EINA_UNUSED)
79{
80 AppData *ad = data;
81 ad->transparent = elm_check_state_get(obj);
82}
83
84static void
85_depth_check_cb(void *data, Evas_Object *obj,
86 void *event_info EINA_UNUSED)
87{
88 AppData *ad = data;
89 ad->enable_depth = elm_check_state_get(obj);
90 ad->enable_depth_was_auto = EINA_FALSE;
91}
92
93static void
94_stencil_check_cb(void *data, Evas_Object *obj,
95 void *event_info EINA_UNUSED)
96{
97 AppData *ad = data;
98 ad->enable_stencil = elm_check_state_get(obj);
99}
100
101static void
102_direct_check_cb(void *data, Evas_Object *obj,
103 void *event_info EINA_UNUSED)
104{
105 AppData *ad = data;
106 Eina_Bool old = ad->direct;
107 ad->direct = elm_check_state_get(obj);
108 if (old != ad->direct)
109 {
110 evas_object_del(ad->glview);
111 _glview_create(ad);
112 }
113}
114
115static void
116_client_side_check_cb(void *data, Evas_Object *obj,
117 void *event_info EINA_UNUSED)
118{
119 AppData *ad = data;
120 Eina_Bool old = ad->client_side;
121 ad->client_side = elm_check_state_get(obj);
122 if (old != ad->client_side)
123 {
124 evas_object_del(ad->glview);
125 _glview_create(ad);
126 }
127}
128
129static void
130_gles1_check_cb(void *data, Evas_Object *obj,
131 void *event_info EINA_UNUSED)
132{
133 AppData *ad = data;
134 Eina_Bool old = ad->gles1;
135 ad->gles1 = elm_check_state_get(obj);
136 if (old != ad->gles1)
137 {
138 evas_object_del(ad->glview);
139 // Those are probably tests we want to implement: pbuf render & stencil
140 ad->pbuffer.enabled = EINA_FALSE;
141 ad->enable_stencil = EINA_FALSE;
142 _glview_create(ad);
143 }
144 if (ad->gles1)
145 {
146 if (!ad->enable_depth)
147 {
148 // Auto activate depth test for the gears
149 elm_check_state_set(ad->pd->depth_checkbox, EINA_TRUE);
150 ad->enable_depth = EINA_TRUE;
151 ad->enable_depth_was_auto = EINA_TRUE;
152 }
153 elm_object_disabled_set(ad->pd->pbuffer_checkbox, EINA_TRUE);
154 elm_object_disabled_set(ad->pd->stencil_checkbox, EINA_TRUE);
155 }
156 else
157 {
158 if (ad->enable_depth_was_auto)
159 {
160 elm_check_state_set(ad->pd->depth_checkbox, EINA_FALSE);
161 ad->enable_depth = EINA_FALSE;
162 }
163 elm_object_disabled_set(ad->pd->pbuffer_checkbox, EINA_FALSE);
164 elm_object_disabled_set(ad->pd->stencil_checkbox, EINA_FALSE);
165 }
166}
167
168static void
169_pbuffer_check_cb(void *data, Evas_Object *obj,
170 void *event_info EINA_UNUSED)
171{
172 AppData *ad = data;
173 ad->pbuffer.enabled = elm_check_state_get(obj);
174}
175
176#if ENABLE_IMAGE_TEST
177static void
178_evglimg_check_cb(void *data, Evas_Object *obj,
179 void *event_info EINA_UNUSED)
180{
181 AppData *ad = data;
182 ad->evglimg.enabled = elm_check_state_get(obj);
183}
184#endif
185
186static void
187_rotate_cb(void *data, Evas_Object *obj EINA_UNUSED,
188 void *event_info EINA_UNUSED)
189{
190 AppData *ad = data;
191 int rot;
192
193 rot = elm_win_rotation_get(ad->pd->win);
194 ad->rotation = (rot + 90) % 360;
195 elm_win_rotation_set(ad->pd->win, ad->rotation);
196 win_rotate_cb(ad);
197}
198
199static void
200_rotate_resize_cb(void *data, Evas_Object *obj EINA_UNUSED,
201 void *event_info EINA_UNUSED)
202{
203 AppData *ad = data;
204 int rot;
205
206 rot = elm_win_rotation_get(ad->pd->win);
207 ad->rotation = (rot + 90) % 360;
208 elm_win_rotation_with_resize_set(ad->pd->win, ad->rotation);
209 win_rotate_cb(ad);
210}
211
212static Eina_Bool
213_anim_cb(void *data)
214{
215 AppData *ad = data;
216
217 ad->xangle += 1.5;
218 ad->yangle += 1.0;
219 elm_glview_changed_set(ad->glview);
220 return ECORE_CALLBACK_RENEW;
221}
222
223static void
224_ecore_x_error_cb(void *data EINA_UNUSED)
225{
226 fprintf(stderr, "An Ecore X error happened.\n");
227}
228
229EAPI int
230elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
231{
232 Evas_Object *o, *t;
233 AppData *ad;
234
235 const char *transparency = "Enable transparency";
236 const char *depth = "Enable depth test";
237 const char *stencil = "Enable stencil test";
238 const char *direct = "Enable direct rendering";
239 const char *client_side = "Enable client-side rotation";
240 const char *pbuffer = "Render to a PBuffer surface";
241 const char *gles1 = "OpenGL ES 1.1";
242
243 // Force OpenGL engine
244 //elm_config_engine_set("opengl_x11");
245 elm_config_accel_preference_set("hw");
246 elm_config_accel_preference_override_set(EINA_TRUE);
247
248 ad = calloc(1, sizeof(*ad));
249 ad->pd = calloc(1, sizeof(*ad->pd));
250
251// if (access("/etc/tizen-release", R_OK) == 0)
252 {
253 ad->tizen = EINA_TRUE;
254 transparency = "Trans.";
255 depth = "Depth";
256 stencil = "Stencil";
257 direct = "DR";
258 pbuffer = "PBuffer";
259 gles1 = "GLES 1";
260 client_side = "CSR";
261 }
262
263 ecore_x_error_handler_set(_ecore_x_error_cb, ad);
264
265 ad->pd->win = o = elm_win_util_standard_add("glview", "GLView");
266 evas_object_smart_callback_add(o, "delete,request", _close_cb, ad);
267 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _win_resize_cb, ad);
268 S(o);
269
270 o = elm_conformant_add(ad->pd->win);
271 elm_win_resize_object_add(ad->pd->win, o);
272 SX(o);
273
274 ad->pd->table = t = elm_table_add(ad->pd->win);
275 //elm_win_resize_object_add(ad->pd->win, t);
276 elm_object_content_set(o, t);
277 SX(t);
278
279 ad->pd->title = o = elm_label_add(ad->pd->win);
280 evas_object_size_hint_align_set(o, 0.5, 0.5);
281 evas_object_size_hint_weight_set(o, 1.0, 0.0001);
282 elm_object_text_set(o, "Rotating cube");
283 elm_table_pack(t, o, 1, 0, 3, 1);
284 S(o);
285
286 o = elm_label_add(ad->pd->win);
287 elm_object_text_set(o, "&lt;");
288 elm_table_pack(t, o, 0, 1, 1, 1);
289 SF(o);
290
291 o = elm_label_add(ad->pd->win);
292 elm_object_text_set(o, "&gt;");
293 elm_table_pack(t, o, 4, 1, 1, 1);
294 SF(o);
295
296 o = elm_check_add(ad->pd->win);
297 elm_object_text_set(o, transparency);
298 evas_object_smart_callback_add(o, "changed", _transparent_check_cb, ad);
299 elm_check_state_set(o, EINA_TRUE);
300 ad->transparent = EINA_TRUE;
301 if (!ad->tizen)
302 elm_table_pack(t, o, 1, 2, 2, 1);
303 else
304 elm_table_pack(t, o, 1, 2, 1, 1);
305 SF(o);
306
307 o = elm_check_add(ad->pd->win);
308 elm_object_text_set(o, depth);
309 evas_object_smart_callback_add(o, "changed", _depth_check_cb, ad);
310 elm_check_state_set(o, EINA_FALSE);
311 ad->enable_depth = EINA_FALSE;
312 if (!ad->tizen)
313 elm_table_pack(t, o, 1, 3, 2, 1);
314 else
315 elm_table_pack(t, o, 2, 2, 1, 1);
316 SF(o);
317 ad->pd->depth_checkbox = o;
318
319 o = elm_check_add(ad->pd->win);
320 elm_object_text_set(o, stencil);
321 evas_object_smart_callback_add(o, "changed", _stencil_check_cb, ad);
322 elm_check_state_set(o, EINA_FALSE);
323 ad->enable_stencil = EINA_FALSE;
324 if (!ad->tizen)
325 elm_table_pack(t, o, 1, 4, 2, 1);
326 else
327 elm_table_pack(t, o, 3, 2, 1, 1);
328 SF(o);
329 ad->pd->stencil_checkbox = o;
330
331 o = elm_check_add(ad->pd->win);
332 elm_object_text_set(o, direct);
333 evas_object_smart_callback_add(o, "changed", _direct_check_cb, ad);
334 elm_check_state_set(o, EINA_TRUE);
335 ad->direct = EINA_TRUE;
336 if (!ad->tizen)
337 elm_table_pack(t, o, 1, 5, 2, 1);
338 else
339 elm_table_pack(t, o, 1, 3, 1, 1);
340 SF(o);
341
342 o = elm_check_add(ad->pd->win);
343 elm_object_text_set(o, client_side);
344 evas_object_smart_callback_add(o, "changed", _client_side_check_cb, ad);
345 elm_check_state_set(o, EINA_TRUE);
346 ad->client_side = EINA_TRUE;
347 if (!ad->tizen)
348 elm_table_pack(t, o, 1, 6, 2, 1);
349 else
350 elm_table_pack(t, o, 1, 4, 1, 1);
351 SF(o);
352
353#ifdef EVAS_GL_GLES1
354 o = elm_check_add(ad->pd->win);
355 elm_object_text_set(o, gles1);
356 evas_object_smart_callback_add(o, "changed", _gles1_check_cb, ad);
357 if (!ad->tizen)
358 elm_table_pack(t, o, 1, 7, 2, 1);
359 else
360 elm_table_pack(t, o, 2, 3, 1, 1);
361 SF(o);
362#endif
363
364#if ENABLE_IMAGE_TEST
365 o = elm_check_add(ad->pd->win);
366 elm_object_text_set(o, "EvasGL Image");
367 evas_object_smart_callback_add(o, "changed", _evglimg_check_cb, ad);
368 elm_table_pack(t, o, 1, 8, 2, 1);
369 SF(o);
370#else
371 o = elm_check_add(ad->pd->win);
372 elm_object_text_set(o, pbuffer);
373 evas_object_smart_callback_add(o, "changed", _pbuffer_check_cb, ad);
374 if (!ad->tizen)
375 elm_table_pack(t, o, 1, 8, 2, 1);
376 else
377 elm_table_pack(t, o, 3, 3, 1, 1);
378 SF(o);
379 ad->pd->pbuffer_checkbox = o;
380#endif
381
382 if (!ad->tizen)
383 {
384 o = elm_button_add(ad->pd->win);
385 elm_object_text_set(o, "Rotate +90");
386 evas_object_smart_callback_add(o, "clicked", _rotate_cb, ad);
387 elm_table_pack(t, o, 1, 9, 1, 1);
388 SF(o);
389
390 o = elm_button_add(ad->pd->win);
391 elm_object_text_set(o, "Rotate w. resize +90");
392 evas_object_smart_callback_add(o, "clicked", _rotate_resize_cb, ad);
393 elm_table_pack(t, o, 2, 9, 2, 1);
394 SF(o);
395
396 o = elm_button_add(ad->pd->win);
397 elm_object_text_set(o, "Quit");
398 evas_object_smart_callback_add(o, "clicked", _close_cb, ad);
399 elm_table_pack(t, o, 1, 10, 3, 1);
400 SF(o);
401 }
402 else
403 {
404 o = elm_button_add(ad->pd->win);
405 elm_object_text_set(o, "Rotate window by 90 degrees");
406 evas_object_smart_callback_add(o, "clicked", _rotate_resize_cb, ad);
407 elm_table_pack(t, o, 2, 4, 2, 1);
408 SF(o);
409 }
410
411 _glview_create(ad);
412 //ecore_animator_frametime_set(1.0 / 60.0);
413 ad->pd->anim = ecore_animator_add(_anim_cb, ad);
414
415 evas_object_resize(ad->pd->win, 400, 400);
416
417 elm_run();
418 return 0;
419}
420ELM_MAIN()
diff --git a/package.sh b/package.sh
new file mode 100755
index 0000000..fb292fb
--- /dev/null
+++ b/package.sh
@@ -0,0 +1,13 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5rm -rf /tmp/testapp
6git clone .git /tmp/testapp || exit 1
7
8cd /tmp/ || exit 1
9rm -f testapp.tgz
10tar czf testapp.tgz testapp || exit 1
11
12echo "Package ready at: /tmp/testapp.tgz"
13
diff --git a/packaging/evgltest.spec b/packaging/evgltest.spec
new file mode 100644
index 0000000..be36a5d
--- /dev/null
+++ b/packaging/evgltest.spec
@@ -0,0 +1,73 @@
1Name: evasgl_test
2Summary: Test app for evas gl
3Version: 0.1
4Release: 1
5Group: System/Libraries
6License: BSD
7URL: http://www.enlightenment.org/
8Source0: %{name}-%{version}.tar.gz
9Requires(post): /sbin/ldconfig
10Requires(postun): /sbin/ldconfig
11BuildRequires: pkgconfig(eina)
12BuildRequires: pkgconfig(eet)
13BuildRequires: pkgconfig(x11)
14BuildRequires: pkgconfig(xi)
15BuildRequires: pkgconfig(xrender)
16BuildRequires: pkgconfig(fontconfig)
17BuildRequires: pkgconfig(freetype2)
18BuildRequires: pkgconfig(fribidi)
19BuildRequires: pkgconfig(xext)
20BuildRequires: pkgconfig(libpng)
21BuildRequires: pkgconfig(zlib)
22BuildRequires: pkgconfig(harfbuzz)
23BuildRequires: libjpeg-devel
24BuildRequires: giflib-devel
25BuildRequires: pkgconfig(pixman-1)
26BuildRequires: pkgconfig(elementary)
27BuildRequires: pkgconfig(evas)
28BuildRequires: pkgconfig(efreet)
29BuildRequires: pkgconfig(edbus)
30
31%ifarch %{arm}
32BuildRequires: pkgconfig(gles20)
33BuildRequires: pkgconfig(libdri2)
34BuildRequires: pkgconfig(xfixes)
35BuildRequires: pkgconfig(libtbm)
36BuildRequires: pkgconfig(native-buffer)
37%else
38BuildRequires: pkgconfig(gles20)
39%endif
40
41
42%description
43Evas GL Test app
44
45%package devel
46Summary: Test app
47Group: Development/Tools
48Requires: %{name} = %{version}-%{release}
49
50
51%description devel
52Test app for evas gl (empty pkg)
53
54
55%prep
56%setup -q
57
58%build
59cmake -DCMAKE_BUILD_TYPE=Debug
60make %{?jobs:-j%jobs}
61
62
63%install
64rm -rf %{buildroot}
65mkdir -p %{buildroot}/%{_bindir}
66cp %{_builddir}/%{buildsubdir}/evasgl_test %{buildroot}/%{_bindir}/
67
68%files
69%defattr(-,root,root,-)
70%{_bindir}/evasgl_test
71
72%files devel
73
diff --git a/tests.c b/tests.c
new file mode 100644
index 0000000..fe30f9a
--- /dev/null
+++ b/tests.c
@@ -0,0 +1,52 @@
1#include "evasgl_test.h"
2#include "assert.h"
3
4void
5test_extensions(AppData *ad)
6{
7 const char *extensions;
8 void (*func)() = NULL;
9 void (*func2)() = NULL;
10
11 assert(ad);
12 assert(ad->glview);
13
14 extensions = evas_gl_string_query(ad->evasgl, EVAS_GL_EXTENSIONS);
15 assert(extensions && *extensions);
16 fprintf(stdout, "Extensions advertised by Evas GL:\n%s\n", extensions);
17
18 if (strstr(extensions, "GL_NV_fence"))
19 {
20 func = evas_gl_proc_address_get(ad->evasgl, "glIsFenceNV");
21 assert(func);
22 func(0x42);
23 }
24
25 if (strstr(extensions, "GL_ARB_blend_func_extended"))
26 {
27 func = evas_gl_proc_address_get(ad->evasgl, "glGetFragDataIndex");
28 assert(func);
29 }
30
31 if (strstr(extensions, "GL_KHR_debug"))
32 {
33 func = evas_gl_proc_address_get(ad->evasgl, "glDebugMessageControl");
34 func2 = evas_gl_proc_address_get(ad->evasgl, "glDebugMessageControlKHR");
35 assert(func || func2);
36
37 func = evas_gl_proc_address_get(ad->evasgl, "glDebugMessageControlBLAH");
38 assert(!func);
39 }
40
41 if (strstr(extensions, "get_program_binary"))
42 {
43 func = evas_gl_proc_address_get(ad->evasgl, "glGetProgramBinary");
44 func2 = evas_gl_proc_address_get(ad->evasgl, "glGetProgramBinaryOES");
45 assert(func || func2);
46 }
47
48 fprintf(stdout, "GL_VERSION: %s\n", GL()glGetString(GL_VERSION));
49 fprintf(stdout, "GL_EXTENSIONS: %s\n", GL()glGetString(GL_EXTENSIONS));
50
51 fflush(stdout);
52}