forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvGraphics_linux.cpp
More file actions
52 lines (41 loc) · 1.32 KB
/
mvGraphics_linux.cpp
File metadata and controls
52 lines (41 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "mvGraphics.h"
#include "mvLinuxSpecifics.h"
#include "mvViewport.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "mvProfiler.h"
mvGraphics
setup_graphics(mvViewport& viewport)
{
mvGraphics graphics{};
auto viewportData = (mvViewportData*)viewport.platformSpecifics;
const char* glsl_version = "#version 130";
ImGui_ImplOpenGL3_Init(glsl_version);
return graphics;
}
void
resize_swapchain(mvGraphics& graphics, int width, int height)
{
}
void
cleanup_graphics(mvGraphics& graphics)
{
}
void
present(mvGraphics& graphics, mvColor& clearColor, bool vsync)
{
MV_PROFILE_SCOPE("Presentation")
mvViewport* viewport = GContext->viewport;
auto viewportData = (mvViewportData*)viewport->platformSpecifics;
glfwGetWindowPos(viewportData->handle, &viewport->xpos, &viewport->ypos);
glfwSwapInterval(viewport->vsync ? 1 : 0); // Enable vsync
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(viewportData->handle, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClearColor(viewport->clearColor.r, viewport->clearColor.g, viewport->clearColor.b, viewport->clearColor.a);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(viewportData->handle);
}