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

Standalone Windows and OSX OpenGL sample (no dependencies) #281

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
5 participants
@Pagghiu
Copy link
Contributor

commented Jul 21, 2015

This is a continuation of #135 updated to latest imgui master

  • Standalone samples that require no GLFW / GL3W
  • Works on Windows and OSX
  • Support for High DPI Displays
    imguistandalonewindows
    imguistandaloneosx
Standalone Windows and OSX OpenGL sample (no dependencies)
- No GLFW / GL3W
- Support for High DPI Displays
@ocornut

This comment has been minimized.

Copy link
Owner

commented Jul 21, 2015

Thanks!
Not sure when I'll have time to look at that but it'd be useful to have them.

NB those two files probably ought to be removed:
xcodeproj/project.xcworkspace/xcuserdata/stefano.xcuserdatad/UserInterfaceState.xcuserstate
xcodeproj/project.xcworkspace/xcuserdata/stefano.xcuserdatad/WorkspaceSettings.xcsettings

@ocornut

This comment has been minimized.

Copy link
Owner

commented Oct 14, 2015

I had a look at the wgl example but it looks like it needs lots of work to be readable, not full of noise and constructed like the other examples. Moreover I'm not sure if following a base from 2000 is good idea? (unless this is still the common way to setup a windows / gl example).

@Pagghiu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 15, 2015

I think the restructuring of the other examples has been happening after this PR, so I had no "guideline" reference then ;)
Aligning these to existing examples and cleaning up can of course be done.
I have been starting from this sample and I've been evolving into something slightly more structured in my own code base (a class instead of free functions and globals).
I have to check if it can be extracted and pushed here or if it depends on other parts of our framework.
Setup windows/gl sample without using external libs will always boil down to something like this as far as I know.

The question is if this is of any interest or everyone just uses SDL, GLFW etc.

@ocornut

This comment has been minimized.

Copy link
Owner

commented Oct 15, 2015

I think it is useful as reference. Started to clean it up myself and i got sidetracked slash discouraged with the amount of unnecessary crap ("// set the flag to true") but mostly I wondered if the basic logic was still valid for a Win32 app. If we think it is we can finish the cleanup.

@cocoademon

This comment has been minimized.

Copy link

commented Oct 17, 2015

I think it's a great idea to include a no-external-dependencies example.

However, at least on Windows, this sample doesn't appear to follow the
"proper context creation" approach here (for initializing a newer-than-1.1
OpenGL context):

https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)#Proper_Context_Creation

On 15 October 2015 at 19:08, omar notifications@github.com wrote:

I think it is useful as reference. Started to clean it up myself and i got
sidetracked slash discouraged with the amount of unnecessary crap ("// set
the flag to true") but mostly I wondered if the basic logic was still valid
for a Win32 app. If we think it is we can finish the cleanup.


Reply to this email directly or view it on GitHub
#281 (comment).

@ocornut

This comment has been minimized.

Copy link
Owner

commented Oct 17, 2015

Thanks, this is the sort of link I was hoping. That code was too old, we could use this to rewrite something based on the a mix of the GL and DirectX (for inputs, message pumping) example.

@vexe

This comment has been minimized.

Copy link

commented Jan 9, 2016

I don't understand why the highDpiScale variable exist. It was ruining mouse coordinates until I resize the window then it picks the right coords. And it was making the font quality bad. Removing that variable fixed both issues.

@ocornut

This comment has been minimized.

Copy link
Owner

commented May 20, 2018

@Pagghiu Been resurrecting the raw OSX example. One of the reason is that it will be useful for the upcoming viewport branch to have a viewport-compatible low-level implementation for more systems. In particular because GLFW doesn't currently provide all the features necessary for the current viewport implementation. Hopefully it will soon. (Also the splitting of backend between platform and renderer also makes extra examples easier to maintain).

Pacome helped me bring this up to date with latest best practices (reference counting), and I've been cleaning up to the best of my extents (read: struggling using a Mac). I can add you to the private branch if you want to look at it. The aim is to have a clean V1 of imgui_impl_osx.mm that doesn't support viewport (easy) then evolve that to a viewport-compatible version.

Things to do for V1

  • app doesn't start in front and with key focus (in spite of calling makeKeyAndOrderFront)
  • key events are not passed to app
  • support mouse cursors
  • would be nice storing native NS keys in io.KeysDown[] and using the io.KeyMap[] array as intended.
  • test integration with different renderer (currently only tested with GL2 one)
  • there's code for a menu but it doesn't seem to happen
  • the running demo app doesn't appear in alt-tab or the app list when running, is that normal? (I don't know OSX enough to tell if it's a normal behavior)

Why did your code have things such as:

    if (g_windowHeight == 0)
        g_windowHeight = 1;
..
        if (g_backingHeight == 0)
            g_backingHeight = g_windowHeight * 2;

etc.
Will try to look into those things! If you have time to help or advice it'd be amazing :)
Thanks!

void IMGUIExample_InitImGui()
{
ImGuiIO& io = ImGui::GetIO();
// Time elapsed since last frame, in seconds

This comment has been minimized.

Copy link
@sivu

sivu May 20, 2018

this comment is in a wrong place

This comment has been minimized.

Copy link
@ocornut

ocornut May 20, 2018

Owner

@sivu don’t worry about the PR details so much, it’s a super old PR. I’m now looking into splitting the code to integrate in the new examples/ folder being used in the viewport branch.

ocornut added a commit that referenced this pull request Jun 11, 2018

@ocornut ocornut referenced this pull request Jun 11, 2018

Open

OSX examples/bindings: help/maintainers wanted #1873

2 of 8 tasks complete
@ocornut

This comment has been minimized.

Copy link
Owner

commented Jun 11, 2018

@Pagghiu Closing this ooooold PR, moving to #1873 for the OSX code.
Several the issues I asked above were related to not making the window a Foreground window:

// Make the application a foreground application (else it won't receive keyboard events, see https://stackoverflow.com/questions/12145301/nswindow-doesnt-receive-keyboard-events)
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToForegroundApplication);

I think this wasn't an issue with the Xcode/sdk version you used back then but now it is.

A raw win32 + OpenGL example is missing should be much easier to do right now (by combining imgui_impl_win32.cpp + imgui_impl_openglx + some WGL cruft in main.cpp to create the GL context, if someone is tempted to do it. (Ref https://github.com/Pagghiu/imgui/blob/f82b0d8c728fda72c877634b82c1a9784e026ce4/examples/opengl_example/main_without_deps.cpp)

@ocornut ocornut closed this Jun 11, 2018

@Pagghiu

This comment has been minimized.

Copy link
Contributor Author

commented Jun 11, 2018

Excellent!
I've never found enough time to modernize this ancient pull request but looks like you've been doing great things over the macOS branch ;)

@ocornut ocornut added the osx/ios label Jul 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.