mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 20:18:47 +02:00
Examples: shallow tweaks to match upcoming other examples.
This commit is contained in:
@ -13,10 +13,11 @@
|
||||
#include <GLFW/glfw3native.h>
|
||||
#endif
|
||||
|
||||
// Data
|
||||
static GLFWwindow* g_Window = NULL;
|
||||
static double g_Time = 0.0f;
|
||||
static bool g_MousePressed[3] = { false, false, false };
|
||||
static float g_MouseWheel = 0.0f;
|
||||
static double g_Time = 0.0f;
|
||||
static bool g_FontTextureLoaded = false;
|
||||
|
||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||
@ -124,7 +125,7 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_LoadFontsTexture()
|
||||
void ImGui_ImplGlfw_InitFontsTexture()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
@ -188,8 +189,7 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
||||
|
||||
void ImGui_ImplGlfw_Shutdown()
|
||||
{
|
||||
GLuint tex_id = (GLuint)ImGui::GetIO().Fonts->TexID;
|
||||
if (tex_id)
|
||||
if (GLuint tex_id = (GLuint)ImGui::GetIO().Fonts->TexID)
|
||||
{
|
||||
glDeleteTextures(1, &tex_id);
|
||||
ImGui::GetIO().Fonts->TexID = 0;
|
||||
@ -200,7 +200,7 @@ void ImGui_ImplGlfw_Shutdown()
|
||||
void ImGui_ImplGlfw_NewFrame()
|
||||
{
|
||||
if (!g_FontTextureLoaded)
|
||||
ImGui_ImplGlfw_LoadFontsTexture();
|
||||
ImGui_ImplGlfw_InitFontsTexture();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
struct GLFWwindow;
|
||||
|
||||
bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
|
||||
void ImGui_ImplGlfw_InitFontsTexture();
|
||||
void ImGui_ImplGlfw_Shutdown();
|
||||
void ImGui_ImplGlfw_LoadFontsTexture();
|
||||
void ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
||||
|
@ -12,13 +12,14 @@ static void error_callback(int error, const char* description)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Setup window
|
||||
glfwSetErrorCallback(error_callback);
|
||||
if (!glfwInit())
|
||||
exit(1);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui_ImplGlfw_Init(window, true);
|
||||
//ImGuiIO& io = ImGui::GetIO();
|
||||
//ImFont* my_font1 = io.Fonts->AddFontDefault();
|
||||
@ -26,12 +27,13 @@ int main(int argc, char** argv)
|
||||
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||
ImGui_ImplGlfw_LoadFontsTexture();
|
||||
ImGui_ImplGlfw_InitFontsTexture();
|
||||
|
||||
bool show_test_window = true;
|
||||
bool show_another_window = false;
|
||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
||||
|
||||
// Main loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
Reference in New Issue
Block a user