Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Using OpenGL in my Plugin
No permission to create posts
October 17, 2015
4:17 am
Avatar
aclif
Member
Members
Forum Posts: 8
Member Since:
October 16, 2015
sp_UserOfflineSmall Offline

Hey all,

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.

Thanks!

October 19, 2015
3:40 am
Avatar
Tom
Admin
Forum Posts: 65
Member Since:
April 3, 2014
sp_UserOfflineSmall Offline

Hi aclif,

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:
http://sourceforge.net/p/vstgu.....ewtest.cpp

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 Wink
-Tom

October 20, 2015
2:38 am
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

Thanks Tom!

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( )

case GUI_TIMER_PING:
{
// --- update/redraw
if(m_pOpenGLView)
{
m_pOpenGLView->drawOpenGL( );
}
return NULL;
}

Tom is definitely the pro at OpenGL, but if you have any RAFX specific stuff I can help there too.

- Will

October 20, 2015
4:08 am
Avatar
aclif
Member
Members
Forum Posts: 8
Member Since:
October 16, 2015
sp_UserOfflineSmall Offline

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.

October 20, 2015
4:23 am
Avatar
aclif
Member
Members
Forum Posts: 8
Member Since:
October 16, 2015
sp_UserOfflineSmall Offline

Agh! I made a stupid mistake and forgot to drop the .dll for glew in the same folder as the .dll generated for my project. I put that where it belongs, and now things are working again, for now!

Way too much time spent trying to figure out something so simple Confused

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online: W Pirkle
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Derek: 41

Peter: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 478

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 29

Topics: 479

Posts: 1870

Newest Members:

certvalue111, sobhana s, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 140

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 140