Commit e22781cd authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Render the imgui draw list

parent 4d39dc62
qsb --glsl "100 es,120" --hlsl 50 --msl 12 imgui.vert -o imgui.vert.qsb
qsb --glsl "100 es,120" --hlsl 50 --msl 12 imgui.frag -o imgui.frag.qsb
#version 440
layout(location = 0) in vec2 v_texcoord;
layout(location = 1) in vec4 v_color;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 mvp;
float opacity;
} ubuf;
layout(binding = 1) uniform sampler2D tex;
void main()
{
vec4 c = v_color * texture(tex, v_texcoord);
fragColor = vec4(c.rgb, c.a * ubuf.opacity);
}
#version 440
layout(location = 0) in vec4 position;
layout(location = 1) in vec2 texcoord;
layout(location = 2) in vec4 color;
layout(location = 0) out vec2 v_texcoord;
layout(location = 1) out vec4 v_color;
layout(std140, binding = 0) uniform buf {
mat4 mvp;
float opacity;
} ubuf;
out gl_PerVertex { vec4 gl_Position; };
void main()
{
v_texcoord = texcoord;
v_color = color / vec4(255.0);
gl_Position = ubuf.mvp * vec4(position.xy, 0.0, 1.0);
}
......@@ -62,7 +62,7 @@
*/
//---- Use 32-bit vertex indices (default is 16-bit) to allow meshes with more than 64K vertices. Render function needs to support it.
//#define ImDrawIdx unsigned int
#define ImDrawIdx unsigned int
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
/*
......
......@@ -49,7 +49,7 @@
****************************************************************************/
#include "../shared/examplefw.h"
#include <QRhiImgui>
#include "qrhiimgui.h"
static float vertexData[] = {
0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
......@@ -116,6 +116,11 @@ void Window::customInit()
d.ps->setRenderPassDescriptor(m_rp);
d.ps->build();
d.imgui.initialize(m_r);
d.imgui.setFrameFunc([] {
d.imgui.demoWindow();
});
}
void Window::customRelease()
......@@ -152,5 +157,5 @@ void Window::customRender()
cb->draw(36);
cb->endPass();
d.imgui.imguiPass(cb, rt);
d.imgui.imguiPass(cb, rt, m_rp);
}
......@@ -3,7 +3,18 @@ TEMPLATE = app
QT += shadertools rhi
SOURCES = \
imguidemo.cpp
imguidemo.cpp \
qrhiimgui.cpp \
imgui/imgui.cpp \
imgui/imgui_draw.cpp \
imgui/imgui_widgets.cpp \
imgui/imgui_demo.cpp
HEADERS = \
qrhiimgui.h \
qrhiimgui_p.h
INCLUDEPATH += imgui
RESOURCES = \
imguidemo.qrc
......
......@@ -2,5 +2,7 @@
<qresource>
<file alias="color.vert.qsb">../shared/color.vert.qsb</file>
<file alias="color.frag.qsb">../shared/color.frag.qsb</file>
<file>imgui.vert.qsb</file>
<file>imgui.frag.qsb</file>
</qresource>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment