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