Skip to content

Commit f41caa9

Browse files
committed
- Added basic Android support for OprnGL ES.
1 parent 3b33f4d commit f41caa9

File tree

13 files changed

+401
-33
lines changed

13 files changed

+401
-33
lines changed

GLUS/.cproject

Lines changed: 21 additions & 21 deletions
Large diffs are not rendered by default.

GLUS/Android/jni/Android.mk

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Comment out the version used.
2+
3+
GLES_VERSION := 20
4+
#GLES_VERSION := 30
5+
#GLES_VERSION := 31
6+
7+
LOCAL_PATH := $(call my-dir)
8+
9+
#
10+
# GLUS.
11+
#
12+
13+
include $(CLEAR_VARS)
14+
15+
LOCAL_MODULE := GLUS
16+
17+
# All files.
18+
19+
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../src/*.c)
20+
21+
# Remove specific files.
22+
23+
GL_FILES := $(LOCAL_PATH)/../../src/glus_window_glfw.c
24+
GL_FILES += $(LOCAL_PATH)/../../src/glus_programpipeline.c
25+
GL_FILES += $(LOCAL_PATH)/../../src/glus_program.c
26+
GL_FILES += $(LOCAL_PATH)/../../src/glus_shape_adjacency.c
27+
28+
NOT_USED_FILES := $(LOCAL_PATH)/../../src/glus_memory_nodm.c
29+
30+
OS_FILES := $(wildcard $(LOCAL_PATH)/../../src/glus_os_*.c)
31+
32+
VG_FILES := $(wildcard $(LOCAL_PATH)/../../src/*_vg.c)
33+
34+
ES_FILES := $(wildcard $(LOCAL_PATH)/../../src/*_es.c)
35+
36+
ES2_FILES := $(wildcard $(LOCAL_PATH)/../../src/*_es2.c)
37+
38+
ES31_FILES := $(wildcard $(LOCAL_PATH)/../../src/*_es31.c)
39+
40+
PROJECT_FILES := $(filter-out $(GL_FILES), $(PROJECT_FILES))
41+
PROJECT_FILES := $(filter-out $(OS_FILES), $(PROJECT_FILES))
42+
PROJECT_FILES := $(filter-out $(NOT_USED_FILES), $(PROJECT_FILES))
43+
PROJECT_FILES := $(filter-out $(VG_FILES), $(PROJECT_FILES))
44+
ifeq ($(GLES_VERSION),20)
45+
PROJECT_FILES := $(filter-out $(ES31_FILES), $(PROJECT_FILES))
46+
47+
LOCAL_CFLAGS := -DGLUS_ES2=1
48+
endif
49+
ifeq ($(GLES_VERSION),30)
50+
PROJECT_FILES := $(filter-out $(ES2_FILES), $(PROJECT_FILES))
51+
PROJECT_FILES := $(filter-out $(ES31_FILES), $(PROJECT_FILES))
52+
53+
LOCAL_CFLAGS := -DGLUS_ES3=1
54+
endif
55+
ifeq ($(GLES_VERSION),31)
56+
PROJECT_FILES := $(filter-out $(ES2_FILES), $(PROJECT_FILES))
57+
58+
LOCAL_CFLAGS := -DGLUS_ES31=1
59+
endif
60+
61+
# Change base path in general.
62+
63+
LOCAL_CFLAGS += -DGLUS_BASE_DIRECTORY=\"/sdcard/Download/Binaries/\"
64+
65+
# Add specfic files.
66+
67+
PROJECT_FILES += $(LOCAL_PATH)/../../src/glus_os_android.c
68+
69+
# Generate the final list.
70+
71+
PROJECT_FILES := $(PROJECT_FILES:$(LOCAL_PATH)/%=%)
72+
73+
#
74+
75+
LOCAL_SRC_FILES := $(PROJECT_FILES)
76+
77+
LOCAL_STATIC_LIBRARIES := android_native_app_glue
78+
79+
include $(BUILD_STATIC_LIBRARY)
80+
81+
$(call import-module,android/native_app_glue)

GLUS/Android/jni/Application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
APP_PLATFORM := android-19

GLUS/README.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Yours Norbert Nopper
7373

7474
Changelog:
7575

76+
08.09.2015 - Added basic Android support for OprnGL ES.
77+
7678
11.07.2015 - Improved, updated README.
7779

7880
14.05.2015 - Updated OpenGL ES libraries.

GLUS/src/GLUS/glus_define.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
#define GLUS_VERTICES_FACTOR 4
8080
#define GLUS_VERTICES_DIVISOR 4
8181

82-
#define GLUS_MAX_STRING 256
82+
#define GLUS_MAX_STRING 256
83+
84+
#define GLUS_MAX_FILENAME 2048
85+
86+
#ifndef GLUS_BASE_DIRECTORY
87+
#define GLUS_BASE_DIRECTORY ""
88+
#endif
8389

8490
#endif /* GLUS_DEFINE_H_ */

GLUS/src/GLUS/glus_file.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ typedef struct _GLUSbinaryfile
5252

5353
} GLUSbinaryfile;
5454

55+
/**
56+
* Opens the file whose name is specified in the parameter filename and
57+
* associates it with a stream that can be identified in future operations by the FILE pointer returned.
58+
*
59+
* @param filename C string containing the name of the file to be opened.
60+
* @param mode C string containing a file access mode
61+
*
62+
* @return If the file is successfully opened, the function returns a pointer to a FILE object that can be used to identify the stream on future operations.
63+
* Otherwise, a null pointer is returned.
64+
*/
65+
GLUSAPI FILE* GLUSAPIENTRY glusFileOpen(const char * filename, const char * mode);
66+
5567
#endif /* GLUS_FILE_H_ */

GLUS/src/glus_file.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@
1717

1818
#include "GL/glus.h"
1919

20+
FILE* GLUSAPIENTRY glusFileOpen(const char * filename, const char * mode)
21+
{
22+
char buffer[GLUS_MAX_FILENAME];
23+
24+
if (!filename)
25+
{
26+
return 0;
27+
}
28+
29+
if (strlen(filename) + strlen(GLUS_BASE_DIRECTORY) >= GLUS_MAX_FILENAME)
30+
{
31+
return 0;
32+
}
33+
34+
strcpy(buffer, GLUS_BASE_DIRECTORY);
35+
strcat(buffer, filename);
36+
37+
return fopen(buffer, mode);
38+
}
39+
2040
GLUSboolean _glusFileCheckRead(FILE* f, size_t actualRead, size_t expectedRead)
2141
{
2242
if (!f)

GLUS/src/glus_file_binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GLUSboolean GLUSAPIENTRY glusFileLoadBinary(const GLUSchar* filename, GLUSbinary
3636

3737
binaryfile->length = 0;
3838

39-
f = fopen(filename, "rb");
39+
f = glusFileOpen(filename, "rb");
4040

4141
if (!f)
4242
{
@@ -100,7 +100,7 @@ GLUSboolean GLUSAPIENTRY glusFileSaveBinary(const GLUSchar* filename, const GLUS
100100
return GLUS_FALSE;
101101
}
102102

103-
file = fopen(filename, "wb");
103+
file = glusFileOpen(filename, "wb");
104104

105105
if (!file)
106106
{

GLUS/src/glus_file_text.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GLUSboolean GLUSAPIENTRY glusFileLoadText(const GLUSchar* filename, GLUStextfile
3636

3737
textfile->length = 0;
3838

39-
f = fopen(filename, "rb");
39+
f = glusFileOpen(filename, "rb");
4040

4141
if (!f)
4242
{
@@ -100,7 +100,7 @@ GLUSboolean GLUSAPIENTRY glusFileSaveText(const GLUSchar* filename, const GLUSte
100100
return GLUS_FALSE;
101101
}
102102

103-
file = fopen(filename, "w");
103+
file = glusFileOpen(filename, "w");
104104

105105
if (!file)
106106
{

GLUS/src/glus_image_hdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ GLUSboolean GLUSAPIENTRY glusImageLoadHdr(const GLUSchar* filename, GLUShdrimage
219219
hdrimage->data = 0;
220220

221221
// open filename in "read binary" mode
222-
file = fopen(filename, "rb");
222+
file = glusFileOpen(filename, "rb");
223223

224224
if (!file)
225225
{
@@ -496,7 +496,7 @@ GLUSboolean GLUSAPIENTRY glusImageSaveHdr(const GLUSchar* filename, const GLUShd
496496
}
497497

498498
// open filename in "write binary" mode
499-
file = fopen(filename, "wb");
499+
file = glusFileOpen(filename, "wb");
500500

501501
if (!file)
502502
{

0 commit comments

Comments
 (0)