Material cleanups.

This commit is contained in:
Relintai 2024-01-04 18:39:16 +01:00
parent 12a6cab9e9
commit 29a7478e0a
4 changed files with 15 additions and 11 deletions

View File

@ -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;

View File

@ -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);
@ -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

View File

@ -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;

View File

@ -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