Request for guidance about adaptation of your Modern OpenGL triangle program - to add simple user interface

  • David Bailey
    Likes 0

    Problem Description

    Firstly, thank you for the excellent Modern OpenGL tutorials on YouTube.

    I have not finished the series but I have got far enough to achieve my initial goal - a working 3D model of my multi-element robot - with shaders in separate files and a working camera.
    (I am a retired engineer and the actual robot design/build is my retirement hobby project).
     
    I have developed the 3D model in modern OpenGL and C++ (using GLEW and GLFW) running on a MacPro (OS 10.12 and Xcode 8 ) created as a Command-LIne Project using C++.
     
    However recognising that what I want to do may require Objective-C I have also created a Cocoa/Objective-C version, with mixed language to use the original C++ files.
     
    I now wish to have on screen control of the robot actuator settings - with buttons / sliders objects in the same window as the OpenGL view of the robot.
     
    So I have this question:-
     
    Please can you guide me as to how I can take your simplest triangle example, but adapt it so that the OpenGL view occupies a portion of the window and the remainder of the window has a slider to undertake an action such as changing the colour of the triangle and a text box to output a value for the colour ?
     
    I can see how to design the buttons/text boxes/sliders and “communicate" with them in Objective-C and Cocoa (both of which I am learning) but I can’t work out how to combine that with the robot OpenGL view in the same window. (This combined application will become the controller for the actual robot.)
     
    I have worked through old and new editions of the books "Programming in Objective-C”,  "Cocoa Programming for MacOS X" and the "Open GL Programming Guide" and searched the internet for hours. I have found lots of forum threads where people are saying that this specific subject is hardly addressed anywhere.
     
    I have tried to create a window with an NSOpenGLview and buttons etc. but I can’t work out how to make the openGL program run in that “view" - I don’t even know if that is a valid approach.
     
    Explanations and examples I have found mostly seem to be either old OpenGL (using GLUT),  Swift,  Objective-C (but designed for iOS - not OS), too old to run on my computer, or too complicated for me to understand !
     
    At my age I would prefer NOT to have to learn Swift !! (My primary aim is to complete the actual robot.)
     
    I am really struggling to understand how to proceed and I would appreciate any guidance you can provide.
     
    Thankyou very much

  • Sonar Systems admin
    Likes 0

    I would recommend taking a look at this https://github.com/wjakob/nanogui

     

  • David Bailey
    Likes 0

    Thankyou and I appreciate the link, but I am afraid that using nanogui is way outside my capabilities.

    My Mac OS X terminal knowledge/useage is very limited, clang is virtually unknown to me, and the c++ code is beyond my understanding.

    - This was why I was seeking a simple xcode project example at the very simplest level, in a similar style to the Triangle example for  Modern OpenGL.

    I only managed to learn the Modern OpenGL by painstakingly following every step of the SonarSystem tutorials !


  • Sonar Systems admin
    Likes 0

    How well do you know C++?

  • David Bailey
    Likes 0

    My C++ is limited to what I have learned from attempting to merge my robot “mathematical model” (C  with old OpenGL) with examples of Xcode projects using Modern OpenGL, which at the time where mostly in C++.

    - So I worked through 9 chapters of “Professional C++” up to including “Mastering Clasess and Objects” and “merged” my robot (C) with your Modern Open GL tutorial in C++ (with spinning object) and hence got my robot “moving”.

    I then designed a multi-button controller – with my own design of “buttons” - in a similar Xcode project , C and C++  with Modern OpenGL.

    That is my total C++ experience !

    My question arises from my wish to merge my programmes so that the controller “commands” can be passed to the model.

    At the moment I am doing that by passing the data via an intermediate desktop file – it works but it is not elegant.

  • Sonar Systems admin
    Likes 0

    Are yousing GLFW or SFML or SDL for the window creation?

  • David Bailey
    Likes 0

    I am using GLFW for window creation.

  • David Bailey
    Likes 1

    Thankyou for the above references.

    I have checked them all and this has helped me in a surprising way. From looking at some of the sample screenshots, I have realised that I am already 90% of the way to my own solution.

    I now realise that all I need to do is have 2 OpenGL views within my main window and have the robot 3D OpenGL model running in one, and my own OpenGL control panel running in the other !!

    I didn’t realise how simple it was to create mutliple views.

    So your support has given me the hint I was seeking, but in an unexpected way ! – Thank you very much.

     


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Awesome to hear they helped, feel free to post any other questions you may have.

Login to reply