Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add OpenGL 3 port #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MAINTAINERCLEANFILES = \
$(srcdir)/ChangeLog \
`find "$(srcdir)" -type f -name Makefile.in -print`

SUBDIRS = src demo
SUBDIRS = src demo-gl2 demo-gl3

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = glyphy.pc
Expand Down
6 changes: 4 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ AC_CONFIG_FILES([
glyphy.pc
Makefile
src/Makefile
demo/Makefile
demo/android/Makefile
demo-gl2/Makefile
demo-gl2/android/Makefile
demo-gl3/Makefile
demo-gl3/android/Makefile
])

AC_OUTPUT
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions demo/demo-common.h → demo-gl2/demo-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <algorithm>
#include <vector>

#define GL_SILENCE_DEPRECATION 1

/* Tailor config for various platforms. */

#ifdef EMSCRIPTEN
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions demo/glyphy-demo.cc → demo-gl2/glyphy-demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ main (int argc, char** argv)
glutInitWindowSize (WINDOW_W, WINDOW_H);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
int window = glutCreateWindow ("GLyphy Demo");
printf("\nInitialized with Open GL version %s\n\n", glGetString(GL_VERSION));
glutReshapeFunc (reshape_func);
glutDisplayFunc (display_func);
glutKeyboardFunc (keyboard_func);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
105 changes: 105 additions & 0 deletions demo-gl3/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
NULL =
SUBDIRS =
EXTRA_DIST =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
BUILT_SOURCES =
noinst_PROGRAMS =

BUILT_SOURCES += default-text.h default-font.h
EXTRA_DIST += default-text.txt default-font.ttf
default-text.h: default-text.txt $(top_srcdir)/src/stringize
$(AM_V_GEN) $(top_srcdir)/src/stringize "static const char default_text[]" $< > $@
default-font.h: default-font.ttf
$(AM_V_GEN) { \
echo "static const unsigned char default_font[] = {"; \
hexdump -v -e '"x" 1/1 "%02X" " "' < $< | fmt | sed 's/ *x/\\x/g;s/^/"/;s/$$/"/'; \
echo '};'; \
} > $@

if HAVE_FREETYPE2
if HAVE_GL
if HAVE_GLUT

if ANDROID
SUBDIRS += android
else
noinst_PROGRAMS += glyphy-demo
glyphy_demo_CPPFLAGS = \
-I $(top_srcdir)/src \
$(FREETYPE2_CFLAGS) \
$(GL_CFLAGS) \
$(GLEW_CFLAGS) \
$(GLUT_CFLAGS) \
$(NULL)
glyphy_demo_LDADD = \
$(top_builddir)/src/libglyphy.la \
-lm \
$(FREETYPE2_LIBS) \
$(GL_LIBS) \
$(GLEW_LIBS) \
$(GLUT_LIBS) \
$(NULL)
glyphy_demo_SOURCES = \
default-font.h \
default-text.h \
demo-atlas.h \
demo-atlas.cc \
demo-buffer.h \
demo-buffer.cc \
demo-common.h \
demo-font.h \
demo-font.cc \
demo-glstate.h \
demo-glstate.cc \
demo-shader.h \
demo-shader.cc \
demo-view.h \
demo-view.cc \
glyphy-demo.cc \
matrix4x4.h \
matrix4x4.c \
trackball.h \
trackball.c \
$(SHADERHEADERS) \
$(NULL)
endif
SHADERS = \
demo-atlas.glsl \
demo-fshader.glsl \
demo-vshader.glsl \
$(NULL)
SHADERHEADERS = $(patsubst %.glsl,%-glsl.h, $(SHADERS))
BUILT_SOURCES += $(SHADERHEADERS)
EXTRA_DIST += $(SHADERS)

%-glsl.h: %.glsl $(top_srcdir)/src/stringize
$(AM_V_GEN) $(top_srcdir)/src/stringize "static const char *`echo "$<" | \
sed 's@.*/@@;s/[-.]/_/g'`" < "$<" > "[email protected]" && \
mv "[email protected]" "$@" || ($(RM) "[email protected]"; false)

endif
endif
endif


if HAVE_FREETYPE2

noinst_PROGRAMS += glyphy-validate
glyphy_validate_CPPFLAGS = \
-I $(top_srcdir)/src \
$(FREETYPE2_CFLAGS) \
$(NULL)
glyphy_validate_LDADD = \
$(top_builddir)/src/libglyphy.la \
$(FREETYPE2_LIBS) \
$(NULL)
glyphy_validate_SOURCES = \
glyphy-validate.cc \
$(NULL)

endif


-include $(top_srcdir)/git.mk
29 changes: 29 additions & 0 deletions demo-gl3/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.glyphy.glyphy_demo"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk android:minSdkVersion="18" />

<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false">

<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name"
android:value="glyphy-demo" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
<!-- END_INCLUDE(manifest) -->
15 changes: 15 additions & 0 deletions demo-gl3/android/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if ANDROID

all:
NDK_PROJECT_PATH=$(srcdir) ndk-build NDK_DEBUG=1
ant -buildfile $(srcdir)/build.xml debug

clean-local:
NDK_PROJECT_PATH=$(srcdir) ndk-build clean
ant -buildfile $(srcdir)/build.xml clean

endif

GITIGNOREFILES = bin libs obj

-include $(top_srcdir)/git.mk
57 changes: 57 additions & 0 deletions demo-gl3/android/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
To build GLyphy Demo app on Android, follow these steps:

- Download and install Android SDK and NDK, for Android API version 18 or later.

- Install a "standalone" toolchain with the NDK, and set PLATFORM_PREFIX env
var to point to it. You can do this by running, eg:

ndk/build/tools/make-standalone-toolchain.sh \
--platform=android-18 \
--install-dir=/prefix

Adjust platform and install-dir.

- Make sure the cross-compile tools from PLATFORM_PREFIX are in the path.
Ie. that you can run arm-linux-androideabi-gcc.

- Configure and install FreeType. Within the FreeType tarball run:

./configure --host=arm-linux-androideabi --prefix=$PLATFORM_PREFIX --without-png
make install

- Configure and install freeglut-gles2. We want the pre-3.0 version of freeglut
which has native Android support. Get from SVN and run:

cmake -D CMAKE_TOOLCHAIN_FILE=android_toolchain.cmake \
-D CMAKE_INSTALL_PREFIX=$PLATFORM_PREFIX \
-D CMAKE_BUILD_TYPE=Debug \
-D FREEGLUT_GLES2=ON \
-D FREEGLUT_BUILD_DEMOS=NO \
..
make install

- Configure GLyphy:

./configure \
--host=arm-linux-androideabi \
--prefix=$PLATFORM_PREFIX \
--enable-static \
PKG_CONFIG_LIBDIR=$PLATFORM_PREFIX/lib/pkgconfig

- Make and install the GLyphy library (but not the demos):

make -C src install

- Add a local.properties file to demo/android, with:

sdk.dir=/path/to/sdk

By default GLyphy Demo app builds against android-18 target. If you want
to override that, you can add a target=android-XX line to the above file.

- Finally, make the demo app:

make -C demo

- If all goes well, you should now have demo/android/bin/GLyphyDemo-debug.apk

92 changes: 92 additions & 0 deletions demo-gl3/android/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="GLyphyDemo" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:

source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.

For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml

Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.

This file is an integral part of the build system for your
application and should be checked into Version Control Systems.

-->
<property file="ant.properties" />

<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>

<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.

This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).

This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>

<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />

<!-- Import the actual build file.

To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.

***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />

</project>
50 changes: 50 additions & 0 deletions demo-gl3/android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2010 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := freetype
LOCAL_SRC_FILES := $(PLATFORM_PREFIX)/lib/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := glyphy
LOCAL_SRC_FILES := $(PLATFORM_PREFIX)/lib/libglyphy.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := glut
LOCAL_SRC_FILES := $(PLATFORM_PREFIX)/lib/libfreeglut-gles2.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := glyphy-demo
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES := \
../../matrix4x4.c \
../../trackball.c \
../../demo-atlas.cc \
../../demo-buffer.cc \
../../demo-font.cc \
../../demo-glstate.cc \
../../demo-shader.cc \
../../demo-view.cc \
../../glyphy-demo.cc \
$(NULL)
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lz
LOCAL_WHOLE_STATIC_LIBRARIES := gnustl_static freetype glyphy glut
include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)
Loading