mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Material cleanups.
This commit is contained in:
parent
12a6cab9e9
commit
29a7478e0a
@ -7,6 +7,8 @@
|
||||
#include "render_core/render_state.h"
|
||||
|
||||
class FontMaterial : public Material {
|
||||
SFW_OBJECT(FontMaterial, Material);
|
||||
|
||||
public:
|
||||
int get_material_id() {
|
||||
return 11;
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "render_core/render_state.h"
|
||||
|
||||
class TextureMaterial : public Material {
|
||||
SFW_OBJECT(TextureMaterial, Material);
|
||||
|
||||
public:
|
||||
int get_material_id() {
|
||||
return 3;
|
||||
@ -17,7 +19,7 @@ public:
|
||||
set_uniform(camera_matrix_location, RenderState::camera_transform_3d);
|
||||
set_uniform(model_view_matrix_location, RenderState::model_view_matrix_3d);
|
||||
|
||||
if (texture) {
|
||||
if (texture.is_valid()) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture->get_gl_texture());
|
||||
glUniform1i(texture_location, 0);
|
||||
@ -26,7 +28,7 @@ public:
|
||||
|
||||
void setup_uniforms() {
|
||||
projection_matrix_location = get_uniform("u_proj_matrix");
|
||||
camera_matrix_location = get_uniform("u_camera_matrix");
|
||||
camera_matrix_location = get_uniform("u_camera_matrix");
|
||||
model_view_matrix_location = get_uniform("u_model_view_matrix");
|
||||
|
||||
texture_location = get_uniform("u_texture");
|
||||
@ -76,14 +78,12 @@ public:
|
||||
return fragment_shader_source;
|
||||
}
|
||||
|
||||
TextureMaterial() :
|
||||
Material() {
|
||||
TextureMaterial() {
|
||||
projection_matrix_location = 0;
|
||||
camera_matrix_location = 0;
|
||||
model_view_matrix_location = 0;
|
||||
|
||||
texture_location = 0;
|
||||
texture = NULL;
|
||||
}
|
||||
|
||||
GLint projection_matrix_location;
|
||||
@ -92,7 +92,7 @@ public:
|
||||
|
||||
GLint texture_location;
|
||||
|
||||
Texture *texture;
|
||||
Ref<Texture> texture;
|
||||
};
|
||||
|
||||
#endif // COLORED_MATERIAL_H
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "render_core/render_state.h"
|
||||
|
||||
class TextureMaterial2D : public Material {
|
||||
SFW_OBJECT(TextureMaterial2D, Material);
|
||||
|
||||
public:
|
||||
int get_material_id() {
|
||||
return 10;
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "render_core/render_state.h"
|
||||
|
||||
class TransparentTextureMaterial : public Material {
|
||||
SFW_OBJECT(TransparentTextureMaterial, Material);
|
||||
|
||||
public:
|
||||
int get_material_id() {
|
||||
return 4;
|
||||
@ -16,7 +18,7 @@ public:
|
||||
set_uniform(projection_matrix_location, RenderState::projection_matrix_3d);
|
||||
set_uniform(model_view_matrix_location, RenderState::model_view_matrix_3d);
|
||||
|
||||
if (texture) {
|
||||
if (texture.is_valid()) {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture->get_gl_texture());
|
||||
glUniform1i(texture_location, 0);
|
||||
@ -79,10 +81,8 @@ public:
|
||||
return fragment_shader_source;
|
||||
}
|
||||
|
||||
TransparentTextureMaterial() :
|
||||
Material() {
|
||||
TransparentTextureMaterial() {
|
||||
texture_location = 0;
|
||||
texture = NULL;
|
||||
}
|
||||
|
||||
GLint projection_matrix_location;
|
||||
@ -90,7 +90,7 @@ public:
|
||||
|
||||
GLint texture_location;
|
||||
|
||||
Texture *texture;
|
||||
Ref<Texture> texture;
|
||||
};
|
||||
|
||||
#endif // COLORED_MATERIAL_H
|
||||
|
Loading…
Reference in New Issue
Block a user