pybullet: allow to replace existing text, to avoid flickering (remove/add)
allow texture caching (disable using the disable file caching)
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
|
||||
|
||||
|
||||
//#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"
|
||||
#include "assert.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char* gVideoFileName = 0;
|
||||
char* gPngFileName = 0;
|
||||
static char* gVideoFileName = 0;
|
||||
static char* gPngFileName = 0;
|
||||
|
||||
static b3WheelCallback sOldWheelCB = 0;
|
||||
static b3ResizeCallback sOldResizeCB = 0;
|
||||
@@ -17,15 +30,15 @@ static b3MouseButtonCallback sOldMouseButtonCB = 0;
|
||||
static b3KeyboardCallback sOldKeyboardCB = 0;
|
||||
//static b3RenderCallback sOldRenderCB = 0;
|
||||
|
||||
float gWidth = 1024;
|
||||
float gHeight = 768;
|
||||
static float gWidth = 1024;
|
||||
static float gHeight = 768;
|
||||
|
||||
void MyWheelCallback(float deltax, float deltay)
|
||||
void MyWheelCallback2(float deltax, float deltay)
|
||||
{
|
||||
if (sOldWheelCB)
|
||||
sOldWheelCB(deltax,deltay);
|
||||
}
|
||||
void MyResizeCallback( float width, float height)
|
||||
void MyResizeCallback2( float width, float height)
|
||||
{
|
||||
gWidth = width;
|
||||
gHeight = height;
|
||||
@@ -33,21 +46,21 @@ void MyResizeCallback( float width, float height)
|
||||
if (sOldResizeCB)
|
||||
sOldResizeCB(width,height);
|
||||
}
|
||||
void MyMouseMoveCallback( float x, float y)
|
||||
void MyMouseMoveCallback2( float x, float y)
|
||||
{
|
||||
printf("Mouse Move: %f, %f\n", x,y);
|
||||
|
||||
if (sOldMouseMoveCB)
|
||||
sOldMouseMoveCB(x,y);
|
||||
}
|
||||
void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
void MyMouseButtonCallback2(int button, int state, float x, float y)
|
||||
{
|
||||
if (sOldMouseButtonCB)
|
||||
sOldMouseButtonCB(button,state,x,y);
|
||||
}
|
||||
|
||||
|
||||
void MyKeyboardCallback(int keycode, int state)
|
||||
static void MyKeyboardCallback2(int keycode, int state)
|
||||
{
|
||||
//keycodes are in examples/CommonInterfaces/CommonWindowInterface.h
|
||||
//for example B3G_ESCAPE for escape key
|
||||
@@ -65,21 +78,21 @@ int main(int argc, char* argv[])
|
||||
b3CommandLineArgs myArgs(argc, argv);
|
||||
|
||||
|
||||
SimpleOpenGL3App* app = new SimpleOpenGL3App("SimpleOpenGL3App", gWidth, gHeight, true);
|
||||
SimpleOpenGLApp* app = new SimpleOpenGLApp("SimpleOpenGL3App", gWidth, gHeight);
|
||||
|
||||
app->m_instancingRenderer->getActiveCamera()->setCameraDistance(13);
|
||||
app->m_instancingRenderer->getActiveCamera()->setCameraPitch(0);
|
||||
app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0);
|
||||
app->m_renderer->getActiveCamera()->setCameraDistance(13);
|
||||
app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
||||
app->m_renderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0);
|
||||
sOldKeyboardCB = app->m_window->getKeyboardCallback();
|
||||
app->m_window->setKeyboardCallback(MyKeyboardCallback);
|
||||
app->m_window->setKeyboardCallback(MyKeyboardCallback2);
|
||||
sOldMouseMoveCB = app->m_window->getMouseMoveCallback();
|
||||
app->m_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
app->m_window->setMouseMoveCallback(MyMouseMoveCallback2);
|
||||
sOldMouseButtonCB = app->m_window->getMouseButtonCallback();
|
||||
app->m_window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
app->m_window->setMouseButtonCallback(MyMouseButtonCallback2);
|
||||
sOldWheelCB = app->m_window->getWheelCallback();
|
||||
app->m_window->setWheelCallback(MyWheelCallback);
|
||||
app->m_window->setWheelCallback(MyWheelCallback2);
|
||||
sOldResizeCB = app->m_window->getResizeCallback();
|
||||
app->m_window->setResizeCallback(MyResizeCallback);
|
||||
app->m_window->setResizeCallback(MyResizeCallback2);
|
||||
|
||||
|
||||
myArgs.GetCmdLineArgument("mp4_file", gVideoFileName);
|
||||
@@ -134,10 +147,12 @@ int main(int argc, char* argv[])
|
||||
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();
|
||||
int upAxis = 1;
|
||||
app->m_renderer->updateCamera(upAxis);
|
||||
|
||||
app->m_renderer->renderScene();
|
||||
|
||||
app->drawGrid();
|
||||
char bla[1024];
|
||||
sprintf(bla, "2d text:%d", frameCount);
|
||||
|
||||
Reference in New Issue
Block a user