emscripten support

This commit is contained in:
Konstantin Käfer
2014-01-07 16:52:23 +01:00
parent 044a7b5dcd
commit 528eaf475e
24 changed files with 406 additions and 94 deletions

View File

@@ -1,8 +1,6 @@
#ifndef LLMR_GEOMETRY_LINEVERTEXBUFFER
#define LLMR_GEOMETRY_LINEVERTEXBUFFER
#include "../platform/gl.hpp"
#include <vector>
namespace llmr {
@@ -18,7 +16,7 @@ public:
void bind();
private:
std::vector<uint16_t> array;
GLuint buffer;
uint32_t buffer;
};
}

View File

@@ -1,7 +1,9 @@
#ifndef LLMR_RENDERER_GL
#define LLMR_RENDERER_GL
#ifdef __APPLE__
#ifdef EMSCRIPTEN
#include <GLES2/gl2.h>
#elif __APPLE__
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#include <OpenGLES/ES2/gl.h>

View File

@@ -8,8 +8,6 @@ class tile;
class platform {
public:
platform(void *obj) : obj(obj) {}
const char *shaderSource(const char *name, const char *extension);
void restart();
void request(tile *tile);

View File

@@ -1,8 +1,6 @@
#ifndef LLMR_RENDERER_PAINTER
#define LLMR_RENDERER_PAINTER
#include "../platform/gl.hpp"
#include "shader-fill.hpp"
#include "shader-line.hpp"
@@ -19,7 +17,7 @@ public:
void setup();
void teardown();
void resize(GLuint new_width, GLuint new_height);
void resize(uint32_t new_width, uint32_t new_height);
void viewport();
@@ -38,16 +36,16 @@ public:
private:
platform *platform;
transform *transform;
GLuint width, height;
GLfloat matrix[16];
uint32_t width, height;
float matrix[16];
Shader *currentShader;
FillShader *fillShader;
LineShader *lineShader;
GLuint vertexArray;
GLuint triangleVertexBuffer;
GLuint fillVertexBuffer;
uint32_t vertexArray;
uint32_t triangleVertexBuffer;
uint32_t fillVertexBuffer;
};
}

View File

@@ -7,11 +7,11 @@ namespace llmr {
class FillShader : public Shader {
public:
FillShader(const GLchar *vertex, const GLchar *fragment);
FillShader();
GLint a_pos;
GLint u_matrix;
GLint u_color;
int32_t a_pos;
int32_t u_matrix;
int32_t u_color;
};
}

View File

@@ -7,11 +7,11 @@ namespace llmr {
class LineShader : public Shader {
public:
LineShader(const GLchar *vertex, const GLchar *fragment);
LineShader();
GLint a_pos;
GLint u_matrix;
GLint u_color;
int32_t a_pos;
int32_t u_matrix;
int32_t u_color;
};
}

View File

@@ -1,21 +1,20 @@
#ifndef LLMR_RENDERER_SHADER
#define LLMR_RENDERER_SHADER
#include "../platform/gl.hpp"
#include <vector>
namespace llmr {
class Shader {
public:
Shader(const GLchar *vertex, const GLchar *fragment);
Shader(const char *vertex, const char *fragment);
~Shader();
bool valid;
GLuint program;
std::vector<GLuint> attributes;
uint32_t program;
std::vector<uint32_t> attributes;
private:
bool compileShader(GLuint *shader, GLenum type, const GLchar *source);
bool compileShader(uint32_t *shader, uint32_t type, const char *source);
};
}

View File

@@ -0,0 +1,28 @@
// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
#ifndef LLMR_SHADER_SHADERS
#define LLMR_SHADER_SHADERS
#ifdef __cplusplus
extern "C" {
#endif
struct llmr_shader {
const char *vertex;
const char *fragment;
};
typedef struct llmr_shader llmr_shader_t;
enum {
FILL_SHADER,
LINE_SHADER,
SHADER_COUNT
};
extern const llmr_shader_t llmr_shaders[SHADER_COUNT];
#ifdef __cplusplus
}
#endif
#endif