Adding to juce::OpenGLExtensionFunctions


#1

I see this problem has been discussed before a few years ago but I don’t see any solution to my problem. I have developed an application on Mac that uses OpenGL and that I’m porting to Windows. I followed the instruction in this video to add OpenGL support to my Visual Studio project: https://www.youtube.com/watch?v=k9LDF016_1A which worked perfectly. However I’m seeing build errors listed below. Presumably the GL functions that I need are not all defined in OpenGLExtensionFunctions. How can they be added? Or is there a workaround?

Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	719	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	736	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	748	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	765	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glGenBuffers"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	817	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	818	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBufferData"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	819	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glGenBuffers"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	826	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	829	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBufferData"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	830	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	871	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	872	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glVertexAttribPointer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	878	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glEnableVertexAttribArray"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	879	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glVertexAttribPointer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	885	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glEnableVertexAttribArray"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	886	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glDisableVertexAttribArray"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	894	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glDisableVertexAttribArray"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	896	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	899	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glBindBuffer"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	900	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glDeleteBuffers"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	975	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glDeleteBuffers"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	976	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glGetAttribLocation"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	1019	
Error (active)	E0135	class "juce::OpenGLExtensionFunctions" has no member "glad_glGetAttribLocation"	ConcertKeyboardist_App	c:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	1024	
Error	C2039	'glad_glGetUniformLocation': is not a member of 'juce::OpenGLExtensionFunctions' (compiling source file ..\..\Source\MainWindow.cpp)	ConcertKeyboardist_App	c:\users\chrisgr\ck\source\ScrollingNoteViewer.h	274	
Error	C2039	'glad_glGetUniformLocation': is not a member of 'juce::OpenGLExtensionFunctions' (compiling source file ..\..\Source\Main.cpp)	ConcertKeyboardist_App	c:\users\chrisgr\ck\source\ScrollingNoteViewer.h	274	
Error	C2039	'glad_glGetUniformLocation': is not a member of 'juce::OpenGLExtensionFunctions' (compiling source file ..\..\Source\MainComponent.cpp)	ConcertKeyboardist_App	c:\users\chrisgr\ck\source\ScrollingNoteViewer.h	274	
Error	C2039	'glad_glGetUniformLocation': is not a member of 'juce::OpenGLExtensionFunctions' (compiling source file ..\..\Source\ScrollingNoteViewer.cpp)	ConcertKeyboardist_App	c:\users\chrisgr\ck\source\ScrollingNoteViewer.h	274	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	719	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	736	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	748	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	765	
Error	C2039	'glad_glGenBuffers': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	817	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	818	
Error	C2039	'glad_glBufferData': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	819	
Error	C2039	'glad_glGenBuffers': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	826	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	829	
Error	C2039	'glad_glBufferData': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	830	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	871	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	872	
Error	C2039	'glad_glVertexAttribPointer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	878	
Error	C2039	'glad_glEnableVertexAttribArray': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	879	
Error	C2039	'glad_glVertexAttribPointer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	885	
Error	C2039	'glad_glEnableVertexAttribArray': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	886	
Error	C2039	'glad_glDisableVertexAttribArray': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	894	
Error	C2039	'glad_glDisableVertexAttribArray': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	896	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	899	
Error	C2039	'glad_glBindBuffer': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	900	
Error	C2039	'glad_glDeleteBuffers': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	975	
Error	C2039	'glad_glDeleteBuffers': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	976	
Error	C2039	'glad_glGetAttribLocation': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	1019	
Error	C2039	'glad_glGetAttribLocation': is not a member of 'juce::OpenGLExtensionFunctions'	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Source\ScrollingNoteViewer.cpp	1024	
Error	C2039	'glad_glGetUniformLocation': is not a member of 'juce::OpenGLExtensionFunctions' (compiling source file ..\..\Source\ViewerFrame.cpp)	ConcertKeyboardist_App	c:\users\chrisgr\ck\source\ScrollingNoteViewer.h	274

#2

What’s the “glad_” prefix? Haven’t seen that before, I don’t think it’s anything to do with juce…?


#3

Glad is described in this tutorial. OpenGL Tutorial. It’s a popular GL library and “Multi-Language GL/GLES/EGL/GLX/WGL Loader-Generator”. See this site for the Loader-Generator. The tutorial quickly got me to the stage of building their GL example code in Visual Studio. However I’m not able to build with JUCE.

I have made some progress on this problem since posting this request by doing the following for each of my uses of openGLContext.extensions:

#if defined(__APPLE__)
    openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, vertexBuffer);
#else
    glad_glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
#endif

Could this possibly work? The code checker is happy with it but I’m still getting these unresolved errors from the linker:

	Error	LNK2001	unresolved external symbol glad_glDeleteBuffers	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glEnable	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glBlendFunc	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glViewport	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glBindBuffer	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glGenBuffers	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glBufferData	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glBufferSubData	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glDisableVertexAttribArray	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glEnableVertexAttribArray	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glGetAttribLocation	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glGetUniformLocation	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glUniformMatrix4fv	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK2001	unresolved external symbol glad_glVertexAttribPointer	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\ScrollingNoteViewer.obj	1	
	Error	LNK1120	14 unresolved externals	ConcertKeyboardist_App	C:\Users\chrisgr\CK\Builds\VisualStudio2017\x64\Debug\App\ConcertKeyboardist.exe	1	

My VS Project settings are are follows:

VC++ Directories:

Include Directories     C:\Users\chrisgr\OpenGL Stuff\Include;$(IncludePath)
Library Directories     $(LibraryPath);C:\Users\chrisgr\OpenGL Stuff\Libraries

Linker “Input”

Additional Dependencies    opengl32.lib;glfw3.lib;%(AdditionalDependencies)

The “OpenGL Stuff” directory is:

OpenGLStuff
   Libraries
     glfw3.lib
   Include
     glad
        glad.h
     GLFW
        glfw3.h
        glfw3native.h
     KHR
        khrplatform.h

These were generated as described in the tutorial and work correctly for the tutorial examples but not for JUCE.

Note that I added these settings to the Projucer project VS 2017 exporter:

Visual Studio 2017 - External Libraries to Link    
    opengl32.lib
    glfw3.lib
Visual Studio 2017 - Debug - Header Search Paths
    C:\Users\chrisgr\OpenGL Stuff\Include
Visual Studio 2017 - Debug - External Library Search Paths
    C:\Users\chrisgr\OpenGL Stuff\Libraries 

When I generate a VS Project from this it does not add the library to the VS Project “VC++ Directories - Include Directories” field in properties so I have to add “C:\Users\chrisgr\OpenGL Stuff\Libraries” to the VS project manually. My entry in Projucer’s “Header Search Paths” seems to be ignored. Is there a way to have Projucer set this field?

That about where I am now. I’d appreciate any tips on how to get my GL based project to build on Windows. As I said it works perfectly on Mac.