Commit 4625ad11 authored by w4t's avatar w4t

remove engine pointer

parent 7ceec1d4
Pipeline #70 canceled with stages
......@@ -549,7 +549,8 @@ namespace ofxImGui
if (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;
}
}
......
#include "Gui.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
#include "imgui_remote.h"
// @RemoteImgui end
......@@ -18,7 +10,6 @@ namespace ofxImGui
//--------------------------------------------------------------
Gui::Gui()
: lastTime(0.0f)
, engine(nullptr)
, theme(nullptr)
{
ImGui::CreateContext();
......@@ -39,23 +30,8 @@ namespace ofxImGui
io.DisplaySize = ImVec2((float)ofGetWidth(), (float)ofGetHeight());
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_;
engine->setup(autoDraw);
engine.setup(autoDraw);
if (theme_)
{
......@@ -73,16 +49,7 @@ namespace ofxImGui
//--------------------------------------------------------------
void Gui::exit()
{
if (engine)
{
delete engine;
engine = nullptr;
}
//if(io)
//{
// io->Fonts->TexID = 0;
// io = nullptr;
//}
if (theme)
{
delete theme;
......@@ -90,7 +57,11 @@ namespace ofxImGui
}
for (size_t i = 0; i < loadedTextures.size(); i++)
{
if(loadedTextures[i])
{
delete loadedTextures[i];
loadedTextures[i] = NULL;
}
}
loadedTextures.clear();
......@@ -159,12 +130,11 @@ namespace ofxImGui
//--------------------------------------------------------------
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) {
if (!engine) return -1;
ofPixels pixels;
ofLoadImage(pixels, imagePath);
return loadPixels(pixels);
......@@ -172,7 +142,6 @@ namespace ofxImGui
//--------------------------------------------------------------
GLuint Gui::loadImage(ofImage& image) {
if (!engine) return -1;
return loadPixels(image.getPixels());
}
......@@ -206,11 +175,6 @@ namespace ofxImGui
//--------------------------------------------------------------
void Gui::begin() {
if (!engine) {
ofLogError(__FUNCTION__) << "setup() call required, calling it for you";
setup();
}
ImGuiIO& io = ImGui::GetIO();
float currentTime = ofGetElapsedTimef();
......@@ -226,7 +190,7 @@ namespace ofxImGui
// Update settings
io.MousePos = ImVec2((float)ofGetMouseX(), (float)ofGetMouseY());
for (int i = 0; i < 5; i++) {
io.MouseDown[i] = engine->mousePressed[i];
io.MouseDown[i] = engine.mousePressed[i];
}
ImGui::RemoteUpdate();
......@@ -244,7 +208,7 @@ namespace ofxImGui
{
if (!autoDraw)
{
engine->draw();
engine.draw();
}
}
}
......@@ -3,7 +3,15 @@
#include "ofImage.h"
#include "ofPixels.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"
namespace ofxImGui
......@@ -42,7 +50,13 @@ namespace ofxImGui
GLuint loadTexture(ofTexture& texture, const std::string& imagePath);
private:
BaseEngine* engine;
#if defined(TARGET_OPENGLES)
EngineOpenGLES engine;
#elif defined (OF_TARGET_API_VULKAN)
EngineVk engine;
#else
EngineGLFW engine;
#endif
float lastTime;
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