Giter Club home page Giter Club logo

sdl2-opengl-es's People

Contributors

batiste avatar greut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdl2-opengl-es's Issues

[patch][Linux] fixing some warnings, cosmetics

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

  • ECHO_MESSAGE = "Linux"
  • CFLAGS += -DLinux
  • LDFLAGS_MESA = -lGLESv2
  • CC += -std=c99
    +endif
# -lXi -lXmu

all:	eglbuild glbuild

glbuild:
  • $(CC) $(CFLAGS) -o app_gl my_app.c $(LDFLAGS_GL) $(SDLFLAGS)
  • $(CC) $(CFLAGS) -o app_gl my_app.c $(LDFLAGS_GL) $(SDLFLAGS)

eglbuild:

  • $(CC) $(CFLAGS) -o app_egl my_app.c -lGLESv2 $(SDLFLAGS)
  • $(CC) $(CFLAGS) -lm -o app_egl my_app.c -lGLESv2 $(SDLFLAGS) $(LDFLAGS_GL)

macbuild:
$(CC) -framework OpenGL -o app_gl my_app.c $(SDLFLAGS)
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("List length %d\n", list->length);
  • fprintf(stderr, "List length %d\n", list->length);
    int i = 1;
    for(el = list->first; el != NULL; el=el->next, i=i+1) {
  •    printf("Item %d address %d\n", i, (int)el->data);
    
  •    fprintf(stderr, "Item %d address %p\n", i, el->data);
    
    }
    -}
    \ No newline at end of file
    +}
    diff --git a/math.c b/math.c
    index 8cc0b1d..b5b6398 100644
    --- a/math.c
    +++ b/math.c
    @@ -1,5 +1,3 @@

double distance_2_points(float x1, float y1, float x2, float y2) {
float distance;
float distance_x = x1 - x2;

--
ericb

Error compiling shader

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

compile error

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.