fixes in Mac resizing example browser (if window size exceeds capability)
This commit is contained in:
@@ -120,6 +120,8 @@ class CommonWindowInterface
|
||||
virtual float getRetinaScale() const =0;
|
||||
virtual void setAllowRetina(bool allow) =0;
|
||||
|
||||
virtual int getWidth() const = 0;
|
||||
virtual int getHeight() const = 0;
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
|
||||
|
||||
|
||||
@@ -695,8 +695,8 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
}
|
||||
|
||||
|
||||
int width = 1024;
|
||||
int height=768;
|
||||
int width = 1920;
|
||||
int height=1080;
|
||||
#ifndef NO_OPENGL3
|
||||
SimpleOpenGL3App* simpleApp=0;
|
||||
sUseOpenGL2 =args.CheckCmdLineFlag("opengl2");
|
||||
@@ -723,6 +723,8 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
char title[1024];
|
||||
sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
|
||||
simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
|
||||
|
||||
|
||||
s_app = simpleApp;
|
||||
}
|
||||
#endif
|
||||
@@ -734,7 +736,11 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
#endif
|
||||
|
||||
s_instancingRenderer = s_app->m_renderer;
|
||||
s_window = s_app->m_window;
|
||||
s_window = s_app->m_window;
|
||||
|
||||
width = s_window->getWidth();
|
||||
height = s_window->getHeight();
|
||||
|
||||
prevMouseMoveCallback = s_window->getMouseMoveCallback();
|
||||
s_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
|
||||
@@ -818,8 +824,6 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
///add some demos to the gAllExamples
|
||||
|
||||
|
||||
|
||||
|
||||
int numDemos = gAllExamples->getNumRegisteredExamples();
|
||||
|
||||
//char nodeText[1024];
|
||||
|
||||
@@ -101,6 +101,9 @@ public:
|
||||
virtual float getTimeInSeconds();
|
||||
|
||||
|
||||
virtual int getWidth() const;
|
||||
virtual int getHeight() const;
|
||||
|
||||
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
|
||||
@@ -423,8 +423,8 @@ void MacOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
[m_internalData->m_window makeKeyAndOrderFront: nil];
|
||||
|
||||
[m_internalData->m_myview MakeCurrent];
|
||||
//m_internalData->m_width = m_internalData->m_myview.GetWindowWidth;
|
||||
//m_internalData->m_height = m_internalData->m_myview.GetWindowHeight;
|
||||
m_internalData->m_width = m_internalData->m_myview.GetWindowWidth;
|
||||
m_internalData->m_height = m_internalData->m_myview.GetWindowHeight;
|
||||
|
||||
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
@@ -1132,6 +1132,21 @@ void MacOpenGLWindow::getMouseCoordinates(int& x, int& y)
|
||||
|
||||
}
|
||||
|
||||
int MacOpenGLWindow::getWidth() const
|
||||
{
|
||||
if (m_internalData && m_internalData->m_myview && m_internalData->m_myview.GetWindowWidth)
|
||||
return m_internalData->m_myview.GetWindowWidth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MacOpenGLWindow::getHeight() const
|
||||
{
|
||||
if (m_internalData && m_internalData->m_myview && m_internalData->m_myview.GetWindowHeight)
|
||||
return m_internalData->m_myview.GetWindowHeight;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MacOpenGLWindow::setResizeCallback(b3ResizeCallback resizeCallback)
|
||||
{
|
||||
[m_internalData->m_myview setResizeCallback:resizeCallback];
|
||||
|
||||
@@ -56,8 +56,11 @@ static void SimpleResizeCallback( float widthf, float heightf)
|
||||
{
|
||||
int width = (int)widthf;
|
||||
int height = (int)heightf;
|
||||
gApp->m_instancingRenderer->resize(width,height);
|
||||
gApp->m_primRenderer->setScreenSize(width,height);
|
||||
if (gApp && gApp->m_instancingRenderer)
|
||||
gApp->m_instancingRenderer->resize(width,height);
|
||||
|
||||
if (gApp && gApp->m_primRenderer)
|
||||
gApp->m_primRenderer->setScreenSize(width,height);
|
||||
|
||||
}
|
||||
|
||||
@@ -115,6 +118,7 @@ extern unsigned char OpenSansData[];
|
||||
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, bool allowRetina)
|
||||
{
|
||||
gApp = this;
|
||||
|
||||
m_data = new SimpleInternalData;
|
||||
m_data->m_frameDumpPngFileName = 0;
|
||||
m_data->m_renderTexture = 0;
|
||||
@@ -123,6 +127,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
m_data->m_upAxis = 1;
|
||||
|
||||
m_window = new b3gDefaultOpenGLWindow();
|
||||
|
||||
m_window->setAllowRetina(allowRetina);
|
||||
|
||||
b3gWindowConstructionInfo ci;
|
||||
@@ -141,6 +146,9 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
1.f);
|
||||
|
||||
m_window->startRendering();
|
||||
width = m_window->getWidth();
|
||||
height = m_window->getHeight();
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
#ifndef __APPLE__
|
||||
@@ -160,17 +168,21 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
m_parameterInterface = 0;
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer = new GLInstancingRenderer(128*1024,64*1024*1024);
|
||||
m_renderer = m_instancingRenderer ;
|
||||
m_instancingRenderer->init();
|
||||
m_instancingRenderer->resize(width,height);
|
||||
m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
m_renderer = m_instancingRenderer ;
|
||||
m_window->setResizeCallback(SimpleResizeCallback);
|
||||
|
||||
|
||||
m_instancingRenderer->init();
|
||||
m_instancingRenderer->resize(width,height);
|
||||
m_primRenderer->setScreenSize(width,height);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer->InitShaders();
|
||||
|
||||
@@ -178,7 +190,6 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
|
||||
m_window->setMouseButtonCallback(SimpleMouseButtonCallback);
|
||||
m_window->setKeyboardCallback(SimpleKeyboardCallback);
|
||||
m_window->setWheelCallback(SimpleWheelCallback);
|
||||
m_window->setResizeCallback(SimpleResizeCallback);
|
||||
|
||||
TwGenerateDefaultFonts();
|
||||
m_data->m_fontTextureId = BindFont(g_DefaultNormalFont);
|
||||
|
||||
Reference in New Issue
Block a user