mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
67 lines
2.3 KiB
C++
67 lines
2.3 KiB
C++
|
|
#include "imgui/imgui_image.h"
|
||
|
|
|
||
|
|
|
||
|
|
// GL includes
|
||
|
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||
|
|
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||
|
|
#include <OpenGLES/ES2/gl.h> // Use GL ES 2
|
||
|
|
#else
|
||
|
|
#include <GLES2/gl2.h> // Use GL ES 2
|
||
|
|
#endif
|
||
|
|
#if defined(__EMSCRIPTEN__)
|
||
|
|
#ifndef GL_GLEXT_PROTOTYPES
|
||
|
|
#define GL_GLEXT_PROTOTYPES
|
||
|
|
#endif
|
||
|
|
#include <GLES2/gl2ext.h>
|
||
|
|
#endif
|
||
|
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||
|
|
#if defined(__APPLE__)
|
||
|
|
#include <TargetConditionals.h>
|
||
|
|
#endif
|
||
|
|
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||
|
|
#include <OpenGLES/ES3/gl.h> // Use GL ES 3
|
||
|
|
#else
|
||
|
|
#include <GLES3/gl3.h> // Use GL ES 3
|
||
|
|
#endif
|
||
|
|
#elif !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||
|
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||
|
|
// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w.
|
||
|
|
// In the rest of your app/engine, you can use another loader of your choice (gl3w, glew, glad, glbinding, glext, glLoadGen, etc.).
|
||
|
|
// If you happen to be developing a new feature for this backend (imgui_impl_opengl3.cpp):
|
||
|
|
// - You may need to regenerate imgui_impl_opengl3_loader.h to add new symbols. See https://github.com/dearimgui/gl3w_stripped
|
||
|
|
// - You can temporarily use an unstripped version. See https://github.com/dearimgui/gl3w_stripped/releases
|
||
|
|
// Changes to this backend using new APIs should be accompanied by a regenerated stripped loader version.
|
||
|
|
#define IMGL3W_IMPL
|
||
|
|
#include "imgui_impl_opengl3_loader.h"
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
unsigned int funcMakeImageTexture()
|
||
|
|
{
|
||
|
|
GLuint gl_text;
|
||
|
|
glGenTextures(1, &gl_text);
|
||
|
|
return gl_text;
|
||
|
|
}
|
||
|
|
|
||
|
|
void funcUpdateImageTexture(unsigned int gl_text, uint32_t *buffer, int width, int height)
|
||
|
|
{
|
||
|
|
glBindTexture(GL_TEXTURE_2D, gl_text);
|
||
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||
|
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
void funcDeleteImageTexture(unsigned int /*gl_text*/)
|
||
|
|
{
|
||
|
|
//glDeleteTextures(1, &gl_text);
|
||
|
|
}
|
||
|
|
|
||
|
|
void bindImageTextureFunctions()
|
||
|
|
{
|
||
|
|
makeImageTexture = funcMakeImageTexture;
|
||
|
|
updateImageTexture = funcUpdateImageTexture;
|
||
|
|
deleteImageTexture = funcDeleteImageTexture;
|
||
|
|
}
|