mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Examples: Not clearing input data/tex data in atlas (will be required for dynamic atlas anyway). Effectively fix resizing in DX examples.
+ Standardized comments.
This commit is contained in:
parent
6269859315
commit
6cee2fca94
@ -88,9 +88,8 @@ void ImGui_ImplA5_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
|
|
||||||
bool Imgui_ImplA5_CreateDeviceObjects()
|
bool Imgui_ImplA5_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
|
// Build texture atlas
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
|
|
||||||
// Build texture
|
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
@ -125,10 +124,6 @@ bool Imgui_ImplA5_CreateDeviceObjects()
|
|||||||
io.Fonts->TexID = (void*)cloned_img;
|
io.Fonts->TexID = (void*)cloned_img;
|
||||||
g_Texture = cloned_img;
|
g_Texture = cloned_img;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
|
||||||
io.Fonts->ClearInputData();
|
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
|
|
||||||
// Create an invisible mouse cursor
|
// Create an invisible mouse cursor
|
||||||
// Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
|
// Because al_hide_mouse_cursor() seems to mess up with the actual inputs..
|
||||||
ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
|
ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
|
||||||
|
@ -224,14 +224,13 @@ IMGUI_API LRESULT ImGui_ImplDX11_WndProcHandler(HWND, UINT msg, WPARAM wParam, L
|
|||||||
|
|
||||||
static void ImGui_ImplDX11_CreateFontsTexture()
|
static void ImGui_ImplDX11_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Build
|
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
|
|
||||||
// Create DX11 texture
|
// Upload texture to graphics system
|
||||||
{
|
{
|
||||||
D3D11_TEXTURE2D_DESC texDesc;
|
D3D11_TEXTURE2D_DESC texDesc;
|
||||||
ZeroMemory(&texDesc, sizeof(texDesc));
|
ZeroMemory(&texDesc, sizeof(texDesc));
|
||||||
@ -280,10 +279,6 @@ static void ImGui_ImplDX11_CreateFontsTexture()
|
|||||||
samplerDesc.MaxLOD = 0.f;
|
samplerDesc.MaxLOD = 0.f;
|
||||||
g_pd3dDevice->CreateSamplerState(&samplerDesc, &g_pFontSampler);
|
g_pd3dDevice->CreateSamplerState(&samplerDesc, &g_pFontSampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
|
||||||
io.Fonts->ClearInputData();
|
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX11_CreateDeviceObjects()
|
bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||||
|
@ -230,14 +230,13 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
|
|
||||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Build
|
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height, bytes_per_pixel;
|
int width, height, bytes_per_pixel;
|
||||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
|
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
|
||||||
|
|
||||||
// Create DX9 texture
|
// Upload texture to graphics system
|
||||||
g_FontTexture = NULL;
|
g_FontTexture = NULL;
|
||||||
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &g_FontTexture) < 0)
|
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &g_FontTexture) < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -251,9 +250,6 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)g_FontTexture;
|
io.Fonts->TexID = (void *)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
|
||||||
io.Fonts->ClearInputData();
|
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,12 +692,15 @@ static void ImGui_ImplIOS_RenderDrawLists (ImDrawData *draw_data)
|
|||||||
|
|
||||||
void ImGui_ImplIOS_CreateFontsTexture()
|
void ImGui_ImplIOS_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
||||||
|
|
||||||
|
// Upload texture to graphics system
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -706,10 +709,9 @@ void ImGui_ImplIOS_CreateFontsTexture()
|
|||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Restore state
|
||||||
io.Fonts->ClearInputData();
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplIOS_CreateDeviceObjects()
|
bool ImGui_ImplIOS_CreateDeviceObjects()
|
||||||
@ -767,7 +769,6 @@ bool ImGui_ImplIOS_CreateDeviceObjects()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
glAttachShader(g_ShaderHandle, g_VertHandle);
|
glAttachShader(g_ShaderHandle, g_VertHandle);
|
||||||
glAttachShader(g_ShaderHandle, g_FragHandle);
|
glAttachShader(g_ShaderHandle, g_FragHandle);
|
||||||
glLinkProgram(g_ShaderHandle);
|
glLinkProgram(g_ShaderHandle);
|
||||||
|
@ -167,14 +167,13 @@ int32 ImGui_Marmalade_CharCallback(void* SystemData, void* userData)
|
|||||||
|
|
||||||
bool ImGui_Marmalade_CreateDeviceObjects()
|
bool ImGui_Marmalade_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
|
|
||||||
// Create texture
|
// Upload texture to graphics system
|
||||||
g_FontTexture = new CIwTexture();
|
g_FontTexture = new CIwTexture();
|
||||||
g_FontTexture->SetModifiable(true);
|
g_FontTexture->SetModifiable(true);
|
||||||
CIwImage& image = g_FontTexture->GetImage();
|
CIwImage& image = g_FontTexture->GetImage();
|
||||||
@ -187,13 +186,9 @@ bool ImGui_Marmalade_CreateDeviceObjects()
|
|||||||
g_FontTexture->SetFiltering(false);
|
g_FontTexture->SetFiltering(false);
|
||||||
g_FontTexture->Upload();
|
g_FontTexture->Upload();
|
||||||
|
|
||||||
// Store the pointer
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)g_FontTexture;
|
io.Fonts->TexID = (void *)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
|
||||||
io.Fonts->ClearInputData();
|
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,16 +161,17 @@ void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c)
|
|||||||
io.AddInputCharacter((unsigned short)c);
|
io.AddInputCharacter((unsigned short)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwGL3_CreateFontsTexture()
|
bool ImGui_ImplGlfwGL3_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
||||||
|
|
||||||
// Create OpenGL texture
|
// Upload texture to graphics system
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -180,9 +181,10 @@ void ImGui_ImplGlfwGL3_CreateFontsTexture()
|
|||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Restore state
|
||||||
io.Fonts->ClearInputData();
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
|
bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
|
||||||
|
@ -145,14 +145,13 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
|
|||||||
|
|
||||||
bool ImGui_ImplGlfw_CreateDeviceObjects()
|
bool ImGui_ImplGlfw_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
||||||
|
|
||||||
// Create OpenGL texture
|
// Upload texture to graphics system
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
@ -164,9 +163,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects()
|
|||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Restore state
|
||||||
io.Fonts->ClearInputData();
|
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -166,14 +166,15 @@ bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event)
|
|||||||
|
|
||||||
void ImGui_ImplSdlGL3_CreateFontsTexture()
|
void ImGui_ImplSdlGL3_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
|
||||||
|
|
||||||
// Create OpenGL texture
|
// Upload texture to graphics system
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -183,9 +184,8 @@ void ImGui_ImplSdlGL3_CreateFontsTexture()
|
|||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Restore state
|
||||||
io.Fonts->ClearInputData();
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSdlGL3_CreateDeviceObjects()
|
bool ImGui_ImplSdlGL3_CreateDeviceObjects()
|
||||||
|
@ -146,14 +146,15 @@ bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event)
|
|||||||
|
|
||||||
bool ImGui_ImplSdl_CreateDeviceObjects()
|
bool ImGui_ImplSdl_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
|
// Build texture atlas
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Build texture
|
|
||||||
unsigned char* pixels;
|
unsigned char* pixels;
|
||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
||||||
|
|
||||||
// Create texture
|
// Upload texture to graphics system
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -163,9 +164,8 @@ bool ImGui_ImplSdl_CreateDeviceObjects()
|
|||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Restore state
|
||||||
io.Fonts->ClearInputData();
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
io.Fonts->ClearTexData();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user