Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic SDL2 example. #58

Closed
wants to merge 1 commit into from
Closed

Conversation

dadair-ca
Copy link

I have added a basic SDL2 example directory. Thus, opengl_example now includes both a glfw_example and sdl2_example directory. I have tested both glfw and sdl2 directories building on OSX 10.9.4. I have not tested SDL2 on Windows, and in fact windows-specific #defines and functions were removed.

The SDL2 example is the ultimate bare-minimum to have the widgets showing. There is no keyboard-mapping, for example. As well, SDL2 must already be installed (not included within the example directory itself).

The example could be changed to include the TestWindow, but I know when I first looked at the repository I wanted an example that was the ultimate bare-minimum to get going, so I thought I would implement that. If people want extra functionality, they can look at the other example files to see what else can be added.

Just my thoughts, let me know!

@ocornut
Copy link
Owner

ocornut commented Oct 6, 2014

David,

  • I can't take an incomplete example they have to match features.
  • If understanding how to implement keyboard and other features is too much to understand then we have to make the example clearer, but the example cannot skip on the feature. It should be about 20 lines to get keyboard to function. See bottom post in Keyboard storage can't fit keycodes that are large #37
    I'm interested in your feedback in what part of the OpenGL example were confusing, if I can improve on that I'll do it.
  • glew/glfw are duplicated which create an unnecessary amount of extra files (to some degree even one copy of the files are already unnecessary but their presence is to make Windows compilation less of a hassle). I'd prefer to remove glew/glfw alltogether, and it's fine not to include SDL in the directory (you didn't).

The confusion with SDL2 may be that keycode don't fit within the [512] array, but you can fill the KeyMap array with 0..ImGuiKey_Count-1 and then just fill the KeysDown[] array. In fact the presence of 2 arrays is unnecessary and I will rework the API to remove the [512] array at all.

I don't expect you to update the PR but I will keep this open. After I'm done cleaning up the input I could include the finished SDL example in here. I need to rework a few other things which passing input which will break old code so I'd rather do both of them at the same time to limit the hassle.

@dadair-ca
Copy link
Author

Hi Omar,

Totally reasonable. I will attempt to address all of the issues you have raised. #37 definitely will help adding keyboard input. I had attempted that, but the exact issues addressed in #37 were giving me grief.

I will work on my SDL2 example within the next few days here and push a working example. I'll address the duplication of glfw/glew as well, by placing them in the parent opengl folder.

@ocornut
Copy link
Owner

ocornut commented Oct 7, 2014

I was under the fleeting impression that SDL would be able to work without glfw/glew but that isn't the case?

@xythobuz
Copy link
Contributor

xythobuz commented Oct 7, 2014

You definitely don't need glfw/glew! See 07045fb & 4481055
If you want I could open another pull request with this...

@ocornut
Copy link
Owner

ocornut commented Mar 31, 2015

FYI there's also an Allegro 5 example here:
https://github.com/bggd/a5imgui_example

The extra file are easy to add, but I'm not sure how to integrate them. I don't want solutions building to be failing for users under Windows who don't have the libraries, obviously. So perhaps they should be different solutions? but that's a little extra burden of testing/maintaining.

@ocornut
Copy link
Owner

ocornut commented Jul 8, 2015

More recent SDL2 example merged (#233)

@ocornut ocornut closed this Jul 8, 2015
ocornut added a commit that referenced this pull request Jul 30, 2016
…les (#323)

Missing support Vulkan (#549), Apple (#575, #247), SDL (#58, #356),
Allegro, Marmalade (#368, #375)
ocornut added a commit that referenced this pull request Sep 18, 2017
…les (#323)

Missing support Vulkan (#549), Apple (#575, #247), SDL (#58, #356),
Allegro, Marmalade (#368, #375)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants