I grabbed the source code from Module 6 in the Advanced GUI Tutorials for use with RackAFX v6.6, and have been modifying that code to create an OpenGL view.
So far, I've gutted out the WaveFormView and have replaced it with my own class inheriting COpenGLView. I think I've got all the hooks there set up properly, and now I'm trying to set up my OpenGL context.
RackAFX and VSTGUI4 don't seem to natively support or include the libraries needed for OpenGL integration. Am I right about that? I've already included GL.h and GLU.h in the header file for my class inheriting COpenGLView, but those two libraries don't define all the needed functions and macros.
I'm fairly new to graphics programming and definitely skipped an important step in downloading and setting up some libraries which I read are needed for OpenGL 3.3 +. Initially, I'd assumed VSTGUI4 or RackAFX was already using OpenGL to some extent and that the libraries would already be included. But some Google searches have indicated that isn't the case? What is RackAFX using to render its graphics (MFC?), and does VSTGUI4 handle graphics rendering at all? What would be your suggestion for using OpenGL in RackAFX?
I'm going to try downloading and integrating GLFW to see if that does the trick, and will leave an update if and when I'm able to resolve the issue.
And apologies if I've asked or said anything confusing here. I'm fairly new to both RackAFX and OpenGL / graphics programming.
OpenGL is a little special, e.g. there's nothing like an OpenGL 3.3 library on windows. There only is the good old OpenGLv1.1 library and it more or less only "talks" to your graphics driver. I.e. the "real" OpenGL library IS your graphics driver. Every OpenGL function newer then v1.1 needs has to be queried separately thru the OpenGL-extension mechanism. For this cumbersome task there are some libraries, like glew and glee which will query all functions your opengl driver supports and fetch the function pointers for them so that you can call them. For real-world code this also means that you should prepare for a driver not supporting a queried function. And if used over a remote-desktop connection, you only can use OpenGL v1.1 anyway. For "real-world" code you would have to provide a fallback implementation for that scenario.
But regarding the OpenGL context, the COpenGLView will already set this up for you - it gives you a ready-to-use OpenGL context.
Depending on what you are trying to achieve, I think you will be fine with OpenGL v1.1, at least for you first steps in graphics programming.
I think GLFW will not be of much use in this case, as it will try to get user input and open a window with a opengl context for you. But both things will be done by the host and/or VSTGUI already in your scenario.
One basic thing that is differnt in the COpenGLView compared to all other VSTGUI views is that it does not do the rendering in the normal draw-method but via drawOpenGL. You need to call this somewhere, e.g. from the OnIdle method, otherwise it will never do any opengl drawing.
In the VSTGUI sources you can find an example, but it is not very well documented. A thing to note about that example is that it can do the opengl rendering either from a separate thread or from the OnIdle call, so it contains some code that's not necessary in every situation.
The class is TestopenGLView and starts at line 70:
All you need to link for OpenGL support should be opengl32.lib (and glu32.lib if you use it).
I hope this helps, feel free to come back to me with your graphics questions
One added comment - when Tom refers to the onIdle() method, he is talking about the update function that is called for each VSTGUI timer ping. Ordinarily, you would only have access to this function if you wrote it - i.e. you wrote your own custom GUI from scratch (last Module in Advanced GUI Tutorials).
However, to facilitate animations and other owner-draw views, I added the GUI_TIMER_PING message to showGUI( ) and it is used in the CustomViewsFour project that you have been working from. You would replace the Wave View updating code with your own call to drawOpenGL( )
// --- update/redraw
Tom is definitely the pro at OpenGL, but if you have any RAFX specific stuff I can help there too.
Thanks, both of you! Tom, the link to the example in particular was really useful - there's so little documentation out there for this stuff. I've managed to change the background color of the OpenGL view now... Baby steps, right?
I do want to use OpenGL 3.3+ if at all possible, a big goal with this project for me is to learn graphics programming, and I figure I may as well learn the newer stuff. I'm working on an audio visualizer plugin and believe I'll need the extra flexibility from newer OpenGL. Plus, I really want to learn how to write shaders.
I did realize that I don't need GLFW after making my original post... I downloaded and got glew compiling with my RackAFX project in VS2013. What I'm running into now is an entirely new issue, and I'm not quite sure how to solve this one. Whenever I make a call to a macro or function defined by glew in my code, RackAFX is unable to load the resulting dll. Everything compiles fine in Visual Studio, but attempting to load the plugin just brings up a popup from RackAFX: "Error loading DLL", followed by a prompt to recompile my project. If I comment out glew code, things run fine.
Do you guys have any intuition on what might be the source of the issue? I compiled glew using cmake for use in VS2013, thought I'd done that correctly. Right now I'm including glew as a 32 bit dynamic library.
Again, if I'm able to find a solution before a reply comes, I'll make sure to mention it.
Most Users Ever Online: 152
Currently Browsing this Page:
Guest Posters: 1
Newest Members:IgorVish, Arjuna, TomMilne, BaiJin, MarioG, caozbm, audio_coder, coder, Levioter, VariableCook
Moderators: W Pirkle: 470
Administrators: Tom: 74, JD Young: 80, Will Pirkle: 0, W Pirkle: 470