More things
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 7m11s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 7m11s
This commit is contained in:
59
main.cpp
59
main.cpp
@@ -18,6 +18,10 @@ std::ostream& operator<<(std::ostream& os, const Vector2& v) {
|
||||
}
|
||||
|
||||
class MyWindow : public ReWindow::RWindow {
|
||||
public:
|
||||
float r = 255;
|
||||
float b = 0;
|
||||
float g = g;
|
||||
public:
|
||||
MyWindow(const std::string& title, int w, int h) : ReWindow::RWindow(title, w, h) {}
|
||||
|
||||
@@ -26,7 +30,13 @@ class MyWindow : public ReWindow::RWindow {
|
||||
void OnKeyDown(const ReWindow::KeyDownEvent& e) override {}
|
||||
|
||||
void OnRefresh(float elapsed) override {
|
||||
glClearColor(255, 0, 0, 255);
|
||||
if (r >= 1)
|
||||
r = 1;
|
||||
if (b >= 1)
|
||||
b = 1;
|
||||
if (g >= 1)
|
||||
g = 1;
|
||||
glClearColor(r, g, b, 255);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
GLSwapBuffers();
|
||||
auto pos = GetMouseCoordinates();
|
||||
@@ -179,13 +189,54 @@ int main() {
|
||||
windowdos->SetRenderer(ReWindow::RenderingAPI::OPENGL);
|
||||
|
||||
windowdos->Open();
|
||||
/*
|
||||
|
||||
auto HSVtoRGB = [&] (float H, float S, float V)
|
||||
{
|
||||
float s = S / 100;
|
||||
float v = V / 100;
|
||||
float C = s * v;
|
||||
float X = C * (1 - fabs(fmod(H / 60.0, 2) - 1));
|
||||
float m = v - C;
|
||||
float r, g, b;
|
||||
|
||||
if (H >= 0 && H < 60)
|
||||
r = C, g = X, b = 0;
|
||||
else if (H >= 60 && H < 120)
|
||||
r = X, g = C, b = 0;
|
||||
else if (H >= 120 && H < 180)
|
||||
r = 0, g = C, b = X;
|
||||
else if (H >= 180 && H < 240)
|
||||
r = 0, g = X, b = C;
|
||||
else if (H >= 240 && H < 300)
|
||||
r = X, g = 0, b = C;
|
||||
else
|
||||
r = C, g = 0, b = X;
|
||||
|
||||
int R = (r + m) * 255;
|
||||
int G = (g + m) * 255;
|
||||
int B = (b + m) * 255;
|
||||
|
||||
window->r = R;
|
||||
window->g = G;
|
||||
window->b = B;
|
||||
window->ManagedRefresh();
|
||||
//sleep(5);
|
||||
};
|
||||
float H;
|
||||
float S;
|
||||
float i;
|
||||
while (!windowdos->IsClosing()) {
|
||||
//window->PollEvents();
|
||||
// HSVtoRGB(H, S,100);
|
||||
//H = (i / window->GetWidth()) * 360;
|
||||
//S = (i / window->GetHeight()) * 100;
|
||||
// i += 0.1;
|
||||
//window->ManagedRefresh();
|
||||
window->r += 0.1;
|
||||
window->g += 0.1;
|
||||
window->ManagedRefresh();
|
||||
windowdos->ManagedRefresh();
|
||||
//sleep(10);
|
||||
}
|
||||
*/
|
||||
delete window;
|
||||
delete windowdos;
|
||||
return 0;
|
||||
|
@@ -251,6 +251,10 @@ void RWindowImpl::PollEvents() {
|
||||
if (pPlatform->xev.type == Expose)
|
||||
{
|
||||
Logger::Debug(std::format("Event '{}'", "Expose"));
|
||||
// Essentially allows more than one window to be drawable
|
||||
// https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib
|
||||
// https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXMakeCurrent.xml
|
||||
//glXMakeCurrent(pPlatform->display, pPlatform->window, pPlatform->glContext);
|
||||
}
|
||||
|
||||
// NOTE: This event is functionally useless, as it only informs of the very beginning and end of a mouse movement.
|
||||
@@ -285,6 +289,26 @@ void RWindowImpl::PollEvents() {
|
||||
}
|
||||
|
||||
|
||||
void RWindowImpl::Refresh() {
|
||||
// Essentially allows more than one window to be drawable
|
||||
// https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib
|
||||
// https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXMakeCurrent.xml
|
||||
glXMakeCurrent(pPlatform->display, pPlatform->window, pPlatform->glContext);
|
||||
|
||||
PollEvents();
|
||||
OnRefresh(delta_time);
|
||||
|
||||
// Only call once and cache the result.
|
||||
currentMouse.Position = GetAccurateMouseCoordinates();
|
||||
|
||||
/// TODO: Implement optional minimum epsilon to trigger a Mouse Update.
|
||||
if (currentMouse.Position != previousMouse.Position) {
|
||||
processMouseMove(previousMouse.Position, currentMouse.Position);
|
||||
previousMouse.Position = currentMouse.Position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Might make the window go off the screen on some window managers.
|
||||
void RWindowImpl::SetSize(int newWidth, int newHeight) {
|
||||
if (!resizable) return;
|
||||
|
@@ -215,6 +215,7 @@ void RWindowImpl::ManagedRefresh()
|
||||
UpdateFrameTiming(dt);
|
||||
}
|
||||
|
||||
/*
|
||||
void RWindowImpl::Refresh() {
|
||||
PollEvents();
|
||||
OnRefresh(delta_time);
|
||||
@@ -228,6 +229,7 @@ void RWindowImpl::Refresh() {
|
||||
previousMouse.Position = currentMouse.Position;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
float RWindowImpl::ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end) {
|
||||
auto frame_time = end - start;
|
||||
|
Reference in New Issue
Block a user