istereo
changeset 15:32503603eb7d
ah!
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Wed, 07 Sep 2011 09:17:15 +0300 |
parents | b39d8607f4bb |
children | 20a9d3db38cb |
files | src/config.h src/opengl.h src/respath.c src/tex.c |
diffstat | 4 files changed, 35 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/config.h Wed Sep 07 09:17:15 2011 +0300 1.3 @@ -0,0 +1,8 @@ 1.4 +#ifndef CONFIG_H_ 1.5 +#define CONFIG_H_ 1.6 + 1.7 +#if defined(__IPHONE_3_0) || defined(__IPHONE_3_2) || defined(__IPHONE_4_0) 1.8 +#define IPHONE 1.9 +#endif 1.10 + 1.11 +#endif /* CONFIG_H_ */
2.1 --- a/src/opengl.h Wed Sep 07 09:03:51 2011 +0300 2.2 +++ b/src/opengl.h Wed Sep 07 09:17:15 2011 +0300 2.3 @@ -1,4 +1,9 @@ 2.4 -#if defined(__IPHONE_3_0) || defined(__IPHONE_3_2) || defined(__IPHONE_4_0) 2.5 +#ifndef OPENGL_H_ 2.6 +#define OPENGL_H_ 2.7 + 2.8 +#include "config.h" 2.9 + 2.10 +#ifdef IPHONE 2.11 #include <OpenGLES/ES2/gl.h> 2.12 #else 2.13 2.14 @@ -10,4 +15,6 @@ 2.15 #include <GL/glut.h> 2.16 #endif /* __APPLE__ */ 2.17 2.18 -#endif 2.19 +#endif /* IPHONE */ 2.20 + 2.21 +#endif /* OPENGL_H_ */
3.1 --- a/src/respath.c Wed Sep 07 09:03:51 2011 +0300 3.2 +++ b/src/respath.c Wed Sep 07 09:17:15 2011 +0300 3.3 @@ -4,9 +4,9 @@ 3.4 #include <errno.h> 3.5 #include <unistd.h> 3.6 #include "respath.h" 3.7 +#include "config.h" 3.8 3.9 -#if defined(__IPHONE_3_0) || defined(__IPHONE_3_2) || defined(__IPHONE_4_0) 3.10 -#define IPHONE 3.11 +#ifdef IPHONE 3.12 #include <CoreFoundation/CoreFoundation.h> 3.13 #endif 3.14
4.1 --- a/src/tex.c Wed Sep 07 09:03:51 2011 +0300 4.2 +++ b/src/tex.c Wed Sep 07 09:17:15 2011 +0300 4.3 @@ -4,6 +4,7 @@ 4.4 #include <errno.h> 4.5 #include "opengl.h" 4.6 #include "tex.h" 4.7 +#include "config.h" 4.8 4.9 unsigned int load_texture(const char *fname) 4.10 { 4.11 @@ -55,3 +56,18 @@ 4.12 4.13 return tex; 4.14 } 4.15 + 4.16 +void bind_texture(unsigned int tex, int unit) 4.17 +{ 4.18 + glActiveTexture(GL_TEXTURE0 + unit); 4.19 + 4.20 +#ifndef IPHONE 4.21 + if(tex) { 4.22 + glEnable(GL_TEXTURE_2D); 4.23 + } else { 4.24 + glDisable(GL_TEXTURE_2D); 4.25 + } 4.26 +#endif 4.27 + 4.28 + glBindTexture(GL_TEXTURE_2D, tex); 4.29 +}