From f73b54e4ab3b376c0c23506ee70bfd76d4da8969 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 11 Apr 2017 20:16:49 -0700 Subject: [PATCH] testing ImGUI --- build3/premake4.lua | 3 ++- examples/OpenGLWindow/SimpleOpenGL2App.cpp | 3 +++ examples/OpenGLWindow/SimpleOpenGL3App.h | 2 +- examples/SimpleOpenGL3/main.cpp | 28 ++++++++++++++-------- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/build3/premake4.lua b/build3/premake4.lua index 57ea7412e..1cf34e241 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -266,9 +266,10 @@ end if _OPTIONS["enable_pybullet"] then include "../examples/pybullet" end + include "../examples/SimpleOpenGL3" if _OPTIONS["standalone-examples"] then - include "../examples/SimpleOpenGL3" + include "../examples/TinyRenderer" include "../examples/BasicDemo" include "../examples/InverseDynamics" diff --git a/examples/OpenGLWindow/SimpleOpenGL2App.cpp b/examples/OpenGLWindow/SimpleOpenGL2App.cpp index 3a87a0d0e..3122bd120 100644 --- a/examples/OpenGLWindow/SimpleOpenGL2App.cpp +++ b/examples/OpenGLWindow/SimpleOpenGL2App.cpp @@ -12,6 +12,7 @@ #include "GLInstanceGraphicsShape.h" #include "stdlib.h" #include "TwFonts.h" +#include "SimpleOpenGL2Renderer.h" #ifdef __APPLE__ #include "MacOpenGLWindow.h" #else @@ -177,6 +178,8 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height) m_window->setWheelCallback(Simple2WheelCallback); m_window->setResizeCallback(Simple2ResizeCallback); + m_renderer = new SimpleOpenGL2Renderer(width,height); + } SimpleOpenGL2App::~SimpleOpenGL2App() diff --git a/examples/OpenGLWindow/SimpleOpenGL3App.h b/examples/OpenGLWindow/SimpleOpenGL3App.h index 6902dacf8..3d0f69dd4 100644 --- a/examples/OpenGLWindow/SimpleOpenGL3App.h +++ b/examples/OpenGLWindow/SimpleOpenGL3App.h @@ -16,7 +16,7 @@ struct SimpleOpenGL3App : public CommonGraphicsApp class GLInstancingRenderer* m_instancingRenderer; virtual void setBackgroundColor(float red, float green, float blue); - SimpleOpenGL3App(const char* title, int width,int height, bool allowRetina); + SimpleOpenGL3App(const char* title, int width,int height, bool allowRetina=true); virtual ~SimpleOpenGL3App(); virtual int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f, int textureIndex = -1, float textureScaling = 1); diff --git a/examples/SimpleOpenGL3/main.cpp b/examples/SimpleOpenGL3/main.cpp index a06dbae27..998412c1a 100644 --- a/examples/SimpleOpenGL3/main.cpp +++ b/examples/SimpleOpenGL3/main.cpp @@ -1,8 +1,15 @@ +//#define USE_OPENGL2 +#ifdef USE_OPENGL2 +#include "OpenGLWindow/SimpleOpenGL2App.h" +typedef SimpleOpenGL2App SimpleOpenGLApp ; +#else #include "OpenGLWindow/SimpleOpenGL3App.h" +typedef SimpleOpenGL3App SimpleOpenGLApp ; +#endif //USE_OPENGL2 #include "Bullet3Common/b3Quaternion.h" #include "Bullet3Common/b3CommandLineArgs.h" @@ -23,7 +30,7 @@ static b3KeyboardCallback sOldKeyboardCB = 0; float gWidth = 1024; float gHeight = 768; -SimpleOpenGL3App* app = 0; +SimpleOpenGLApp* app = 0; float gMouseX = 0; float gMouseY = 0; float g_MouseWheel = 0.0f; @@ -246,11 +253,12 @@ int main(int argc, char* argv[]) b3CommandLineArgs myArgs(argc, argv); - app = new SimpleOpenGL3App("SimpleOpenGL3App", gWidth, gHeight, true); + app = new SimpleOpenGLApp("SimpleOpenGLApp", gWidth, gHeight); + + app->m_renderer->getActiveCamera()->setCameraDistance(13); + app->m_renderer->getActiveCamera()->setCameraPitch(0); + app->m_renderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0); - app->m_instancingRenderer->getActiveCamera()->setCameraDistance(13); - app->m_instancingRenderer->getActiveCamera()->setCameraPitch(0); - app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0); sOldKeyboardCB = app->m_window->getKeyboardCallback(); app->m_window->setKeyboardCallback(MyKeyboardCallback); sOldMouseMoveCB = app->m_window->getMouseMoveCallback(); @@ -320,19 +328,19 @@ int main(int argc, char* argv[]) app->m_renderer->activateTexture(textureHandle); app->m_renderer->updateTexture(textureHandle, image); - float color[4] = { 255, 1, 1, 1 }; - app->m_primRenderer->drawTexturedRect(100, 200, gWidth / 2 - 50, gHeight / 2 - 50, color, 0, 0, 1, 1, true); + //float color[4] = { 255, 1, 1, 1 }; + //app->m_primRenderer->drawTexturedRect(100, 200, gWidth / 2 - 50, gHeight / 2 - 50, color, 0, 0, 1, 1, true); - app->m_instancingRenderer->init(); - app->m_instancingRenderer->updateCamera(); + app->m_renderer->init(); + app->m_renderer->updateCamera(1); app->m_renderer->renderScene(); app->drawGrid(); char bla[1024]; sprintf(bla, "Simple test frame %d", frameCount); - app->drawText(bla, 10, 10); + //app->drawText(bla, 10, 10); #ifdef B3_USE_IMGUI {