testing ImGUI

This commit is contained in:
Erwin Coumans 2017-04-11 20:16:49 -07:00
parent a43f3b026a
commit f73b54e4ab
4 changed files with 24 additions and 12 deletions

View File

@ -266,9 +266,10 @@ end
if _OPTIONS["enable_pybullet"] then if _OPTIONS["enable_pybullet"] then
include "../examples/pybullet" include "../examples/pybullet"
end end
include "../examples/SimpleOpenGL3"
if _OPTIONS["standalone-examples"] then if _OPTIONS["standalone-examples"] then
include "../examples/SimpleOpenGL3"
include "../examples/TinyRenderer" include "../examples/TinyRenderer"
include "../examples/BasicDemo" include "../examples/BasicDemo"
include "../examples/InverseDynamics" include "../examples/InverseDynamics"

View File

@ -12,6 +12,7 @@
#include "GLInstanceGraphicsShape.h" #include "GLInstanceGraphicsShape.h"
#include "stdlib.h" #include "stdlib.h"
#include "TwFonts.h" #include "TwFonts.h"
#include "SimpleOpenGL2Renderer.h"
#ifdef __APPLE__ #ifdef __APPLE__
#include "MacOpenGLWindow.h" #include "MacOpenGLWindow.h"
#else #else
@ -177,6 +178,8 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
m_window->setWheelCallback(Simple2WheelCallback); m_window->setWheelCallback(Simple2WheelCallback);
m_window->setResizeCallback(Simple2ResizeCallback); m_window->setResizeCallback(Simple2ResizeCallback);
m_renderer = new SimpleOpenGL2Renderer(width,height);
} }
SimpleOpenGL2App::~SimpleOpenGL2App() SimpleOpenGL2App::~SimpleOpenGL2App()

View File

@ -16,7 +16,7 @@ struct SimpleOpenGL3App : public CommonGraphicsApp
class GLInstancingRenderer* m_instancingRenderer; class GLInstancingRenderer* m_instancingRenderer;
virtual void setBackgroundColor(float red, float green, float blue); 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 ~SimpleOpenGL3App();
virtual int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f, int textureIndex = -1, float textureScaling = 1); virtual int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f, int textureIndex = -1, float textureScaling = 1);

View File

@ -1,8 +1,15 @@
//#define USE_OPENGL2
#ifdef USE_OPENGL2
#include "OpenGLWindow/SimpleOpenGL2App.h"
typedef SimpleOpenGL2App SimpleOpenGLApp ;
#else
#include "OpenGLWindow/SimpleOpenGL3App.h" #include "OpenGLWindow/SimpleOpenGL3App.h"
typedef SimpleOpenGL3App SimpleOpenGLApp ;
#endif //USE_OPENGL2
#include "Bullet3Common/b3Quaternion.h" #include "Bullet3Common/b3Quaternion.h"
#include "Bullet3Common/b3CommandLineArgs.h" #include "Bullet3Common/b3CommandLineArgs.h"
@ -23,7 +30,7 @@ static b3KeyboardCallback sOldKeyboardCB = 0;
float gWidth = 1024; float gWidth = 1024;
float gHeight = 768; float gHeight = 768;
SimpleOpenGL3App* app = 0; SimpleOpenGLApp* app = 0;
float gMouseX = 0; float gMouseX = 0;
float gMouseY = 0; float gMouseY = 0;
float g_MouseWheel = 0.0f; float g_MouseWheel = 0.0f;
@ -246,11 +253,12 @@ int main(int argc, char* argv[])
b3CommandLineArgs myArgs(argc, 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(); sOldKeyboardCB = app->m_window->getKeyboardCallback();
app->m_window->setKeyboardCallback(MyKeyboardCallback); app->m_window->setKeyboardCallback(MyKeyboardCallback);
sOldMouseMoveCB = app->m_window->getMouseMoveCallback(); sOldMouseMoveCB = app->m_window->getMouseMoveCallback();
@ -320,19 +328,19 @@ int main(int argc, char* argv[])
app->m_renderer->activateTexture(textureHandle); app->m_renderer->activateTexture(textureHandle);
app->m_renderer->updateTexture(textureHandle, image); app->m_renderer->updateTexture(textureHandle, image);
float color[4] = { 255, 1, 1, 1 }; //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_primRenderer->drawTexturedRect(100, 200, gWidth / 2 - 50, gHeight / 2 - 50, color, 0, 0, 1, 1, true);
app->m_instancingRenderer->init(); app->m_renderer->init();
app->m_instancingRenderer->updateCamera(); app->m_renderer->updateCamera(1);
app->m_renderer->renderScene(); app->m_renderer->renderScene();
app->drawGrid(); app->drawGrid();
char bla[1024]; char bla[1024];
sprintf(bla, "Simple test frame %d", frameCount); sprintf(bla, "Simple test frame %d", frameCount);
app->drawText(bla, 10, 10); //app->drawText(bla, 10, 10);
#ifdef B3_USE_IMGUI #ifdef B3_USE_IMGUI
{ {