GLUT Window
parent
3d5deecc87
commit
fadfdd3014
|
@ -1,3 +1,3 @@
|
||||||
Start testing: Jan 16 14:18 EST
|
Start testing: Jan 17 09:27 EST
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
End testing: Jan 16 14:18 EST
|
End testing: Jan 17 09:27 EST
|
||||||
|
|
|
@ -9,25 +9,20 @@
|
||||||
#include <blt/window/window.h>
|
#include <blt/window/window.h>
|
||||||
|
|
||||||
class glut_window : public blt::window {
|
class glut_window : public blt::window {
|
||||||
private:
|
protected:
|
||||||
|
void createGLUTWindow();
|
||||||
|
void destroyGLUTWindow();
|
||||||
public:
|
public:
|
||||||
glut_window();
|
glut_window() = default;
|
||||||
virtual void createWindow() override;
|
glut_window(int width, int height);
|
||||||
virtual void destroyWindow() override;
|
void createWindow() override;
|
||||||
virtual ~glut_window();
|
void destroyWindow() override;
|
||||||
|
~glut_window() override;
|
||||||
|
|
||||||
virtual bool setResizeable(bool resizeEnabled) override;
|
bool setResizeable(bool resizeEnabled) override;
|
||||||
virtual bool setWindowSize(int width, int height) override;
|
bool setWindowSize(int width, int height) override;
|
||||||
virtual int getWidth() override;
|
|
||||||
virtual int getHeight() override;
|
|
||||||
|
|
||||||
virtual bool isKeyDown(int key) override;
|
void render();
|
||||||
virtual bool isMouseDown(int button) override;
|
|
||||||
// Function signature is window pointer to this, key press, pressed/released (true/false)
|
|
||||||
virtual void registerKeyListener(std::function<void(window*, int, bool)> listener) override;
|
|
||||||
// Function signature is window pointer to this, mouse button press, pressed/released (true/false)
|
|
||||||
virtual void registerMouseListener(std::function<void(window*, int, bool)> listener) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FINAL_PROJECT_WINDOW_H
|
#endif //FINAL_PROJECT_WINDOW_H
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0d2292e1d428f10d0102005e4580f1cbb5803a27
|
Subproject commit 12ec6a9334f4343e0815059070fc93ef86474633
|
|
@ -3,21 +3,22 @@
|
||||||
* Copyright (c) Brett Terpstra 2023 All Rights Reserved
|
* Copyright (c) Brett Terpstra 2023 All Rights Reserved
|
||||||
*/
|
*/
|
||||||
#include <window/window.h>
|
#include <window/window.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
glut_window::glut_window() {
|
glut_window::glut_window(int width, int height) : window(width, height) {
|
||||||
|
createGLUTWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glut_window::createWindow() {
|
void glut_window::createWindow() {
|
||||||
|
createGLUTWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glut_window::destroyWindow() {
|
void glut_window::destroyWindow() {
|
||||||
|
destroyGLUTWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
glut_window::~glut_window() {
|
glut_window::~glut_window() {
|
||||||
|
destroyGLUTWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool glut_window::setResizeable(bool resizeEnabled) {
|
bool glut_window::setResizeable(bool resizeEnabled) {
|
||||||
|
@ -25,29 +26,34 @@ bool glut_window::setResizeable(bool resizeEnabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool glut_window::setWindowSize(int width, int height) {
|
bool glut_window::setWindowSize(int width, int height) {
|
||||||
return false;
|
m_width = width;
|
||||||
|
m_height = height;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int glut_window::getWidth() {
|
// TODO: a less hacky way of doing this.
|
||||||
return 0;
|
blt::window* currentlyActiveWindow = nullptr;
|
||||||
|
|
||||||
|
void glut_window_render(){
|
||||||
|
if (currentlyActiveWindow != nullptr)
|
||||||
|
((glut_window*)currentlyActiveWindow)->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
int glut_window::getHeight() {
|
void glut_window::createGLUTWindow() {
|
||||||
return 0;
|
glutInit(nullptr, nullptr);
|
||||||
|
glutInitWindowSize(m_width, m_height);
|
||||||
|
glutInitDisplayMode(GLUT_RGBA);
|
||||||
|
glutCreateWindow("UwU Final Project!");
|
||||||
|
|
||||||
|
currentlyActiveWindow = this;
|
||||||
|
glutDisplayFunc(glut_window_render);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool glut_window::isKeyDown(int key) {
|
void glut_window::destroyGLUTWindow() {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool glut_window::isMouseDown(int button) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void glut_window::registerKeyListener(std::function<(void) (bool)...> listener) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void glut_window::registerMouseListener(std::function<(void) (bool)...> listener) {
|
void glut_window::render() {
|
||||||
|
for (const auto& HelloTAThisIsAVeryLargeNameForNoGoodReasonItIsntEvenDescriptive : renderFunctions)
|
||||||
|
HelloTAThisIsAVeryLargeNameForNoGoodReasonItIsntEvenDescriptive(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue