Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLFW geometry constraints #7700

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
134 changes: 73 additions & 61 deletions libs/openFrameworks/app/ofAppBaseWindow.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include "ofWindowSettings.h"
#include "ofConstants.h"
#include "ofWindowSettings.h"
#include <optional>

class ofBaseApp;
class ofBaseRenderer;
Expand All @@ -18,111 +19,122 @@ struct _XDisplay;
typedef struct _XDisplay Display;
#endif

class ofAppBaseWindow{
class ofAppBaseWindow {
public:
ofAppBaseWindow() { }
virtual ~ofAppBaseWindow() { }

ofAppBaseWindow(){}
virtual ~ofAppBaseWindow(){}

virtual void setup(const ofWindowSettings & settings)=0;
virtual void update()=0;
virtual void draw()=0;
virtual bool getWindowShouldClose(){
virtual void setup(const ofWindowSettings & settings) = 0;
virtual void update() = 0;
virtual void draw() = 0;
virtual bool getWindowShouldClose() {
return false;
}
virtual void setWindowShouldClose(){}
virtual void close(){}
virtual void setWindowShouldClose() { }
virtual void close() { }
virtual ofCoreEvents & events() = 0;
virtual std::shared_ptr<ofBaseRenderer> & renderer() = 0;

virtual void hideCursor(){}
virtual void showCursor(){}
virtual void hideCursor() { }
virtual void showCursor() { }

virtual void setWindowPosition(int x, int y) { }
virtual void setWindowSize(int w, int h) { }
virtual void setWindowMinimumSize(int w, int h) { }
virtual void setWindowMaximumSize(int w, int h) { }
virtual void setWindowAspectRatio(int horizontal, int vertical) { }
virtual void setWindowShape(int w, int h) { }

virtual void setWindowPosition(int x, int y){}
virtual void setWindowShape(int w, int h){}
std::optional<glm::vec2> minimumWindowSize;
std::optional<glm::vec2> maximumWindowSize;
std::optional<glm::vec2> windowAspectRatio;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make these protected ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

certainly! however in relation to the GLUT implementation (which is currently commented out) if the only window typer supporting these limits is GLFW, they could also be moved into private ofAppGLFWWindow?

(at the same time perhaps confirm it is not a priority to support GLUT? (who's callbacks are statics; makes things a bit different)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - we should do a PR to remove all references to GLUT at this point.
🙂


virtual glm::vec2 getWindowPosition(){ return glm::vec2(); }
virtual glm::vec2 getWindowSize(){ return glm::vec2(); }
virtual glm::vec2 getScreenSize(){ return glm::vec2(); }
virtual glm::vec2 getWindowPosition() { return glm::vec2(); }
virtual glm::vec2 getWindowSize() { return glm::vec2(); }
virtual glm::vec2 getScreenSize() { return glm::vec2(); }

virtual void setOrientation(ofOrientation orientation){ }
virtual ofOrientation getOrientation(){ return OF_ORIENTATION_DEFAULT; }
virtual bool doesHWOrientation(){ return false; }
virtual void setOrientation(ofOrientation orientation) { }
virtual ofOrientation getOrientation() { return OF_ORIENTATION_DEFAULT; }
virtual bool doesHWOrientation() { return false; }

//this is used by ofGetWidth and now determines the window width based on orientation
virtual int getWidth(){ return 0; }
virtual int getHeight(){ return 0; }
virtual int getWidth() { return 0; }
virtual int getHeight() { return 0; }

virtual void setWindowTitle(std::string title){}
virtual void setWindowTitle(std::string title) { }
virtual int getNativeWindowMode() {return -1;};
virtual int getWindowingIsAttached() {return -1;};

virtual ofWindowMode getWindowMode(){ return OF_WINDOW; }
virtual ofWindowMode getWindowMode() { return OF_WINDOW; }

virtual void setFullscreen(bool fullscreen){}
virtual void toggleFullscreen(){}
virtual void setFullscreen(bool fullscreen) { }
virtual void toggleFullscreen() { }
virtual void toggleOSFullscreen() { }
virtual void toggleWindowingFullscreen() { }

virtual void enableSetupScreen(){}
virtual void disableSetupScreen(){}
virtual void enableSetupScreen() { }
virtual void disableSetupScreen() { }

virtual void setVerticalSync(bool enabled){}
virtual void setClipboardString(const std::string& text){}
virtual std::string getClipboardString(){ return ""; }
virtual void setVerticalSync(bool enabled) { }
virtual void setClipboardString(const std::string & text) { }
virtual std::string getClipboardString() { return ""; }

virtual void makeCurrent(){}
virtual void swapBuffers(){}
virtual void startRender(){}
virtual void finishRender(){}
virtual void makeCurrent() { }
virtual void swapBuffers() { }
virtual void startRender() { }
virtual void finishRender() { }

virtual void * getWindowContext(){ return nullptr; }
virtual void * getWindowContext() { return nullptr; }

#if defined(TARGET_LINUX) && !defined(TARGET_RASPBERRY_PI_LEGACY)
virtual Display* getX11Display(){ return nullptr; }
virtual Window getX11Window(){ return 0; }
virtual Display * getX11Display() { return nullptr; }
virtual Window getX11Window() { return 0; }
#endif

#if defined(TARGET_LINUX) && !defined(TARGET_OPENGLES)
virtual GLXContext getGLXContext(){ return 0; }
virtual GLXContext getGLXContext() { return 0; }
#endif

#if defined(TARGET_LINUX) && defined(TARGET_OPENGLES)
virtual EGLDisplay getEGLDisplay(){ return 0; }
virtual EGLContext getEGLContext(){ return 0; }
virtual EGLSurface getEGLSurface(){ return 0; }
virtual EGLDisplay getEGLDisplay() { return 0; }
virtual EGLContext getEGLContext() { return 0; }
virtual EGLSurface getEGLSurface() { return 0; }
#endif

#if defined(TARGET_OSX)
virtual void * getNSGLContext(){ return nullptr; }
virtual void * getCocoaWindow(){ return nullptr; }
virtual void * getNSGLContext() { return nullptr; }
virtual void * getCocoaWindow() { return nullptr; }
#endif

#if defined(TARGET_WIN32)
virtual HGLRC getWGLContext(){ return 0; }
virtual HWND getWin32Window(){ return 0; }
virtual HGLRC getWGLContext() { return 0; }
virtual HWND getWin32Window() { return 0; }
#endif
};

class ofAppBaseGLWindow: public ofAppBaseWindow{
class ofAppBaseGLWindow : public ofAppBaseWindow {
public:
virtual ~ofAppBaseGLWindow(){}
virtual void setup(const ofGLWindowSettings & settings)=0;
void setup(const ofWindowSettings & settings){
const ofGLWindowSettings * glSettings = dynamic_cast<const ofGLWindowSettings*>(&settings);
if(glSettings){
virtual ~ofAppBaseGLWindow() { }
virtual void setup(const ofGLWindowSettings & settings) = 0;
void setup(const ofWindowSettings & settings) {
const ofGLWindowSettings * glSettings = dynamic_cast<const ofGLWindowSettings *>(&settings);
if (glSettings) {
setup(*glSettings);
}else{
} else {
setup(ofGLWindowSettings(settings));
}
}
};

class ofAppBaseGLESWindow: public ofAppBaseWindow{
class ofAppBaseGLESWindow : public ofAppBaseWindow {
public:
virtual ~ofAppBaseGLESWindow(){}
virtual void setup(const ofGLESWindowSettings & settings)=0;
void setup(const ofWindowSettings & settings){
const ofGLESWindowSettings * glSettings = dynamic_cast<const ofGLESWindowSettings*>(&settings);
if(glSettings){
virtual ~ofAppBaseGLESWindow() { }
virtual void setup(const ofGLESWindowSettings & settings) = 0;
void setup(const ofWindowSettings & settings) {
const ofGLESWindowSettings * glSettings = dynamic_cast<const ofGLESWindowSettings *>(&settings);
if (glSettings) {
setup(*glSettings);
}else{
} else {
setup(ofGLESWindowSettings(settings));
}
}
Expand Down
Loading
Loading