mirror of
https://github.com/Relintai/sfw.git
synced 2025-01-17 14:47:18 +01:00
Now Shaders and materials use Strings.
This commit is contained in:
parent
d2c3151d73
commit
6837cb1042
@ -15,7 +15,7 @@ void ColorMaterial::setup_uniforms() {
|
|||||||
model_view_matrix_location = get_uniform("u_model_view_matrix");
|
model_view_matrix_location = get_uniform("u_model_view_matrix");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColorMaterial::get_vertex_shader_source() {
|
String ColorMaterial::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_camera_matrix;\n"
|
"uniform mat4 u_camera_matrix;\n"
|
||||||
@ -32,10 +32,10 @@ const char **ColorMaterial::get_vertex_shader_source() {
|
|||||||
"}\n"
|
"}\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColorMaterial::get_fragment_shader_source() {
|
String ColorMaterial::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -46,7 +46,7 @@ const char **ColorMaterial::get_fragment_shader_source() {
|
|||||||
"void main() { gl_FragColor = v_color; }\n"
|
"void main() { gl_FragColor = v_color; }\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorMaterial::ColorMaterial() {
|
ColorMaterial::ColorMaterial() {
|
||||||
|
@ -20,8 +20,8 @@ public:
|
|||||||
void bind_uniforms();
|
void bind_uniforms();
|
||||||
void setup_uniforms();
|
void setup_uniforms();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
ColorMaterial();
|
ColorMaterial();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void ColorMaterial2D::setup_state() {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColorMaterial2D::get_vertex_shader_source() {
|
String ColorMaterial2D::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_model_view_matrix;\n"
|
"uniform mat4 u_model_view_matrix;\n"
|
||||||
@ -37,10 +37,10 @@ const char **ColorMaterial2D::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColorMaterial2D::get_fragment_shader_source() {
|
String ColorMaterial2D::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -53,7 +53,7 @@ const char **ColorMaterial2D::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorMaterial2D::ColorMaterial2D() {
|
ColorMaterial2D::ColorMaterial2D() {
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void unbind();
|
void unbind();
|
||||||
void setup_state();
|
void setup_state();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
ColorMaterial2D();
|
ColorMaterial2D();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ void ColoredMaterial::setup_uniforms() {
|
|||||||
tri_color_uniform_location = get_uniform("fragment_color");
|
tri_color_uniform_location = get_uniform("fragment_color");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColoredMaterial::get_vertex_shader_source() {
|
String ColoredMaterial::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_model_view_matrix;\n"
|
"uniform mat4 u_model_view_matrix;\n"
|
||||||
@ -28,10 +28,10 @@ const char **ColoredMaterial::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **ColoredMaterial::get_fragment_shader_source() {
|
String ColoredMaterial::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -45,7 +45,7 @@ const char **ColoredMaterial::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColoredMaterial::ColoredMaterial() {
|
ColoredMaterial::ColoredMaterial() {
|
||||||
|
@ -20,8 +20,8 @@ public:
|
|||||||
void bind_uniforms();
|
void bind_uniforms();
|
||||||
void setup_uniforms();
|
void setup_uniforms();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
ColoredMaterial();
|
ColoredMaterial();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void FontMaterial::setup_state() {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **FontMaterial::get_vertex_shader_source() {
|
String FontMaterial::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_model_view_matrix;\n"
|
"uniform mat4 u_model_view_matrix;\n"
|
||||||
@ -47,10 +47,10 @@ const char **FontMaterial::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **FontMaterial::get_fragment_shader_source() {
|
String FontMaterial::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -73,7 +73,7 @@ const char **FontMaterial::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontMaterial::FontMaterial() {
|
FontMaterial::FontMaterial() {
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void unbind();
|
void unbind();
|
||||||
void setup_state();
|
void setup_state();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
FontMaterial();
|
FontMaterial();
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
//--STRIP
|
//--STRIP
|
||||||
|
|
||||||
void Material::bind() {
|
void Material::bind() {
|
||||||
//csak main thread!
|
|
||||||
|
|
||||||
if (!shader) {
|
if (!shader) {
|
||||||
shader = ShaderCache::get_singleton()->get_shader(get_material_id());
|
shader = ShaderCache::get_singleton()->get_shader(get_material_id());
|
||||||
|
|
||||||
@ -46,11 +44,11 @@ void Material::setup_uniforms() {
|
|||||||
void Material::setup_state() {
|
void Material::setup_state() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Material::get_uniform(const char *name) {
|
int32_t Material::get_uniform(const String &name) {
|
||||||
int32_t uniform = glGetUniformLocation(shader->program, name);
|
int32_t uniform = glGetUniformLocation(shader->program, name.utf8().get_data());
|
||||||
|
|
||||||
if (uniform == -1) {
|
if (uniform == -1) {
|
||||||
printf("%s is not a valid glsl program variable!\n", name);
|
ERR_PRINT(name + " is not a valid glsl program variable!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return uniform;
|
return uniform;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "core/projection.h"
|
#include "core/projection.h"
|
||||||
#include "core/transform.h"
|
#include "core/transform.h"
|
||||||
#include "core/transform_2d.h"
|
#include "core/transform_2d.h"
|
||||||
|
#include "core/ustring.h"
|
||||||
#include "object/reference.h"
|
#include "object/reference.h"
|
||||||
#include "render_core/shader.h"
|
#include "render_core/shader.h"
|
||||||
//--STRIP
|
//--STRIP
|
||||||
@ -22,10 +23,10 @@ public:
|
|||||||
virtual void bind_uniforms();
|
virtual void bind_uniforms();
|
||||||
virtual void setup_uniforms();
|
virtual void setup_uniforms();
|
||||||
virtual void setup_state();
|
virtual void setup_state();
|
||||||
virtual const char **get_vertex_shader_source() = 0;
|
virtual String get_vertex_shader_source() = 0;
|
||||||
virtual const char **get_fragment_shader_source() = 0;
|
virtual String get_fragment_shader_source() = 0;
|
||||||
|
|
||||||
int32_t get_uniform(const char *name);
|
int32_t get_uniform(const String &name);
|
||||||
|
|
||||||
Material();
|
Material();
|
||||||
virtual ~Material();
|
virtual ~Material();
|
||||||
|
@ -25,6 +25,9 @@ void Shader::unbind() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Shader::compile() {
|
void Shader::compile() {
|
||||||
|
ERR_FAIL_COND(_vertex_shader_source.empty());
|
||||||
|
ERR_FAIL_COND(_fragment_shader_source.empty());
|
||||||
|
|
||||||
if (!program) {
|
if (!program) {
|
||||||
program = glCreateProgram();
|
program = glCreateProgram();
|
||||||
}
|
}
|
||||||
@ -37,9 +40,10 @@ void Shader::compile() {
|
|||||||
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **vertex_shader_source = get_vertex_shader_source();
|
CharString vertex_shader_source = _vertex_shader_source.utf8();
|
||||||
|
const char *vss = vertex_shader_source.get_data();
|
||||||
|
|
||||||
glShaderSource(vertex_shader, 1, vertex_shader_source, NULL);
|
glShaderSource(vertex_shader, 1, &vss, NULL);
|
||||||
glCompileShader(vertex_shader);
|
glCompileShader(vertex_shader);
|
||||||
|
|
||||||
int32_t shader_compiled = GL_FALSE;
|
int32_t shader_compiled = GL_FALSE;
|
||||||
@ -51,9 +55,10 @@ void Shader::compile() {
|
|||||||
|
|
||||||
glAttachShader(program, vertex_shader);
|
glAttachShader(program, vertex_shader);
|
||||||
|
|
||||||
const char **fragment_shader_source = get_fragment_shader_source();
|
CharString fragment_shader_source = _fragment_shader_source.utf8();
|
||||||
|
const char *fss = fragment_shader_source.get_data();
|
||||||
|
|
||||||
glShaderSource(fragment_shader, 1, fragment_shader_source, NULL);
|
glShaderSource(fragment_shader, 1, &fss, NULL);
|
||||||
glCompileShader(fragment_shader);
|
glCompileShader(fragment_shader);
|
||||||
|
|
||||||
shader_compiled = GL_FALSE;
|
shader_compiled = GL_FALSE;
|
||||||
@ -85,49 +90,44 @@ void Shader::destroy() {
|
|||||||
glDeleteProgram(program);
|
glDeleteProgram(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **Shader::get_vertex_shader_source() {
|
String Shader::get_vertex_shader_source() {
|
||||||
return vertex_shader_source;
|
return _vertex_shader_source;
|
||||||
}
|
}
|
||||||
void Shader::set_vertex_shader_source(const char **source) {
|
void Shader::set_vertex_shader_source(const String &source) {
|
||||||
vertex_shader_source = source;
|
_vertex_shader_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **Shader::get_fragment_shader_source() {
|
String Shader::get_fragment_shader_source() {
|
||||||
return fragment_shader_source;
|
return _fragment_shader_source;
|
||||||
}
|
}
|
||||||
void Shader::set_fragment_shader_source(const char **source) {
|
void Shader::set_fragment_shader_source(const String &source) {
|
||||||
fragment_shader_source = source;
|
_fragment_shader_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::print_shader_errors(const uint32_t p_program, const char *name) {
|
void Shader::print_shader_errors(const uint32_t p_program, const String &name) {
|
||||||
int max_length = 5000;
|
int max_length = 5000;
|
||||||
Vector<char> error_log;
|
char error_log[5000];
|
||||||
error_log.resize(max_length);
|
|
||||||
|
|
||||||
glGetShaderInfoLog(p_program, max_length, &max_length, error_log.ptrw());
|
glGetShaderInfoLog(p_program, max_length, &max_length, error_log);
|
||||||
|
|
||||||
printf("Error %s!\n", name);
|
ERR_PRINT("Error " + name + "\n" + String::utf8(error_log, max_length));
|
||||||
printf("%s!\n", error_log.ptr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::print_program_errors(const uint32_t p_program) {
|
void Shader::print_program_errors(const uint32_t p_program) {
|
||||||
if (glIsProgram(program)) {
|
if (glIsProgram(program)) {
|
||||||
int info_length = 0;
|
int info_length = 0;
|
||||||
int max_length = 5000;
|
int max_length = 5000;
|
||||||
|
char info_log[5000];
|
||||||
|
|
||||||
glGetProgramiv(p_program, GL_INFO_LOG_LENGTH, &info_length);
|
glGetProgramiv(p_program, GL_INFO_LOG_LENGTH, &info_length);
|
||||||
|
|
||||||
char *info_log = new char[max_length];
|
|
||||||
|
|
||||||
glGetProgramInfoLog(p_program, max_length, &info_length, info_log);
|
glGetProgramInfoLog(p_program, max_length, &info_length, info_log);
|
||||||
|
|
||||||
if (info_length > 0) {
|
if (info_length > 0) {
|
||||||
printf("%s\n", info_log);
|
ERR_PRINT(String::utf8(info_log, max_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] info_log;
|
|
||||||
} else {
|
} else {
|
||||||
printf("print_program_errors: Not a program!\n");
|
ERR_PRINT("print_program_errors: Not a program!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +135,6 @@ Shader::Shader() {
|
|||||||
vertex_shader = 0;
|
vertex_shader = 0;
|
||||||
fragment_shader = 0;
|
fragment_shader = 0;
|
||||||
program = 0;
|
program = 0;
|
||||||
|
|
||||||
vertex_shader_source = NULL;
|
|
||||||
fragment_shader_source = NULL;
|
|
||||||
}
|
}
|
||||||
Shader::~Shader() {
|
Shader::~Shader() {
|
||||||
destroy();
|
destroy();
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
//--STRIP
|
//--STRIP
|
||||||
|
|
||||||
//--STRIP
|
//--STRIP
|
||||||
#include "render_core/3rd_glad.h"
|
|
||||||
#include "core/hash_map.h"
|
#include "core/hash_map.h"
|
||||||
|
#include "render_core/3rd_glad.h"
|
||||||
//--STRIP
|
//--STRIP
|
||||||
|
|
||||||
class Shader {
|
class Shader {
|
||||||
@ -23,13 +23,13 @@ public:
|
|||||||
void compile();
|
void compile();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
void set_vertex_shader_source(const char **source);
|
void set_vertex_shader_source(const String &source);
|
||||||
|
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
void set_fragment_shader_source(const char **source);
|
void set_fragment_shader_source(const String &source);
|
||||||
|
|
||||||
void print_shader_errors(const uint32_t p_program, const char *name);
|
void print_shader_errors(const uint32_t p_program, const String &name);
|
||||||
void print_program_errors(const uint32_t p_program);
|
void print_program_errors(const uint32_t p_program);
|
||||||
|
|
||||||
Shader();
|
Shader();
|
||||||
@ -42,8 +42,8 @@ public:
|
|||||||
static Shader *current_shader;
|
static Shader *current_shader;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char **vertex_shader_source;
|
String _vertex_shader_source;
|
||||||
const char **fragment_shader_source;
|
String _fragment_shader_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderCache {
|
class ShaderCache {
|
||||||
|
@ -31,7 +31,7 @@ void TextureMaterial::setup_state() {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TextureMaterial::get_vertex_shader_source() {
|
String TextureMaterial::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_camera_matrix;\n"
|
"uniform mat4 u_camera_matrix;\n"
|
||||||
@ -48,10 +48,10 @@ const char **TextureMaterial::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TextureMaterial::get_fragment_shader_source() {
|
String TextureMaterial::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -66,7 +66,7 @@ const char **TextureMaterial::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureMaterial::TextureMaterial() {
|
TextureMaterial::TextureMaterial() {
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void unbind();
|
void unbind();
|
||||||
void setup_state();
|
void setup_state();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
TextureMaterial();
|
TextureMaterial();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void TextureMaterial2D::setup_state() {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TextureMaterial2D::get_vertex_shader_source() {
|
String TextureMaterial2D::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_model_view_matrix;\n"
|
"uniform mat4 u_model_view_matrix;\n"
|
||||||
@ -44,10 +44,10 @@ const char **TextureMaterial2D::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TextureMaterial2D::get_fragment_shader_source() {
|
String TextureMaterial2D::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -69,7 +69,7 @@ const char **TextureMaterial2D::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureMaterial2D::TextureMaterial2D() {
|
TextureMaterial2D::TextureMaterial2D() {
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void unbind();
|
void unbind();
|
||||||
void setup_state();
|
void setup_state();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
TextureMaterial2D();
|
TextureMaterial2D();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void TransparentTextureMaterial::setup_state() {
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TransparentTextureMaterial::get_vertex_shader_source() {
|
String TransparentTextureMaterial::get_vertex_shader_source() {
|
||||||
static const char *vertex_shader_source[] = {
|
static const char *vertex_shader_source[] = {
|
||||||
"uniform mat4 u_proj_matrix;\n"
|
"uniform mat4 u_proj_matrix;\n"
|
||||||
"uniform mat4 u_model_view_matrix;\n"
|
"uniform mat4 u_model_view_matrix;\n"
|
||||||
@ -44,10 +44,10 @@ const char **TransparentTextureMaterial::get_vertex_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return vertex_shader_source;
|
return String(*vertex_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **TransparentTextureMaterial::get_fragment_shader_source() {
|
String TransparentTextureMaterial::get_fragment_shader_source() {
|
||||||
static const char *fragment_shader_source[] = {
|
static const char *fragment_shader_source[] = {
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
@ -68,7 +68,7 @@ const char **TransparentTextureMaterial::get_fragment_shader_source() {
|
|||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
return fragment_shader_source;
|
return String(*fragment_shader_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransparentTextureMaterial::TransparentTextureMaterial() {
|
TransparentTextureMaterial::TransparentTextureMaterial() {
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void unbind();
|
void unbind();
|
||||||
void setup_state();
|
void setup_state();
|
||||||
|
|
||||||
const char **get_vertex_shader_source();
|
String get_vertex_shader_source();
|
||||||
const char **get_fragment_shader_source();
|
String get_fragment_shader_source();
|
||||||
|
|
||||||
TransparentTextureMaterial();
|
TransparentTextureMaterial();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user