11.15
This commit is contained in:
@@ -26,6 +26,9 @@ int32_t g_canvasWidth = 1024;
|
||||
int32_t g_canvasHeight = 512;
|
||||
davinci::Device g_device;
|
||||
davinci::Scene g_scene;
|
||||
int32_t g_mousePosX = 0;
|
||||
int32_t g_mousePosY = 0;
|
||||
davinci::fVector4 g_mouseColor = davinci::fVector4::BLACK;
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//int main(int argc, char* argv[])
|
||||
@@ -160,6 +163,20 @@ SDL_AppResult SDL_AppIterate(void* appstate)
|
||||
g_adapterTexture.updateTexture(g_canvasWidth, 0, g_renderTarget.getDepthBuffer());
|
||||
g_adapterTexture.draw();
|
||||
|
||||
float mousePosX, mousePosY;
|
||||
SDL_GetMouseState(&mousePosX, &mousePosY);
|
||||
|
||||
g_mousePosX = (int32_t)(mousePosX) % g_canvasWidth;
|
||||
g_mousePosY = g_screenHeight - (int32_t)(mousePosY);
|
||||
if(g_mousePosX>=0 && g_mousePosX < g_canvasWidth && g_mousePosY >=0 && g_mousePosY < g_canvasHeight)
|
||||
{
|
||||
g_mouseColor = g_renderTarget.getColorBuffer().getPixel(g_mousePosX, g_mousePosY);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_mouseColor = davinci::fVector4::BLACK;
|
||||
}
|
||||
|
||||
//draw ui
|
||||
drawMainUI();
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ extern davinci::Device g_device;
|
||||
extern davinci::Scene g_scene;
|
||||
extern davinci::RenderTarget g_renderTarget;
|
||||
extern davinci::AntiAliasingTech g_aaTech;
|
||||
extern int32_t g_mousePosX;
|
||||
extern int32_t g_mousePosY;
|
||||
extern davinci::fVector4 g_mouseColor;
|
||||
|
||||
bool initMainUI(SDL_Window* window, SDL_GLContext gl_context, const char* glsl_version)
|
||||
{
|
||||
@@ -129,6 +132,10 @@ void drawMainUI()
|
||||
|
||||
davinci_utils::dump_render_target("d:\\rendertarget", g_renderTarget);
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImVec2 mousePos = ImGui::GetMousePos();
|
||||
ImGui::Text("MousePosition: %d,%d", g_mousePosX, g_mousePosY);
|
||||
ImGui::Text("MouseColor: %.3f,%.3f,%.3f,%.3f", g_mouseColor.x, g_mouseColor.y, g_mouseColor.z, g_mouseColor.w);
|
||||
ImGui::End();
|
||||
|
||||
// Rendering
|
||||
|
||||
Reference in New Issue
Block a user