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>
|
||||
|
||||
class glut_window : public blt::window {
|
||||
private:
|
||||
|
||||
protected:
|
||||
void createGLUTWindow();
|
||||
void destroyGLUTWindow();
|
||||
public:
|
||||
glut_window();
|
||||
virtual void createWindow() override;
|
||||
virtual void destroyWindow() override;
|
||||
virtual ~glut_window();
|
||||
glut_window() = default;
|
||||
glut_window(int width, int height);
|
||||
void createWindow() override;
|
||||
void destroyWindow() override;
|
||||
~glut_window() override;
|
||||
|
||||
virtual bool setResizeable(bool resizeEnabled) override;
|
||||
virtual bool setWindowSize(int width, int height) override;
|
||||
virtual int getWidth() override;
|
||||
virtual int getHeight() override;
|
||||
bool setResizeable(bool resizeEnabled) override;
|
||||
bool setWindowSize(int width, int height) override;
|
||||
|
||||
virtual bool isKeyDown(int key) override;
|
||||
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;
|
||||
void render();
|
||||
};
|
||||
|
||||
#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
|
||||
*/
|
||||
#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() {
|
||||
|
||||
createGLUTWindow();
|
||||
}
|
||||
|
||||
void glut_window::destroyWindow() {
|
||||
|
||||
destroyGLUTWindow();
|
||||
}
|
||||
|
||||
glut_window::~glut_window() {
|
||||
|
||||
destroyGLUTWindow();
|
||||
}
|
||||
|
||||
bool glut_window::setResizeable(bool resizeEnabled) {
|
||||
|
@ -25,29 +26,34 @@ bool glut_window::setResizeable(bool resizeEnabled) {
|
|||
}
|
||||
|
||||
bool glut_window::setWindowSize(int width, int height) {
|
||||
return false;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
return true;
|
||||
}
|
||||
|
||||
int glut_window::getWidth() {
|
||||
return 0;
|
||||
// TODO: a less hacky way of doing this.
|
||||
blt::window* currentlyActiveWindow = nullptr;
|
||||
|
||||
void glut_window_render(){
|
||||
if (currentlyActiveWindow != nullptr)
|
||||
((glut_window*)currentlyActiveWindow)->render();
|
||||
}
|
||||
|
||||
int glut_window::getHeight() {
|
||||
return 0;
|
||||
void glut_window::createGLUTWindow() {
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool glut_window::isMouseDown(int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void glut_window::registerKeyListener(std::function<(void) (bool)...> listener) {
|
||||
void glut_window::destroyGLUTWindow() {
|
||||
|
||||
}
|
||||
|
||||
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