Comments (9)
Yes indeed It need extra for to add more data etc.
https://github.com/soufianekhiat/ImPlatform/blob/main/ImPlatform/ImPlatform.cpp#L1173
If I need another Vertex Format I'll need to create my own data struct for draw call, and by pass the ImDrawList pass.
Interpretation of that available on ImPlatform:
https://github.com/soufianekhiat/ImPlatform/blob/main/ImPlatformDemo/main.cpp#L106
https://github.com/soufianekhiat/ImPlatform/blob/main/ImPlatformDemo/main.cpp#L201
https://github.com/soufianekhiat/ImPlatform/blob/main/ImPlatformDemo/main.cpp#L201
Hidden under 'IM_SUPPORT_CUSTOM_SHADER' while I don't support "enough" backend.
from imgui.
This code is not working, and produce a gpu hang.
I'm not sure how we can help, it's seems likely a problem with your use of DX11.
It will be a simpler (no brainer) to have a trivial pixel shader with 4 vertices instead.
It doesn't seem simpler to me IMHO because you are going to need lots of shader variants.
But maybe you can find a way to let dear imgui generate the mesh and only act on the shader.
from imgui.
I'm not sure how we can help, it's seems likely a problem with your use of DX11.
If it's dx11 problem I can work on it. I never saw a proper usage of draw callback I'm not sure of the proper use.
It doesn't seem simpler to me IMHO because you are going to need lots of shader variants.
But maybe you can find a way to let dear imgui generate the mesh and only act on the shader.
True! More shader variant, but traded for more flexibility, for a simple linear gradient I need lot of vertices (based on where the gradient start end).
What do you mean by the last sentence?
Current I had to tesselate the geometry
https://github.com/soufianekhiat/DearWidgets/blob/rework/src/api/dear_widgets.cpp#L2078
From a simple geometry:
https://github.com/soufianekhiat/DearWidgets/blob/rework/src/api/dear_widgets.cpp#L2355
To have a sense of a simple linear gradient:
https://github.com/soufianekhiat/DearWidgets/blob/rework/src/api/dear_widgets.cpp#L2439
from imgui.
Here an illustration of the problem:
from imgui.
You should probably use RenderDoc or another gpu debugger to understand why your code is crashing.
What do you mean by the last sentence?
DrawQuadWithCustomShader output a simple quad which can already be output by ImDrawList, so maybe you can simply your callback logic to set shader + some uniforms for your shader, and not attempt to create/bind buffers.
AddCallback(bind your shader and data)
AddRectFilled()
AddCallback(ImDrawCallback_ResetRenderState)
from imgui.
[Fixed]
ImGui::Begin( "Custom Shader" );
ImDrawList* draw = ImGui::GetWindowDrawList();
ImVec2 cur = ImGui::GetCursorScreenPos();
draw->AddCallback( &DrawCustomShaderQuad, &shader );
ImRect bb( cur, cur + ImGui::GetContentRegionAvail() );
draw->AddImageQuad( img, bb.GetBL(), bb.GetBR(), bb.GetTR(), bb.GetTL(), ImVec2( 0, 0 ), ImVec2( 1, 0 ), ImVec2( 1, 1 ), ImVec2( 0, 1 ), IM_COL32_WHITE );
draw->AddCallback( ImDrawCallback_ResetRenderState, NULL );
ImGui::End();
Your second recommendation is much simple, it simplify the memory management etc. And rely on unique Vertex Buffer.
void DrawCustomShaderQuad( const ImDrawList* parent_list, const ImDrawCmd* cmd )
{
ImPlatform::ImShader* shaders = ( ImPlatform::ImShader* )cmd->UserCallbackData;
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
ID3D11DeviceContext* ctx = bd->pd3dDeviceContext;
ctx->PSSetShader( ( ID3D11PixelShader* )( shaders->ps ), nullptr, 0 );
}
from imgui.
I guess you’ll need to pass some extra data to your shader but that’s the general idea yes (as long as the vertex format used by ImDrawList is sufficient for you).
from imgui.
Sidenote to have it portable for GLSL and GLSL I prefix all shaders with:
https://github.com/soufianekhiat/ImPlatform/blob/main/ImPlatform/ImPlatform.cpp#L1016
from imgui.
Good to hear. Do you need anything else on my end or can we close this?
from imgui.
Related Issues (20)
- Child windows and docking + IsWindowFocused HOT 3
- Table Not Automatically Adjusting Column width to contained controls. HOT 4
- Automatic button color change on hover HOT 2
- SDL_SetTextInputArea (in ImGui 1.90.9) no longer available >>> SDL_SetTextInputRect HOT 3
- Is Carriage Return usable is window label? HOT 1
- [Bug?] Large (font size) merged fonts leading to blocky, fat text HOT 1
- How to never steal keyboard/window focus but process mouse and keyboard keys ? HOT 3
- Trying to get ImGui to work in high dpi mode with sdl3 renderer backend but its not actually drawing in high dpi.
- I think it's a very old bug in the tables. HOT 1
- Scroll (SetScrollHereY) precision issue with messy font size float (and solution) HOT 3
- FullScreen Mode Issue on MacBook Air M3: Toolbar Buttons Misaligned and Unresponsive Due to Notch HOT 2
- Window goes blank on AMD GPU
- Transparent windows in a secondary viewport HOT 3
- Sub sub-menu fail to display using ImGuiConfigFlags_ViewportsEnable HOT 3
- Unmapped Memory Access
- Style color for active input field (feature request) HOT 2
- Frame rate control for individual windows HOT 1
- DirectX12 'ft2build.h' : No such file or directory
- SetNextWindowRefreshPolicy issues
- ListClipper jumps back when scrolls down to bottom HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.