From 55b170e5e713b060495fa0b4aeca1e400a7f388a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 18 Apr 2015 15:15:17 -0700 Subject: [PATCH 1/2] Fix CGLXContext --- include/IContext.hpp | 4 ++-- libBoo.pri | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/IContext.hpp b/include/IContext.hpp index 95e3568..6904b70 100644 --- a/include/IContext.hpp +++ b/include/IContext.hpp @@ -10,7 +10,7 @@ public: virtual void setMinVersion (const int& min)=0; virtual void setMajorVersion(const int& maj)=0; - virtual void create(); + virtual void create()=0; virtual const std::string version() const=0; virtual const std::string name() const=0; virtual int depthSize() const=0; @@ -19,4 +19,4 @@ public: virtual int blueDepth() const=0; }; -#endif // ICONTEXT_HPP \ No newline at end of file +#endif // ICONTEXT_HPP diff --git a/libBoo.pri b/libBoo.pri index c553323..c0578d9 100644 --- a/libBoo.pri +++ b/libBoo.pri @@ -1,10 +1,14 @@ +!contains(CONFIG,c++11):CONFIG += C++11 + HEADERS += \ $$PWD/include/boo.hpp \ $$PWD/include/IContext.hpp \ $$PWD/include/CCGLContext.hpp \ + $$PWD/include/CGLXContext.hpp \ $$PWD/include/ISurface.hpp SOURCES += \ - $$PWD/src/CCGLContext.cpp + $$PWD/src/CCGLContext.cpp \ + $$PWD/src/CGLXContext.cpp INCLUDEPATH += $$PWD/include From fd3a3d7f258e2263c52e7216679e49762239992a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 18 Apr 2015 16:12:22 -0700 Subject: [PATCH 2/2] * create should return bool --- include/CGLXContext.hpp | 7 ++++++- include/IContext.hpp | 6 +++--- libBoo.pro | 3 +++ src/CGLXContext.cpp | 18 ++++++++++++++++++ test/main.cpp | 7 +++++++ 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/include/CGLXContext.hpp b/include/CGLXContext.hpp index 676c331..b5209d4 100644 --- a/include/CGLXContext.hpp +++ b/include/CGLXContext.hpp @@ -11,6 +11,9 @@ public: CGLXContext(); virtual ~CGLXContext() {} + bool create(); + void setMajorVersion(const int& maj) override; + void setMinVersion(const int& min) override; const std::string version() const override; const std::string name() const override; int depthSize() const override; @@ -18,8 +21,10 @@ public: int greenDepth() const override; int blueDepth() const override; private: - int m_minVersion; int m_majVersion; + int m_minVersion; + + Display* m_display; }; diff --git a/include/IContext.hpp b/include/IContext.hpp index 95e3568..fcc633c 100644 --- a/include/IContext.hpp +++ b/include/IContext.hpp @@ -7,10 +7,10 @@ class IContext { public: virtual ~IContext() {} - + virtual void setMinVersion (const int& min)=0; virtual void setMajorVersion(const int& maj)=0; - virtual void create(); + virtual bool create()=0; virtual const std::string version() const=0; virtual const std::string name() const=0; virtual int depthSize() const=0; @@ -19,4 +19,4 @@ public: virtual int blueDepth() const=0; }; -#endif // ICONTEXT_HPP \ No newline at end of file +#endif // ICONTEXT_HPP diff --git a/libBoo.pro b/libBoo.pro index 363cfe8..394141e 100644 --- a/libBoo.pro +++ b/libBoo.pro @@ -1,5 +1,8 @@ CONFIG -= Qt CONFIG += app c++11 +unix:CONFIG += link_pkgconfig +unix:PKGCONFIG += x11 + include(libBoo.pri) include(test/test.pri) diff --git a/src/CGLXContext.cpp b/src/CGLXContext.cpp index 59fed1b..0e6a6d5 100644 --- a/src/CGLXContext.cpp +++ b/src/CGLXContext.cpp @@ -2,10 +2,28 @@ #include CGLXContext::CGLXContext() + : m_majVersion(3), + m_minVersion(3), + m_display(nullptr) { std::cout << "Hello from GLX" << std::endl; } +bool CGLXContext::create() +{ + return true; +} + +void CGLXContext::setMinVersion(const int& min) +{ + m_minVersion = min; +} + +void CGLXContext::setMajorVersion(const int& maj) +{ + m_majVersion = maj; +} + const std::string CGLXContext::version() const { return "Invalid version"; diff --git a/test/main.cpp b/test/main.cpp index 295761d..544d17f 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -4,5 +4,12 @@ int main(int argc, char** argv) { + IContext* ctx = new CContext; + + if (ctx->create()) + { + } + + delete ctx; return 0; }