fix retina API
This commit is contained in:
@@ -118,6 +118,8 @@ class CommonWindowInterface
|
||||
virtual void setWindowTitle(const char* title)=0;
|
||||
|
||||
virtual float getRetinaScale() const =0;
|
||||
virtual void setAllowRetina(bool allow) =0;
|
||||
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
|
||||
|
||||
|
||||
@@ -715,7 +715,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
{
|
||||
char title[1024];
|
||||
sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
|
||||
simpleApp = new SimpleOpenGL3App(title,width,height);
|
||||
simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
|
||||
s_app = simpleApp;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,8 @@ class MacOpenGLWindow : public CommonWindowInterface
|
||||
b3RenderCallback m_renderCallback;
|
||||
|
||||
float m_retinaScaleFactor;
|
||||
bool m_allowRetina;
|
||||
|
||||
public:
|
||||
|
||||
MacOpenGLWindow();
|
||||
@@ -89,6 +91,10 @@ public:
|
||||
{
|
||||
return m_retinaScaleFactor;
|
||||
}
|
||||
virtual void setAllowRetina(bool allow)
|
||||
{
|
||||
m_allowRetina = allow;
|
||||
}
|
||||
|
||||
virtual void createWindow(const b3gWindowConstructionInfo& ci);
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ void dumpInfo(void)
|
||||
|
||||
|
||||
|
||||
extern bool gAllowRetina;
|
||||
|
||||
// -------------------- View ------------------------
|
||||
|
||||
@@ -233,7 +232,8 @@ m_mouseMoveCallback(0),
|
||||
m_mouseButtonCallback(0),
|
||||
m_wheelCallback(0),
|
||||
m_keyboardCallback(0),
|
||||
m_retinaScaleFactor(1)
|
||||
m_retinaScaleFactor(1),
|
||||
m_allowRetina(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ void MacOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci)
|
||||
//support HighResolutionOSX for Retina Macbook
|
||||
if (ci.m_openglVersion>=3)
|
||||
{
|
||||
if (gAllowRetina)
|
||||
if (m_allowRetina)
|
||||
{
|
||||
[m_internalData->m_myview setWantsBestResolutionOpenGLSurface:YES];
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ static GLuint BindFont(const CTexFont *_Font)
|
||||
|
||||
extern unsigned char OpenSansData[];
|
||||
|
||||
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, bool allowRetina)
|
||||
{
|
||||
gApp = this;
|
||||
m_data = new SimpleInternalData;
|
||||
@@ -123,6 +123,8 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
m_data->m_upAxis = 1;
|
||||
|
||||
m_window = new b3gDefaultOpenGLWindow();
|
||||
m_window->setAllowRetina(allowRetina);
|
||||
|
||||
b3gWindowConstructionInfo ci;
|
||||
ci.m_title = title;
|
||||
ci.m_width = width;
|
||||
|
||||
@@ -16,7 +16,7 @@ struct SimpleOpenGL3App : public CommonGraphicsApp
|
||||
class GLInstancingRenderer* m_instancingRenderer;
|
||||
virtual void setBackgroundColor(float red, float green, float blue);
|
||||
|
||||
SimpleOpenGL3App(const char* title, int width,int height);
|
||||
SimpleOpenGL3App(const char* title, int width,int height, bool allowRetina);
|
||||
virtual ~SimpleOpenGL3App();
|
||||
|
||||
virtual int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f, int textureIndex = -1);
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
virtual void endRendering();
|
||||
|
||||
virtual float getRetinaScale() const {return 1.f;}
|
||||
virtual void setAllowRetina(bool /*allowRetina*/) {};
|
||||
|
||||
virtual int fileOpenDialog(char* fileName, int maxFileNameLength);
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
virtual void endRendering();
|
||||
|
||||
virtual float getRetinaScale() const {return 1.f;}
|
||||
|
||||
virtual void setAllowRetina(bool /*allowRetina*/) {};
|
||||
|
||||
virtual void runMainLoop();
|
||||
virtual float getTimeInSeconds();
|
||||
|
||||
Reference in New Issue
Block a user