Giter VIP home page Giter VIP logo

egui_sdl2_gl's Introduction

Crates.io Documentation CI

Egui backend for SDL2 + Open GL

Example screenshot

This is a backend implementation for Egui that can be used with SDL 2 for events, audio, input et al and OpenGL for rendering.

I've included an example in the examples folder to illustrate how the three can be used together. To run the example, do the following:

cargo run --example basic
cargo run --example mix
cargo run --example demo_lib --features=use_epi

Starting with v13.1 SDL2 is 'bundled' as a cargo requirement and so SDL2 needn't be setup separately. If, however, you wish to be in control of the SDL2 setup, you can remove the bundled feature from the cargo.toml and set up the SDL2 framework separately, as described in the SDL2 repo above.

Note that using OpenGL involves wrapping any Open GL call in an unsafe block. Have a look at the src/painter.rs file to see what I mean. This of course means that all bets are off when dealing with code inside the unsafe blocks, but that's the price to pay when dealing with raw OpenGL.

Why would anyone want to use this then, you wonder? Well I would say the familiarity of using SDL2, the elegance of Egui and the power of OpenGL makes for a good combination in making games, emulators, graphics tools and such.

As far as the implementation goes, I've used Emil's original egui_glium and egui_web backends (see the egui github for source) as guides to implement this version, but have deviated in a couple of ways:

  1. It doesn't use the App architecture as used in the original code because I wanted to keep it as simple as possible.
  2. I've added a update_user_texture_data method to the painter class, which allows for easy dynamic updating of textures that need to be managed by Egui (to render in an Image control, say). See examples/example.rs to see how this can be useful.

I'm not an expert in Egui, Open GL or Rust for that matter. Please do submit an issue ticket (or better, send a PR!) if you spot something something that's out of whack in so far as the backend implementation goes. Issues regarding SDL2, Egui or OpenGL should be directed towards their respective repository owners!

Note: most of essential features are supported now.

egui_sdl2_gl's People

Contributors

ar37-rs avatar arekkusuva avatar arjunnair avatar d10sfan avatar firelightflagboy avatar frankvdstam avatar guillaumegomez avatar katyo avatar

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.