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;
|
||||
|
||||
@@ -85,6 +85,7 @@ constexpr std::uint32_t gl_texture_cube_map_negative_y = 0x8518U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_positive_z = 0x8519U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_negative_z = 0x851AU;
|
||||
constexpr std::uint32_t gl_linear = 0x2601U;
|
||||
constexpr std::uint32_t gl_linear_mipmap_linear = 0x2703U;
|
||||
constexpr std::uint32_t gl_nearest = 0x2600U;
|
||||
constexpr std::uint32_t gl_texture_mag_filter = 0x2800U;
|
||||
constexpr std::uint32_t gl_texture_min_filter = 0x2801U;
|
||||
@@ -548,6 +549,11 @@ std::uint32_t linear_texture_filter() noexcept
|
||||
return gl_linear;
|
||||
}
|
||||
|
||||
std::uint32_t linear_mipmap_linear_texture_filter() noexcept
|
||||
{
|
||||
return gl_linear_mipmap_linear;
|
||||
}
|
||||
|
||||
std::uint32_t nearest_texture_filter() noexcept
|
||||
{
|
||||
return gl_nearest;
|
||||
|
||||
@@ -112,6 +112,7 @@ struct OpenGlReadbackFormat {
|
||||
[[nodiscard]] std::uint32_t max_blend_equation() noexcept;
|
||||
[[nodiscard]] std::uint32_t rgba8_internal_format() noexcept;
|
||||
[[nodiscard]] std::uint32_t linear_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t linear_mipmap_linear_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t nearest_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t repeat_texture_wrap() noexcept;
|
||||
[[nodiscard]] std::uint32_t active_texture_unit(std::uint32_t unit_index) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user