Skip to content

witcherofthorns/csharp-sdl-imgui

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# SDL2 + IMGUI


This is a project for game creation, OpenGL window context creation in SDL2 and input control, implemented in C#
All ImGui draw calls are called from the classic Nuget ImGui.Net package and have linked with intern SDL and SDL_GL calls

Getting Started

It is assumed that you are using SDL2 in your project.
for create an SDL window with an OpenGL context:

(_window, _glContext) = ImGuiGL.CreateWindowAndGLContext("SDL Window", 800, 600);
_renderer = new ImGuiGLRenderer(_window, _glContext);

For rendering (drawing) a new frame
usually at the end of a while loop:

_renderer.ClearColor(0.05f, 0.05f, 0.05f, 1.00f);
_renderer.NewFrame();
ImGui.ShowDemoWindow();
_renderer.Render();
SDL_GL_SwapWindow(_window);

Repo Structure

  • Example: contains a simple example project that displays the ImGui demo in an SDL window and shows the basic structure on how you can setup your own game loop. This demo expects that you have SDL2 already installed on your computer and does not provide any SDL2 binaries.
  • General: contains the csproj file and ImGui,SDL2 and OpenGL folders.

Warning

To work with SDL you will need the original sdl2.dll runtime library which was written in C/C++, you can find it on this site, this is what the C# SDL linked to for native and processed calls, you should put sdl2.dll in the folder with your executable exe file. If you need SDL_ttf and SDL_image and so on, then you should also download them in binary .dll format and copy them to the folder with your compiled executable file

License

Whatever

Acknowledgements

This code began as a fork of the opengl4sharp lib. Unfortunately, that didn't work out so this ended up being a near total rewrite besides keeping the OpenGL enums.

About

This is a project for game creation, OpenGL window context creation in SDL2 and input control, implemented in Csharp

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%