Merge pull request #15 from xsacha/master

New defines; iOS support
This commit is contained in:
Henrik Rydgård committed 2012-11-26 02:31:09 -08:00
commit 5ca7692912
13 files changed
+59 -123

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ inline void Crash() { __asm { int 3 }; }
#else
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(ARM)
#undef Crash
inline void Crash() {
+22
View File
@@ -0,0 +1,22 @@
#ifndef _GL_COMMON_H
#define _GL_COMMON_H
#if defined(USING_GLES2)
#if defined(IOS)
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
typedef char GLchar;
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#else // OpenGL
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#endif //_GL_COMMON_H
+3 -15
View File
@@ -1,16 +1,4 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
typedef char GLchar;
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "gfx/gl_common.h"
#include "base/logging.h"
void glCheckzor(const char *file, int line) {
@@ -20,7 +8,7 @@ void glCheckzor(const char *file, int line) {
}
}
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
#if 0
void log_callback(GLenum source, GLenum type,
GLuint id,
@@ -56,7 +44,7 @@ void log_callback(GLenum source, GLenum type,
#endif
void gl_log_enable() {
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
#if 0
glEnable(DEBUG_OUTPUT_SYNCHRONOUS_ARB); // TODO: Look into disabling, for more perf
glDebugMessageCallback(&log_callback, 0);
+1 -1
View File
@@ -6,7 +6,7 @@
void gl_log_enable();
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
//#define DEBUG_OPENGL
#endif
+9 -20
View File
@@ -1,30 +1,19 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
#include "image/png_load.h"
#include "ext/etcpack/etcdec.h"
#endif
#include "image/zim_load.h"
#include "base/logging.h"
#include "texture.h"
#include "gfx/texture.h"
#include "gfx/texture_gen.h"
#include "gfx/gl_debug_log.h"
#include "gfx/gl_lost_manager.h"
#include "gfx/gl_common.h"
Texture::Texture() : id_(0) {
register_gl_resource_holder(this);
@@ -76,7 +65,7 @@ bool Texture::Load(const char *filename) {
glBindTexture(GL_TEXTURE_2D, id_);
if (bpp == 1) {
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(USING_GLES2)
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
#else
glTexImage2D(GL_TEXTURE_2D, 0, 1, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
@@ -118,7 +107,7 @@ bool Texture::Load(const char *filename) {
const char *name = fn;
if (zim && 0==memcmp(name, "Media/textures/", strlen("Media/textures"))) name += strlen("Media/textures/");
len = strlen(name);
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
if (!strcmp("png", &name[len-3]) ||
!strcmp("PNG", &name[len-3])) {
if (!LoadPNG(fn)) {
@@ -141,7 +130,7 @@ bool Texture::Load(const char *filename) {
return false;
}
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
bool Texture::LoadPNG(const char *filename) {
unsigned char *image_data;
if (1 != pngLoad(filename, &width_, &height_, &image_data, false)) {
@@ -184,7 +173,7 @@ bool Texture::LoadXOR() {
}
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
// Allocates using new[], doesn't free.
uint8_t *ETC1ToRGBA(uint8_t *etc1, int width, int height) {
@@ -244,7 +233,7 @@ bool Texture::LoadZIM(const char *filename) {
int data_h = height[l];
if (data_w < 4) data_w = 4;
if (data_h < 4) data_h = 4;
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(USING_GLES2)
int compressed_image_bytes = data_w * data_h / 2;
glCompressedTexImage2D(GL_TEXTURE_2D, l, GL_ETC1_RGB8_OES, width[l], height[l], 0, compressed_image_bytes, image_data[l]);
GL_CHECK();
@@ -255,7 +244,7 @@ bool Texture::LoadZIM(const char *filename) {
#endif
}
GL_CHECK();
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, num_levels - 2);
#endif
} else {
+1 -1
View File
@@ -14,7 +14,7 @@ public:
~Texture();
bool LoadZIM(const char *filename);
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
bool LoadPNG(const char *filename);
#endif
bool LoadXOR(); // Loads a placeholder texture.
+7 -12
View File
@@ -1,23 +1,18 @@
// WIP, please ignore
#include "gfx/texture.h"
#include <d3d11_1.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
#include "image/png_load.h"
#include "ext/etcpack/etcdec.h"
#endif
#include "image/zim_load.h"
#include "base/logging.h"
#include "texture.h"
#include "gfx/texture.h"
#include "gfx/texture_gen.h"
#include "gfx/gl_debug_log.h"
#include "gfx/gl_lost_manager.h"
@@ -98,7 +93,7 @@ bool Texture::Load(const char *filename) {
const char *name = fn;
if (zim && 0 == memcmp(name, "Media/textures/", strlen("Media/textures"))) name += strlen("Media/textures/");
len = strlen(name);
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
if (!strcmp("png", &name[len-3]) ||
!strcmp("PNG", &name[len-3])) {
if (!LoadPNG(fn)) {
@@ -122,7 +117,7 @@ bool Texture::Load(const char *filename) {
}
#ifndef METRO
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
bool Texture::LoadPNG(const char *filename) {
unsigned char *image_data;
if (1 != pngLoad(filename, &width_, &height_, &image_data, false)) {
@@ -176,7 +171,7 @@ bool Texture::LoadXOR() {
}
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
// Allocates using new[], doesn't free.
uint8_t *ETC1ToRGBA(uint8_t *etc1, int width, int height) {
@@ -236,7 +231,7 @@ bool Texture::LoadZIM(const char *filename) {
int data_h = height[l];
if (data_w < 4) data_w = 4;
if (data_h < 4) data_h = 4;
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(USING_GLES2)
int compressed_image_bytes = data_w * data_h / 2;
glCompressedTexImage2D(GL_TEXTURE_2D, l, GL_ETC1_RGB8_OES, width[l], height[l], 0, compressed_image_bytes, image_data[l]);
GL_CHECK();
@@ -247,7 +242,7 @@ bool Texture::LoadZIM(const char *filename) {
#endif
}
GL_CHECK();
#if !defined(ANDROID) && !defined(BLACKBERRY)
#if !defined(USING_GLES2)
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, num_levels - 2);
#endif
} else {
+1 -12
View File
@@ -1,15 +1,3 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <algorithm>
#include <cmath>
@@ -21,6 +9,7 @@
#include "gfx_es2/gl_state.h"
#include "gfx/texture_atlas.h"
#include "gfx/gl_debug_log.h"
#include "gfx/gl_common.h"
enum {
// Enough?
+8 -21
View File
@@ -1,29 +1,16 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <string.h>
#include "base/logging.h"
#include "gfx_es2/fbo.h"
#include "gfx/gl_common.h"
#if defined(USING_GLES2)
#define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER
#define GL_DRAW_FRAMEBUFFER GL_FRAMEBUFFER
#define GL_RGBA8 GL_RGBA
#ifndef GL_DEPTH_COMPONENT24
#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES
#endif
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <string.h>
#include "base/logging.h"
#include "gfx_es2/fbo.h"
// TODO: Move out
#if defined(ANDROID) || defined(BLACKBERRY)
#define GLES
#endif
// TODO: Breakout this GL extension checker in its own file.
@@ -94,7 +81,7 @@ FBO *fbo_create(int width, int height, int num_color_textures, bool z_stencil) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#ifdef GLES
#ifdef USING_GLES2
if (gl_extensions.OES_packed_depth_stencil) {
ILOG("Creating FBO using DEPTH24_STENCIL8");
// Standard method
+2 -12
View File
@@ -1,18 +1,8 @@
#pragma once
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <functional>
#include <string.h>
#include "gfx/gl_common.h"
// OpenGL state cache. Should convert all code to use this instead of directly calling glEnable etc,
@@ -128,7 +118,7 @@ public:
BoolState<GL_DEPTH_TEST, false> depthTest;
STATE1(glDepthFunc, GLenum, GL_LESS) depthFunc;
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(USING_GLES2)
STATE2(glDepthRangef, float, float, 0.f, 1.f) depthRange;
#else
STATE2(glDepthRange, double, double, 0.0, 1.0) depthRange;
+2 -15
View File
@@ -1,16 +1,3 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
typedef char GLchar;
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <set>
#include <stdio.h>
@@ -19,7 +6,7 @@ typedef char GLchar;
#include "base/logging.h"
#include "file/vfs.h"
#include "gfx_es2/glsl_program.h"
#include "glsl_program.h"
static std::set<GLSLProgram *> active_programs;
@@ -37,7 +24,7 @@ bool CompileShader(const char *source, GLuint shader, const char *filename) {
ELOG("Error in shader compilation of %s!\n", filename);
ELOG("Info log: %s\n", infoLog);
ELOG("Shader source:\n%s\n", (const char *)source);
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(ARM)
exit(1);
#endif
return false;
+1 -12
View File
@@ -4,22 +4,11 @@
#ifndef _RENDER_UTIL
#define _RENDER_UTIL
#if defined(ANDROID) || defined(BLACKBERRY)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <map>
#include <time.h>
#include "gfx/gl_lost_manager.h"
#include "gfx/gl_common.h"
// Represent a compiled and linked vshader/fshader pair.
// A just-constructed object is valid but cannot be used as a shader program, meaning that
+1 -1
View File
@@ -17,7 +17,7 @@ unsigned int GenerateRandomNumber() {
#include <math.h>
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(ARM)
void EnableFZ()
{