Move image node state mapping to renderer gl
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_image.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include "shader.h"
|
||||
#include "app.h"
|
||||
|
||||
@@ -13,7 +14,9 @@ void NodeImage::static_init()
|
||||
m_plane.create<1>(1, 1);
|
||||
m_sampler.create();
|
||||
m_sampler_mips.create();
|
||||
m_sampler_mips.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
m_sampler_mips.set_filter(
|
||||
pp::renderer::gl::linear_mipmap_linear_texture_filter(),
|
||||
pp::renderer::gl::linear_texture_filter());
|
||||
}
|
||||
|
||||
Node* NodeImage::clone_instantiate() const
|
||||
@@ -99,7 +102,7 @@ void NodeImage::draw()
|
||||
auto& sampler = m_use_mipmaps ? m_sampler_mips : m_sampler;
|
||||
sampler.bind(0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(pp::renderer::gl::blend_state());
|
||||
if (m_use_atlas)
|
||||
{
|
||||
ShaderManager::use(kShader::Atlas);
|
||||
@@ -114,7 +117,7 @@ void NodeImage::draw()
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::scale(glm::vec3(m_scale, 1.f)));
|
||||
m_plane.draw_fill();
|
||||
sampler.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(pp::renderer::gl::blend_state());
|
||||
}
|
||||
|
||||
bool NodeImage::set_image(const std::string& path)
|
||||
@@ -155,7 +158,12 @@ void NodeImage::load_url(const std::string& url)
|
||||
int w, h, c;
|
||||
uint8_t* rgba = stbi_load_from_memory(m_remote_asset->m_data, m_remote_asset->m_len, &w, &h, &c, 4);
|
||||
m_remote_texture = std::make_shared<Texture2D>();
|
||||
m_remote_texture->create(w, h, GL_RGBA8, GL_RGBA, rgba);
|
||||
m_remote_texture->create(
|
||||
w,
|
||||
h,
|
||||
pp::renderer::gl::rgba8_internal_format(),
|
||||
pp::renderer::gl::rgba_pixel_format(),
|
||||
rgba);
|
||||
if (m_use_mipmaps)
|
||||
m_remote_texture->create_mipmaps();
|
||||
delete rgba;
|
||||
|
||||
Reference in New Issue
Block a user