Skip to content

Commit

Permalink
Merge PerVertexColor shader into oscimgui
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Jan 7, 2025
1 parent 114526d commit 39e09f9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
9 changes: 0 additions & 9 deletions resources/oscar/shaders/PerVertexColor.frag

This file was deleted.

16 changes: 0 additions & 16 deletions resources/oscar/shaders/PerVertexColor.vert

This file was deleted.

46 changes: 44 additions & 2 deletions src/oscar/UI/oscimgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,48 @@ namespace
}
)";

// HACK: this shouldn't be necessary, but is, because the legacy draw list
// rendering code was dependent on it.
constexpr CStringView c_custom_ui_renderer_vertex_shader_src = R"(
#version 330 core
uniform mat4 uProjMat;
uniform mat4 uViewMat;
uniform mat4 uModelMat;
layout (location = 0) in vec3 aPos;
layout (location = 3) in vec4 aColor;
out vec4 aVertColor;
void main()
{
gl_Position = uProjMat * uViewMat * uModelMat * vec4(aPos, 1.0);
aVertColor = aColor;
}
)";

// HACK: this shouldn't be necessary, but is, because the legacy draw list
// rendering code was dependent on it.
constexpr CStringView c_custom_ui_renderer_fragment_shader_src = R"(
#version 330 core
uniform mat4 uProjMat;
uniform mat4 uViewMat;
uniform mat4 uModelMat;
layout (location = 0) in vec3 aPos;
layout (location = 3) in vec4 aColor;
out vec4 aVertColor;
void main()
{
gl_Position = uProjMat * uViewMat * uModelMat * vec4(aPos, 1.0);
aVertColor = aColor;
}
)";

ImTextureID to_imgui_texture_id(UID id)
{
static_assert(std::is_same_v<ImTextureID, InternalTextureID>);
Expand Down Expand Up @@ -2449,8 +2491,8 @@ void osc::ui::DrawList::render_to(RenderTexture& target)

// solid color material
const Material material{Shader{
App::slurp("oscar/shaders/PerVertexColor.vert"),
App::slurp("oscar/shaders/PerVertexColor.frag"),
c_custom_ui_renderer_vertex_shader_src,
c_custom_ui_renderer_fragment_shader_src,
}};

Camera c;
Expand Down

0 comments on commit 39e09f9

Please sign in to comment.