Code Monkey home page Code Monkey logo

glfwpp's Introduction

Hello there

I am a student at the Warsaw Staszic High School. My main areas of interest are physics and computer science. I am especially into advanced C++ programming and physically based real-time rendering. You can find some of my projects on Github. I also host an educational YouTube channel, where I share my knowledge with the world.

I also take part in Cyberduck – a robotics project whose goal is to create a portable aqueous meteorological station in the shape of a mallard. Additionally, I also participate in PaSh – a shell-script parallelisation project hosted by the Linux Foundation.

In free time, I like doing renders in Blender – an open-source 3D graphics suite. You can find my works on my website. You can also find there a showcase of renderers of my own making.

glfwpp's People

Contributors

adi-g15 avatar ahsoltan avatar arkeet avatar carlowood avatar dependabot[bot] avatar fossabot avatar janekb04 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

glfwpp's Issues

multiple windows

If you build several windows:

#include <vector>
#include "include/glfwpp/glfwpp.h"
static void keyboard_callback(glfw::Window& W, glfw::KeyCode K, int, glfw::KeyState S, glfw::ModifierKeyBit)
{
  if(K == glfw::KeyCode::Escape && S == glfw::KeyState::Release) W.setShouldClose(true);
}

int main()
{
  std::vector<glfw::Window> DSE {};

  [[maybe_unused]]auto GLFW = glfw::init();

  DSE.emplace_back( 640, 480, "GLFWPP N_1" );
  DSE.back().keyEvent.setCallback(keyboard_callback);

  DSE.emplace_back( 640, 480, "GLFWPP N_2" );
  DSE.back().keyEvent.setCallback(keyboard_callback);

  DSE.emplace_back( 640, 480, "GLFWPP N_3" );
  DSE.back().keyEvent.setCallback(keyboard_callback);

  while (!DSE.empty())
  {
    for(auto& W: DSE)
    {
      glfw::makeContextCurrent(W);
      glfw::pollEvents();

      if(W.shouldClose())
      {
        auto it = std::find_if(DSE.begin(), DSE.end(), [&W](const auto& cW){ return cW == W; });
        if(it != DSE.end()) DSE.erase(it);
      }
    }
  }
}

then the event handler only connects to the latter. Maybe I'm doing wrong?

Fails initialization with vulkan

Using Vulkan API (glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API)).

Assertion failed: errorCode_ != GLFW_NOT_INITIALIZED, file D:\Repositories\Engine\glfwpp\include\glfwpp\glfwpp.h, line 24

Using glfw::init() does not initialise the glfw. Standart glfwInit() works thou.
Using glfw::init after glfwInit() changes nothing, but using glfw::init() first has no error. I am concerned whether i need to call glfwTerminate() thou. Trying to store GlfwLibrary in a smart pointer causes error after window is closed.
I suspect it might be GlfwLibrary dying before window is initialized...

Add `.editorconfig`

It will mandate the coding style and other settings in a cross-editor manner.

Separate GLFW examples from the main GLFW repository

Separate examples as well as their dependencies. Maybe have them as a submodule? This will remove the need to use glew, imgui and other dependencies only examples have with GLFWPP. After separation glew-cmake should probably be swapped for a different OpenGL loader as for this one FOSSA detects license issues.

Build failure on GCC 12.2.0: Missing include for `std::exchange`

OS: Ubuntu 22.10
Compiler: GCC 12.2.0

Relevang build log:

...
[ 72%] Building CXX object examples/CMakeFiles/glfwpp_example_basic.dir/basic.cpp.o
In file included from /home/automatic/projects/glfwpp/include/glfwpp/joystick.h:4,
                 from /home/automatic/projects/glfwpp/include/glfwpp/glfwpp.h:10,
                 from /home/automatic/projects/glfwpp/examples/basic.cpp:3:
/home/automatic/projects/glfwpp/include/glfwpp/helper.h: In constructor ‘constexpr glfw::detail::OwningPtr<T>::OwningPtr(glfw::detail::OwningPtr<T>&&)’:
/home/automatic/projects/glfwpp/include/glfwpp/helper.h:49:27: error: ‘exchange’ is not a member of ‘std’
   49 |                 _ptr{std::exchange(other._ptr, nullptr)}
      |                           ^~~~~~~~
/home/automatic/projects/glfwpp/include/glfwpp/helper.h: In member function ‘constexpr glfw::detail::OwningPtr<T>& glfw::detail::OwningPtr<T>::operator=(glfw::detail::OwningPtr<T>&&)’:
/home/automatic/projects/glfwpp/include/glfwpp/helper.h:55:29: error: ‘exchange’ is not a member of ‘std’
   55 |                 _ptr = std::exchange(other._ptr, nullptr);
      |                             ^~~~~~~~
/home/automatic/projects/glfwpp/include/glfwpp/helper.h: In instantiation of ‘constexpr glfw::detail::OwningPtr<T>::OwningPtr(glfw::detail::OwningPtr<T>&&) [with T = GLFWwindow]’:
/home/automatic/projects/glfwpp/include/glfwpp/window.h:446:63:   required from here
/home/automatic/projects/glfwpp/include/glfwpp/helper.h:49:17: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘GLFWwindow*’ in initialization
   49 |                 _ptr{std::exchange(other._ptr, nullptr)}
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [examples/CMakeFiles/glfwpp_example_basic.dir/build.make:76: examples/CMakeFiles/glfwpp_example_basic.dir/basic.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:374: examples/CMakeFiles/glfwpp_example_basic.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

Was building previously without issues on Ubuntu 22.04 and GCC 11.2.0, seems like libstdc++ devs have cleaned up their headers and <type_traits> no longer transparently includes <utility>. Which shouldn't have been something you'd rely on either way.

Add move semantics to objects and consider their nullability

Currently the objects are non-copyable, but also non-movable. This limits their usage. They can stay non copyable like in GLFW, but they should be movable as they are merely GLFW object owners. As they can also be constructed from GLFW object handles, which can be NULL perhaps an isNull() method should be added to test if the object has been moved-from and/or constructed from a null GLFW handle. Otherwise the construction from a null GLFW handle should be prohibited by throwing an exception in the converting constructor. Assert should be added in methods to check that the object is non-null.

Force LF line endings on all text files

A .gitattributes file should be added in the root of the project to ensure that all commits are using Unix line endings.
Example file:

* text=auto eol=lf

Better C++ style error support.

C++ has an Error Handling facility. This includes error categories by means of which collisions between equal integer error values can be avoided.

This means that in C++ one should use std::error_code instead of int.

I propose to allow for the user to set a call back for errors that passes a std::error_code instead of an int.
Currently it is not possible to set an error call back other than overriding what glfwpp has set (in which case
you get an int, of course; and lose the advantage of the wisdom in the current builtin errorCallback).

Aka - the user calls libary.set_error_callback([](std::error_code code, std::string what){ ... }) and is called back for runtime errors (we can leave in the asserts, although not everyone might want to use an assert :/).

I implement this for every C library that I use, it is very nice to have general error codes.
I already implemented this for glfwpp too, see my gui_ErrorCodes.cxx.

So, if you think it is a good idea I can integrate it into glfwpp for you and do a pull request.

PS The THROW_ALERTC in that code throws an exception that automatically converts the enum to a std::error_code,
when caught and printed, I get - for example -:

WARNING       : AIAlert: 
    glfw3::error_callback(65546, "Cannot make current with a window that has no OpenGL or OpenGL ES context"):
    The specified window has no context (GLFW_NO_WINDOW_CONTEXT), caught in HelloTriangleVulkanApplication.cxx.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.