fixes in Mac resizing example browser (if window size exceeds capability)
This commit is contained in:
@@ -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_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
|
||||
m_renderer = m_instancingRenderer ;
|
||||
m_window->setResizeCallback(SimpleResizeCallback);
|
||||
|
||||
|
||||
m_instancingRenderer->init();
|
||||
m_instancingRenderer->resize(width,height);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
m_primRenderer->setScreenSize(width,height);
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer->InitShaders();
|
||||
|
||||
@@ -178,8 +190,7 @@ 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);
|
||||
m_data->m_largeFontTextureId = BindFont(g_DefaultLargeFont);
|
||||
|
||||
Reference in New Issue
Block a user