2.9 KB、45行 生 Blame 履歴
1// dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline)
2// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
3
4// Implemented features:
5// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
6// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
7// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
8// Missing features or Issues:
9// [ ] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
10// [ ] Renderer: Use of DrawCallback_SetSamplerLinear, DrawCallback_SetSamplerNearest is emulated by poking to glTexParameter(), as legacy OpenGL doesn't have glBindSampler().
11
12// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
13// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
14// Learn about Dear ImGui:
15// - FAQ https://dearimgui.com/faq
16// - Getting Started https://dearimgui.com/getting-started
17// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
18// - Introduction, links and more at the top of imgui.cpp
19
20// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
21// **Prefer using the code in imgui_impl_opengl3.cpp**
22// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
23// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
24// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
25// confuse your GPU driver.
26// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
27
28#pragma once
29#include "imgui.h" // IMGUI_IMPL_API
30#ifndef IMGUI_DISABLE
31
32// Follow "Getting Started" link and check examples/ folder to learn about using backends!
33IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
34IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
35IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame();
36IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
37
38// Called by Init/NewFrame/Shutdown
39IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
40IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
41
42// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
43IMGUI_IMPL_API void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex);
44
45#endif // #ifndef IMGUI_DISABLE