mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Various small improvements.
This commit is contained in:
parent
7aa7a49bd4
commit
4b2076ce7b
@ -1,6 +1,7 @@
|
||||
|
||||
//--STRIP
|
||||
#include "color_material.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void ColorMaterial::bind_uniforms() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
//--STRIP
|
||||
#include "color_material_2d.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void ColorMaterial2D::bind_uniforms() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
//--STRIP
|
||||
#include "colored_material.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void ColoredMaterial::bind_uniforms() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
//--STRIP
|
||||
#include "font_material.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void FontMaterial::bind_uniforms() {
|
||||
|
@ -29,13 +29,13 @@ int FrameBuffer::create(const int p_width, const int p_height, const int p_msaa_
|
||||
if (msaa % 2 == 0) {
|
||||
--msaa;
|
||||
}
|
||||
|
||||
destroy();
|
||||
|
||||
_fbo_width = p_width;
|
||||
_fbo_height = p_height;
|
||||
_fbo_msaa_count = msaa;
|
||||
|
||||
destroy();
|
||||
|
||||
glGenFramebuffers(1, &_fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
|
||||
|
||||
@ -262,8 +262,8 @@ Vector2i FrameBuffer::get_size() const {
|
||||
void FrameBuffer::blit_color_to(const uint32_t p_destination_framebuffer, const Rect2i &p_rect) {
|
||||
ERR_FAIL_COND(!p_destination_framebuffer);
|
||||
|
||||
int width = p_rect.size.width == 0 ? p_rect.size.width : _fbo_width;
|
||||
int height = p_rect.size.height == 0 ? p_rect.size.height : _fbo_height;
|
||||
int width = p_rect.size.width == 0 ?_fbo_width : p_rect.size.width;
|
||||
int height = p_rect.size.height == 0 ? _fbo_height : p_rect.size.height;
|
||||
|
||||
uint32_t fbo = get_gl_fbo();
|
||||
|
||||
@ -275,8 +275,8 @@ void FrameBuffer::blit_color_to(const uint32_t p_destination_framebuffer, const
|
||||
void FrameBuffer::blit_depth_to(const uint32_t p_destination_framebuffer, const Rect2i &p_rect) {
|
||||
ERR_FAIL_COND(!p_destination_framebuffer);
|
||||
|
||||
int width = p_rect.size.width == 0 ? p_rect.size.width : _fbo_width;
|
||||
int height = p_rect.size.height == 0 ? p_rect.size.height : _fbo_height;
|
||||
int width = p_rect.size.width == 0 ?_fbo_width : p_rect.size.width;
|
||||
int height = p_rect.size.height == 0 ? _fbo_height : p_rect.size.height;
|
||||
|
||||
uint32_t fbo = get_gl_fbo();
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "render_core/material.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void Material::bind() {
|
||||
@ -58,6 +60,10 @@ Material::Material() {
|
||||
shader = NULL;
|
||||
}
|
||||
Material::~Material() {
|
||||
if (current_material == this) {
|
||||
unbind();
|
||||
current_material = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Material::set_uniform(int32_t p_uniform, const Transform &p_transform) {
|
||||
|
@ -224,7 +224,7 @@ void Mesh::upload() {
|
||||
normals_vbo_size = sizeof(float) * normals.size();
|
||||
colors_vbo_size = sizeof(float) * colors.size();
|
||||
uvs_vbo_size = sizeof(float) * uvs.size();
|
||||
indices_vbo_size = sizeof(float) * indices.size();
|
||||
indices_vbo_size = sizeof(uint32_t) * indices.size();
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices_vbo_size + normals_vbo_size + colors_vbo_size + uvs_vbo_size, NULL, GL_STATIC_DRAW);
|
||||
@ -268,7 +268,7 @@ void Mesh::destroy() {
|
||||
}
|
||||
}
|
||||
void Mesh::render() {
|
||||
if (vertices.size() == 0) {
|
||||
if (!vertices_vbo_size) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "render_core/shader.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
bool Shader::bind() {
|
||||
@ -124,7 +126,7 @@ void Shader::print_program_errors(const uint32_t p_program) {
|
||||
glGetProgramInfoLog(p_program, max_length, &info_length, info_log);
|
||||
|
||||
if (info_length > 0) {
|
||||
ERR_PRINT(String::utf8(info_log, max_length));
|
||||
ERR_PRINT(String::utf8(info_log, info_length));
|
||||
}
|
||||
} else {
|
||||
ERR_PRINT("print_program_errors: Not a program!\n");
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
//--STRIP
|
||||
#include "core/hash_map.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
class Shader {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "render_core/app_window.h"
|
||||
|
||||
#include "render_core/frame_buffer.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void Texture::create_from_image(const Ref<Image> &img) {
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "core/vector2i.h"
|
||||
|
||||
#include "object/resource.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
#include "render_core/image.h"
|
||||
//--STRIP
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
//--STRIP
|
||||
#include "texture_material.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void TextureMaterial::bind_uniforms() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
//--STRIP
|
||||
#include "texture_material_2d.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void TextureMaterial2D::bind_uniforms() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
//--STRIP
|
||||
#include "transparent_texture_material.h"
|
||||
#include "render_core/3rd_glad.h"
|
||||
//--STRIP
|
||||
|
||||
void TransparentTextureMaterial::bind_uniforms() {
|
||||
|
Loading…
Reference in New Issue
Block a user