Git Product home page Git Product logo

minimal_window's Introduction

Build Status:

Minimal Window

A very small C library for putting pixels on the screen, perfect for software raytracing projects. 042a6961-4224-4d63-b3b7-650ed83b29cd

How to include in your CMake project

  1. Install the relevant libraries and runtimes: see Supported Platforms
  2. Clone or download the repo. to your project
  3. Use add_subdirectory("/path/to/minimal_window") with correct path
  4. Link to minimal_window: target_link_libraries(your_target PRIVATE minimal_window)

Alternatively, you can use ExternalProject, FetchContent, CPM, or any other method that you are comfortable with, minimal_window is a modern CMake project and should be very easy to include

Supported Platforms

  • Win32 (Windows)
  • Wayland (Linux):
    Wayland development packages are needed for building (for example on Ubuntu: sudo apt install libwayland-dev wayland-protocols), you also need a running Wayland session at runtime. You also need pkg-config sudo apt install pkg-config.
  • X11 (Linux and macOS):
    * Linux: X11 development packages are needed for building (for example on Ubuntu: sudo apt install libx11-dev), you also need a running X11 session at runtime.
    * macOS: XQuartz is needed at runtime.
  • Native macOS

Tested Compilers

  • GCC
  • MSVC
  • Apple Clang
  • Clang

API

void minimal_window_create_fixed_size_window(int width, int height);
bool minimal_window_process_events();
void minimal_window_draw_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t b);
void minimal_window_request_update();

Example: filling window with white

#include <minimal_window.h>
int main() {
  int width = 800, height = 600;
  minimal_window_create_fixed_size_window(width, height);
  while (minimal_window_process_events()) {
    for (int i = 0; i < width; i++)
      for (int j = 0; j < height; j++)
        minimal_window_draw_pixel(i, j, 255, 255, 255);
  }
  return 0;
}

Example: raytracing

https://github.com/iyadahmed/minimal_window_raytracing/blob/main/main.c

minimal_window's People

Contributors

esnosy avatar

Stargazers

 avatar  avatar Arne Koenig avatar  avatar Thomas L avatar Rohit Tanwar avatar Sandalots avatar Silvio Traversaro avatar Bruno Levy avatar  avatar  avatar Forest Collins Sharp avatar Thomas Murphy avatar  avatar  avatar  avatar Jens Pitkänen avatar Alex James avatar Joshua Minor avatar Bassel Yasser avatar Iohannes Mboumba avatar XMarius avatar Phil Gosch avatar  avatar Allan MacKinnon avatar Wellington Júnior avatar angelofb avatar Ali Emre Gülcü avatar Megamind avatar ERAGON avatar Nate Rupsis avatar  avatar Julien avatar  avatar Viktor Soukup avatar Max Bernstein avatar Romain NOËL avatar Yuri dos Santos avatar zelly avatar Stephen Foster avatar Mika Pi avatar Kolodyazhnyi Aleksandr avatar Pierre Kestener avatar F. avatar Jefferson Amstutz avatar LunaticWyrm avatar Vilerio avatar  avatar Matt Sylvia avatar Renan Bomtempo avatar Zhao Xiaohong avatar _Zaizen_ avatar Rattan Pepper avatar Адитя avatar  avatar Gregory Ginzburg avatar omar avatar  avatar  avatar Chandler Klüser avatar Oliver Wrulich avatar  avatar Can Delibas avatar Marek Kraus avatar sad1e avatar dan avatar Qubit avatar Sam Oliver avatar Jonas Sorgenfrei avatar alezzacreative avatar  avatar Christopher Ting avatar Dinkan avatar Gaston Cababie avatar Lei ZHANG avatar  avatar Gurpreet Singh avatar Victor Li avatar  avatar Krzysztof Gabis avatar deniz avatar Fabian Oppermann avatar Qingxiang Meng (孟庆祥) avatar Maged E. William avatar Joe Mwangi avatar Zakarya Meddad avatar  avatar  avatar  avatar Inês Almeida avatar Sophie Kirschner avatar  avatar Octodice avatar Rasmus Källqvist avatar Lionel Dominjon avatar DruggedBunny avatar Juho Saarinen avatar László Matuska avatar goubermouche avatar Ish avatar

Watchers

Allan MacKinnon avatar  avatar

minimal_window's Issues

Win32: update window while moving

on Win32 maybe we need to handle WM_MOVE and redrawing the window inside that,
but the problem is that handling the move event (even right now with the default handler) is blocking,

so even if we redraw the window, the user code isn't executing and isn't producing new frames, so it needs more thinking

Update every frame or provide an update API

Currently the window only updated when needed by operating system, so it is only good for static results, but not animation, we could either:
1- Update the window every frame (damaging Win32 window or Wayland surface etc.)
2- Provide the update as a function for user for example minimal_window_update)

Issues on X11

1- The window does no update unless maximized or resized
2- The window closes whenever any keyboard button is pressed (this is just because of the switch case)

firefox_SJ5uSBSEm7.mp4

Pixels get drawn out of bounds on Windows

Filling a screen with color and leaving 10 pixels, you can see the entire screen still gets filled until you increase that 10 to 25 or so
image

on Wayland everything works as expected
image

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.