batiste / sdl2-opengl-es Goto Github PK
View Code? Open in Web Editor NEWSDL2.0 and OpenGL ES example for Android
SDL2.0 and OpenGL ES example for Android
Requires SDL2.0 to work. Installing SDL2.0 ----------------- Download it from there: http://www.libsdl.org/hg.php $ ./configure $ make $ sudo make install Installing OpenGL ES --------------------- $ sudo apt-get install libgles2-mesa-dev Build the programms -------------------- $ make
when i try to run your app :
[foo@work batiste-sdl2-opengl-es-cc03603]# ./app_egl
SDL ERROR: file:common.c line:887 error:Invalid window
glCreateShader
open filename assets/vertex-shader-1.vert
Read success
Seek
Final Position (400)
File closed
Memory allocated
SDL_RWFromFile
Read the file
Block read 400
Quit loadFile
Compile shader
glCreateShader
open filename assets/line-shader-1.frag
Read success
Seek
Final Position (155)
File closed
Memory allocated
SDL_RWFromFile
Read the file
Block read 155
Quit loadFile
Compile shader
Error compiling shader:
0:5(1): error: syntax error, unexpected NEW_IDENTIFIER
0.00 frames per second
I tested your program and after some work, I was able to build and test it.
I'll try to attach a patch, fixing some little things, mainly on the Linux side (if unsuccessfull, I'll paste the diff there)/
Thank again for sharing your code !
(pasted, since github attach files seems to accept images only)
diff --git a/Makefile b/Makefile
index 114b998..c16f220 100644
--- a/Makefile
+++ b/Makefile
@@ -4,15 +4,24 @@ LDFLAGS_MESA = -lMesaGL
SDLFLAGS = $(shell sdl2-config --libs --cflags)
CC=gcc
+UNAME_S := $(shell uname -s)
+
+ifeq ($(UNAME_S), Linux) #LINUX
# -lXi -lXmu
all: eglbuild glbuild
glbuild:
eglbuild:
macbuild:
diff --git a/common.c b/common.c
index 163ab9f..6aa03ca 100644
--- a/common.c
+++ b/common.c
@@ -29,12 +29,17 @@
#define CHECK_SDL(...) _checkSDLError(FILE, LINE);
#define CHECK_GL(...) _checkGLError(FILE, LINE);
+#ifdef Linux
+#include <GL/gl.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#else
#include <OpenGL/gl.h>
+#endif
//#include <GLES2/gl2.h>
//#include <GLES2/gl2ext.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -46,7 +51,6 @@ float _mouse_x = 0.0;
float _mouse_y = 0.0;
static Uint32 next_time;
GLuint gvPositionHandle; // shader handler
GLuint gvTexCoordHandle;
GLuint gvSamplerHandle;
@@ -330,6 +334,7 @@ int useProgram(GLuint programObject) {
glEnableVertexAttribArray(gvPositionHandle);
//glEnableVertexAttribArray(gvNormalHandle);
glEnableVertexAttribArray(gvTexCoordHandle);
+
CHECK_GL();
// Set the sampler texture unit to 0
// glUniform1i(gvSamplerHandle, 0);
@@ -343,7 +348,7 @@ struct waveInfos {
int soundpos; /* Current play position */
};
-loadSound(char * filename, struct waveInfos * sound) {
+void loadSound(char * filename, struct waveInfos * sound) {
// Load the WAV
char filename_final[256] = "";
strcpy(filename_final, ASSETS_DIR);
@@ -370,6 +375,8 @@ struct ImageData {
};
typedef struct ImageData ImageData;
+int checkImageDimension(ImageData *);
+
struct TextureInfos {
float x;
float y;
diff --git a/intersection.c b/intersection.c
index fdea25a..bec91f2 100644
--- a/intersection.c
+++ b/intersection.c
@@ -71,7 +71,6 @@ struct Intersection {
int index_p2;
};
int split_vertex(struct TextureInfos * texture, struct Line * line,
struct TextureInfos * texture1, struct TextureInfos * texture2) {
@@ -117,7 +116,6 @@ int split_vertex(struct TextureInfos * texture, struct Line * line,
return nbIntersections;
}
int createNewVertexFromIntersection(
struct Intersection intersections[2],
diff --git a/list.c b/list.c
index f1e8262..e675691 100644
--- a/list.c
+++ b/list.c
@@ -104,9 +104,9 @@ int removeFromList(GenericList *list, ListElement *toRemove) {
void displayList(GenericList *list) {
ListElement *el;
printf("Item %d address %d\n", i, (int)el->data);
fprintf(stderr, "Item %d address %p\n", i, el->data);
double distance_2_points(float x1, float y1, float x2, float y2) {
float distance;
float distance_x = x1 - x2;
--
ericb
I have followed your steps in README and i'm stopped in the last step (fedora 16) :
/usr/bin/ld: /tmp/ccUtpjS7.o: undefined reference to symbol 'sqrtf@@GLIBC_2.2.5'
/usr/bin/ld: note: 'sqrtf@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [eglbuild] Error 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.