wiggling around with the whole notion of what a renderer does and what not. Added simple wrapper for GLFWmonitor named display
This commit is contained in:
parent
3cc0fde1e1
commit
9773103a18
13 changed files with 252 additions and 148 deletions
|
@ -2,9 +2,11 @@
|
|||
set(hdrs
|
||||
include/pw/system/window.hpp
|
||||
include/pw/system/input.hpp
|
||||
include/pw/system/display.hpp
|
||||
)
|
||||
|
||||
set(srcs
|
||||
src/display.cpp
|
||||
src/window.cpp
|
||||
src/input.cpp
|
||||
)
|
||||
|
|
29
src/system/include/pw/system/display.hpp
Normal file
29
src/system/include/pw/system/display.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef PW_SYSTEM_DISPLAY_HPP
|
||||
#define PW_SYSTEM_DISPLAY_HPP
|
||||
|
||||
#include <pw/core/globals.hpp>
|
||||
#include <pw/core/point.hpp>
|
||||
|
||||
namespace pw {
|
||||
|
||||
class display {
|
||||
public:
|
||||
|
||||
typedef std::vector<display> list;
|
||||
|
||||
static const list& all() { return _displays; }
|
||||
|
||||
std::string name() const { return _name; }
|
||||
|
||||
protected:
|
||||
friend class window;
|
||||
|
||||
std::string _name;
|
||||
|
||||
static list _displays;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
10
src/system/src/display.cpp
Normal file
10
src/system/src/display.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include "pw/system/display.hpp"
|
||||
|
||||
|
||||
|
||||
namespace pw {
|
||||
|
||||
|
||||
display::list display::_displays;
|
||||
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
#include "pw/system/window.hpp"
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
//#include "glad/glad.h"
|
||||
|
||||
#include "pw/visual/context.hpp"
|
||||
#include "pw/system/input.hpp"
|
||||
#include "pw/system/display.hpp"
|
||||
|
||||
#include "pw/core/debug.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
@ -97,37 +99,65 @@ struct window::impl {
|
|||
// glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
void update_display_list()
|
||||
{
|
||||
display::_displays.clear();
|
||||
|
||||
// fetch all monitors
|
||||
int monitor_count = 0;
|
||||
GLFWmonitor** monitors = glfwGetMonitors(&monitor_count);
|
||||
|
||||
for (int i = 0; i < monitor_count;i++) {
|
||||
display d;
|
||||
d._name = std::string(glfwGetMonitorName(monitors[i]));
|
||||
|
||||
display::_displays.push_back(d);
|
||||
|
||||
// debug::d() <<
|
||||
}
|
||||
|
||||
// GLFWvidmode
|
||||
// glfwGetVideoModes() ... get all
|
||||
// glfwGetVideoMode( . get current
|
||||
// glfwGetMonitorPos(
|
||||
// glfwGetMonitorPhysicalSize(
|
||||
// glfwGetMonitorName();
|
||||
|
||||
}
|
||||
|
||||
impl()
|
||||
{
|
||||
// initialize
|
||||
glfwInit();
|
||||
|
||||
update_display_list();
|
||||
|
||||
// request specific version 3.2
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
|
||||
//
|
||||
_window = glfwCreateWindow(640, 480, "pixwerxs", nullptr, nullptr);
|
||||
|
||||
// make window current
|
||||
glfwMakeContextCurrent(_window);
|
||||
|
||||
// load opengl
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
debug::e() << "glad couldn't get OpenGL API";
|
||||
}
|
||||
|
||||
// check Version
|
||||
int major, minor, rev;
|
||||
major = glfwGetWindowAttrib(_window, GLFW_CONTEXT_VERSION_MAJOR);
|
||||
minor = glfwGetWindowAttrib(_window, GLFW_CONTEXT_VERSION_MINOR);
|
||||
rev = glfwGetWindowAttrib(_window, GLFW_CONTEXT_REVISION);
|
||||
|
||||
|
||||
// maybe something to pass to the outside
|
||||
// debug::d() << "OpenGL " << major << "." << minor << "." << rev;
|
||||
|
||||
|
||||
// if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
// {
|
||||
// debug::e() << "G";
|
||||
// return -1;
|
||||
// }
|
||||
debug::d() << "OpenGL " << major << "." << minor << "." << rev;
|
||||
|
||||
glfwSetWindowUserPointer(_window,this);
|
||||
|
||||
|
@ -142,14 +172,6 @@ struct window::impl {
|
|||
glfwSetCursorPosCallback(_window, cursor_pos_callback);
|
||||
glfwSetMouseButtonCallback(_window, mouse_button_callback);
|
||||
glfwSetScrollCallback(_window, scroll_callback);
|
||||
|
||||
|
||||
#if 0
|
||||
glfwMakeContextCurrent(_window);
|
||||
|
||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
~impl()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue