[waffle] [PATCH] waffle: make gl_basic to work with nacl
Tapani Pälli
tapani.palli at intel.com
Wed Dec 17 05:12:18 PST 2014
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
.gitignore | 2 ++
examples/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++
examples/gl_basic.c | 17 +++++++++++++++++
examples/index.html | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+)
create mode 100644 examples/index.html
diff --git a/.gitignore b/.gitignore
index 6981cd7..a1161e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,8 @@ Makefile
/bin/gl_basic
/bin/gl_basic_test
+/bin/gl_basic_nacl.nexe
+/bin/gl_basic_nacl.nmf
/bin/simple-x11-egl
/bin/wflinfo
/doc/html/man/waffle.7.html
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 75e1c0b..cf75165 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -17,6 +17,36 @@ if((waffle_on_linux) AND (waffle_has_x11_egl))
endif()
# ----------------------------------------------------------------------------
+# Target: gl_basic_nacl (executable + JSON manifest file)
+# ----------------------------------------------------------------------------
+if (waffle_has_nacl)
+ add_executable(gl_basic_nacl.nexe gl_basic.c)
+ include_directories(${nacl_INCLUDE_DIRS})
+
+ # this is done to get rid of -Werror=implicit-function-declaration
+ # which results in error when compiling against ppapi_simple
+ set(CMAKE_C_FLAGS "--std=c99")
+
+ target_link_libraries(gl_basic_nacl.nexe ${waffle_libname} ${nacl_LDFLAGS} -lppapi_simple -lnacl_io -lppapi_gles2)
+
+ # create .nmf file that contains JSON manifest for the .nexe required by NaCl
+ add_custom_command(
+ OUTPUT gl_basic_nacl.nmf
+ COMMAND ${nacl_root}/tools/create_nmf.py -L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gl_basic_nacl.nexe > ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gl_basic_nacl.nmf
+ DEPENDS gl_basic_nacl.nexe
+ COMMENT "Create JSON manifest"
+ VERBATIM
+ )
+
+ add_custom_target(CreateJSONManifest ALL
+ DEPENDS gl_basic_nacl.nmf)
+
+ # install index.html that loads gl_basic_nacl.nmf
+ file(INSTALL index.html DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+
+endif()
+
+# ----------------------------------------------------------------------------
# Target: gl_basic (executable)
# ----------------------------------------------------------------------------
diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index fb62d52..371e423 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -508,8 +508,16 @@ removeXcodeArgs(int *argc, char **argv)
#endif // __APPLE__
+#ifdef __native_client__
+#include "ppapi_simple/ps_main.h"
+int basic_test_main(int argc, char **argv);
+PPAPI_SIMPLE_REGISTER_MAIN(basic_test_main)
+int
+basic_test_main(int argc, char **argv)
+#else
int
main(int argc, char **argv)
+#endif
{
bool ok;
int i;
@@ -530,9 +538,18 @@ main(int argc, char **argv)
cocoa_init();
#endif
+ #ifndef __native_client__
ok = parse_args(argc, argv, &opts);
if (!ok)
exit(EXIT_FAILURE);
+ #else
+ // Fixed arguments for native client.
+ opts.context_api = WAFFLE_CONTEXT_OPENGL_ES2;
+ opts.platform = WAFFLE_PLATFORM_NACL;
+ opts.dl = WAFFLE_DL_OPENGL_ES2;
+ opts.context_profile = WAFFLE_NONE;
+ opts.context_version = -1;
+ #endif
i = 0;
init_attrib_list[i++] = WAFFLE_PLATFORM;
diff --git a/examples/index.html b/examples/index.html
new file mode 100644
index 0000000..fdc5fc1
--- /dev/null
+++ b/examples/index.html
@@ -0,0 +1,39 @@
+<!--
+// Copyright 2014 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Expires" content="-1">
+ <title>Waffle NaCl example</title>
+</head>
+
+<body>
+ <embed id="waffle" src="gl_basic_nacl.nmf" type="application/x-nacl"/>
+</body>
+</html>
--
1.9.3
More information about the waffle
mailing list