Commit 4625ad11 authored by w4t's avatar w4t

remove engine pointer

parent 7ceec1d4
Pipeline #70 canceled with stages
...@@ -549,7 +549,8 @@ namespace ofxImGui ...@@ -549,7 +549,8 @@ namespace ofxImGui
if (g_FontTexture) if (g_FontTexture)
{ {
glDeleteTextures(1, &g_FontTexture); glDeleteTextures(1, &g_FontTexture);
ImGui::GetIO().Fonts->TexID = 0; //JVC: This is causing an error
//ImGui::GetIO().Fonts->TexID = 0;
g_FontTexture = 0; g_FontTexture = 0;
} }
} }
......
#include "Gui.h" #include "Gui.h"
#include "ofAppRunner.h" #include "ofAppRunner.h"
#if defined(TARGET_OPENGLES)
#include "EngineOpenGLES.h"
#elif defined (OF_TARGET_API_VULKAN)
#include "EngineVk.h"
#else
#include "EngineGLFW.h"
#endif
// @RemoteImgui begin // @RemoteImgui begin
#include "imgui_remote.h" #include "imgui_remote.h"
// @RemoteImgui end // @RemoteImgui end
...@@ -18,7 +10,6 @@ namespace ofxImGui ...@@ -18,7 +10,6 @@ namespace ofxImGui
//-------------------------------------------------------------- //--------------------------------------------------------------
Gui::Gui() Gui::Gui()
: lastTime(0.0f) : lastTime(0.0f)
, engine(nullptr)
, theme(nullptr) , theme(nullptr)
{ {
ImGui::CreateContext(); ImGui::CreateContext();
...@@ -39,23 +30,8 @@ namespace ofxImGui ...@@ -39,23 +30,8 @@ namespace ofxImGui
io.DisplaySize = ImVec2((float)ofGetWidth(), (float)ofGetHeight()); io.DisplaySize = ImVec2((float)ofGetWidth(), (float)ofGetHeight());
io.MouseDrawCursor = false; io.MouseDrawCursor = false;
if (engine)
{
delete engine;
engine = nullptr;
}
#if defined(TARGET_OPENGLES)
engine = new EngineOpenGLES();
#elif defined (OF_TARGET_API_VULKAN)
engine = new EngineVk();
#elif FORCE_APPGLUT
engine = new EngineGLUT();
#else
engine = new EngineGLFW();
#endif
autoDraw = autoDraw_; autoDraw = autoDraw_;
engine->setup(autoDraw); engine.setup(autoDraw);
if (theme_) if (theme_)
{ {
...@@ -73,16 +49,7 @@ namespace ofxImGui ...@@ -73,16 +49,7 @@ namespace ofxImGui
//-------------------------------------------------------------- //--------------------------------------------------------------
void Gui::exit() void Gui::exit()
{ {
if (engine)
{
delete engine;
engine = nullptr;
}
//if(io)
//{
// io->Fonts->TexID = 0;
// io = nullptr;
//}
if (theme) if (theme)
{ {
delete theme; delete theme;
...@@ -90,7 +57,11 @@ namespace ofxImGui ...@@ -90,7 +57,11 @@ namespace ofxImGui
} }
for (size_t i = 0; i < loadedTextures.size(); i++) for (size_t i = 0; i < loadedTextures.size(); i++)
{ {
if(loadedTextures[i])
{
delete loadedTextures[i]; delete loadedTextures[i];
loadedTextures[i] = NULL;
}
} }
loadedTextures.clear(); loadedTextures.clear();
...@@ -159,12 +130,11 @@ namespace ofxImGui ...@@ -159,12 +130,11 @@ namespace ofxImGui
//-------------------------------------------------------------- //--------------------------------------------------------------
GLuint Gui::loadPixels(ofPixels& pixels) { GLuint Gui::loadPixels(ofPixels& pixels) {
return engine->loadTextureImage2D(pixels.getData(), (int)pixels.getWidth(), (int)pixels.getHeight()); return engine.loadTextureImage2D(pixels.getData(), (int)pixels.getWidth(), (int)pixels.getHeight());
} }
//-------------------------------------------------------------- //--------------------------------------------------------------
GLuint Gui::loadPixels(const std::string& imagePath) { GLuint Gui::loadPixels(const std::string& imagePath) {
if (!engine) return -1;
ofPixels pixels; ofPixels pixels;
ofLoadImage(pixels, imagePath); ofLoadImage(pixels, imagePath);
return loadPixels(pixels); return loadPixels(pixels);
...@@ -172,7 +142,6 @@ namespace ofxImGui ...@@ -172,7 +142,6 @@ namespace ofxImGui
//-------------------------------------------------------------- //--------------------------------------------------------------
GLuint Gui::loadImage(ofImage& image) { GLuint Gui::loadImage(ofImage& image) {
if (!engine) return -1;
return loadPixels(image.getPixels()); return loadPixels(image.getPixels());
} }
...@@ -206,11 +175,6 @@ namespace ofxImGui ...@@ -206,11 +175,6 @@ namespace ofxImGui
//-------------------------------------------------------------- //--------------------------------------------------------------
void Gui::begin() { void Gui::begin() {
if (!engine) {
ofLogError(__FUNCTION__) << "setup() call required, calling it for you";
setup();
}
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
float currentTime = ofGetElapsedTimef(); float currentTime = ofGetElapsedTimef();
...@@ -226,7 +190,7 @@ namespace ofxImGui ...@@ -226,7 +190,7 @@ namespace ofxImGui
// Update settings // Update settings
io.MousePos = ImVec2((float)ofGetMouseX(), (float)ofGetMouseY()); io.MousePos = ImVec2((float)ofGetMouseX(), (float)ofGetMouseY());
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
io.MouseDown[i] = engine->mousePressed[i]; io.MouseDown[i] = engine.mousePressed[i];
} }
ImGui::RemoteUpdate(); ImGui::RemoteUpdate();
...@@ -244,7 +208,7 @@ namespace ofxImGui ...@@ -244,7 +208,7 @@ namespace ofxImGui
{ {
if (!autoDraw) if (!autoDraw)
{ {
engine->draw(); engine.draw();
} }
} }
} }
...@@ -3,7 +3,15 @@ ...@@ -3,7 +3,15 @@
#include "ofImage.h" #include "ofImage.h"
#include "ofPixels.h" #include "ofPixels.h"
#include "ofTexture.h" #include "ofTexture.h"
#include "BaseEngine.h"
#if defined(TARGET_OPENGLES)
#include "EngineOpenGLES.h"
#elif defined (OF_TARGET_API_VULKAN)
#include "EngineVk.h"
#else
#include "EngineGLFW.h"
#endif
#include "BaseTheme.h" #include "BaseTheme.h"
namespace ofxImGui namespace ofxImGui
...@@ -42,7 +50,13 @@ namespace ofxImGui ...@@ -42,7 +50,13 @@ namespace ofxImGui
GLuint loadTexture(ofTexture& texture, const std::string& imagePath); GLuint loadTexture(ofTexture& texture, const std::string& imagePath);
private: private:
BaseEngine* engine; #if defined(TARGET_OPENGLES)
EngineOpenGLES engine;
#elif defined (OF_TARGET_API_VULKAN)
EngineVk engine;
#else
EngineGLFW engine;
#endif
float lastTime; float lastTime;
bool autoDraw; bool autoDraw;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment