Setting Linking GLSL up for Visual Studio 2013 using MFC C++

First, I’m trying to create shaders for the very first time! :slight_smile:

I’m trying to make a shader but the functions from OpenGL are not present? vc2013, so I can not seem to load create attach shader. ( Opengl is working fine right now in the project)

Right now it give me error’s on functions to do a shader:

3>------ Build started: Project: GL_View, Configuration: Debug x64 ------
3>  GLShader.cpp
3>GLShader.cpp(40): error C3861: 'glCreateProgram': identifier not found
3>GLShader.cpp(41): error C3861: 'glAttachShader': identifier not found
3>GLShader.cpp(42): error C3861: 'glAttachShader': identifier not found
3>GLShader.cpp(43): error C3861: 'glLinkProgram': identifier not found
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

So I used DependencyWalker to look at the opengl Lib my apps are linked to.


( SO it appears this library doesn’t have it??)


Now possible update, but after searching via web, it seems that I have to first check my hardware to see if I can even use a shader.

I have a NVidia GeForce GTX 760 card ( NVidia’s control panel says Driver Version 432.0)

And it seems that you need to download the glewinfo.exe and visualinfo.exe to do a check as well.

-------------------------------Running glewinfo.exe -----------------------------------

and at the top it says:

---------------------------
    GLEW Extension Info
---------------------------

GLEW version 2.2.0
Reporting capabilities of pixelformat 1
Running on a GeForce GTX 760/PCIe/SSE2 from NVIDIA Corporation
OpenGL version 4.6.0 NVIDIA 432.00 is supported

Then a ton a functions with OK or missing
It appears that GL_VERSION_4_6 is good up to here.

I did search this list and it doesn’t find: glCreateProgram and the others…???

----------------------------Running visualinfo.exe---------------

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 760/PCIe/SSE2
OpenGL version string: 4.6.0 NVIDIA 432.00
OpenGL extensions (GL_): 

Then a bunch of stuff I'm not sure I understand----
OpenGL extensions (GL_):  ( Bunch of functions here)

GLU version string: 1.2.2.0 Microsoft Corporation
GLU extensions (GLU_): 
    GL_EXT_bgra.
WGL extensions (WGL_): 

Then a huge chart


https://www.khronos.org/registry/OpenGL/index_gl.php

  • <GL/glext.h> - OpenGL 1.2 and above compatibility profile and extension interfaces.
  • <GL/glcorearb.h> - OpenGL core profile and ARB extension interfaces, as described in appendix G.2 of the OpenGL 4.3 Specification. Does not include interfaces found only in the compatibility profile.
  • <GL/glxext.h> - GLX 1.3 and above API and GLX extension interfaces.
  • <GL/wglext.h> - WGL extension interfaces.

also <KHR/khrplatform.h>


SO finally my questions:

  1. Since my system32 x64 has a bad Opengl can I replace that, and where for windows? What about the opengl headers/ lib ?

  2. It appears to get those functions I have to include the registry files above after gl.h… glext.h etc? I did but the export ordinal was not there do I need to modify the gl.h file to tell it the correct version of gl(
    /* Version */
    #define GL_VERSION_1_1 1
    )

NOTE: The *.dll of Opengl32.dll
( C:\WIndows\System32 doesn’t have those functions there in there.)

  1. I did find others opengl32.
    dll in C:\Windows\SysWOW64 but no functions
    C:\Windows\WinSys ( I assume these are from other apps I have installed?)

  2. I have the latest driver for my video card so how do I get the appropriate Opengl lib / dll /headers etc

To use OpenGL versions past 1.1 on Windows, you have to either manually load OpenGL functions and use a specialized header (or your own #defines) to provide enumerators, or you must use an OpenGL loading library. The latter is much preferred.

Well inorder to get the functions, remember my opengl library doesn’t have those 4 functions in it so I assume we need to update the opengl lib and dll in system32 so where do I get the windows version to do that? I can modify the that gl header but I cannot find the different windows Opengl dll versions … ( I assume I would use the 4.6 version because of my hardware being up to date?)

And that’s why you have to load those function pointers manually. Please read the link I gave you about loading function pointers. What you’re linking to provides the APIs you need to get those functions; they don’t provide them directly.

First- I have never had to to generate my own ordinals( I assume these) to generate function calls or load them from execution. I was able to look inside the dll and see that they were already there, I then used Afxloadlibrary and got the function.

If I understand what your saying, somehow the API has them but it will not allow me to view them when I crack open the dll with dependwalker. Those functions are just simply not there at all.

HOWEVER, your are saying I can use lua? or Opengl Library loader whatever and it knows how to get them SO this is VERY new to me.

I noticed there was a GetAnyGLfuncAddress so I tried to but it would not let me connect to the opengl32.dll even though it was there. And I believe it said do that before you initialize Opengl which it failed

I went to the Lua thing and did an automatic install, when I added the generated header it to my system it blew up ( see picture below ) I assume I can still use the glu.h?

This was my command line:
LoadGen.lua core_4_4 -style=pointer_c -spec=gl -version=4.4 -profile=core -stdext=gl_ubiquitous.txt -stdext=gl_plat_3_3.txt

Sooo ? hmmmm if I remove that header it generated, it is fine.

//#include “gl_core_4_4.h” ???
#include <GL/gl.h>
#include <GL/glu.h>
//#include <KHR/khrplatform.h>
#include <GL/glext.h>


if I do this:

#include “gl_core_4_4.h”
#include <GL/gl.h>
#include <GL/glu.h>
//#include <KHR/khrplatform.h>
#include <GL/glext.h>

then it doesn’t understand the picking elements defined in gl.h

image

I would say if there is a new lib and windows 10 version via *.lib and dll but if I understand you right those do not exist.

There’s a whole page that explains the process. I linked you to it. You should read it.

I don’t know what “it” is in “it would not let me”. Again, there’s a whole page on how to load OpenGL functions; it explains what you need to do.

Or just use a loading library.

LoadGen probably isn’t updated for OpenGL version 4.4; I haven’t worked on it in quite some time. So you should use probably use a loader that’s still under development, like GLAD or GLEW.

Also, whatever generator you use, you’re not supposed to also include gl.h. It’s one or the other, not both.

Lastly:

It isn’t supposed to. All of those functions and enums were deprecated in OpenGL 3.0 and removed from the core profile of OpenGL in 3.2. When you generated a core profile header, that meant that you intended to use the core profile of OpenGL. That means not having glInitNames and the like.

If you want to use compatibility features, you have to generate compatibility headers.

Does GetAnyGLfuncAddress work in it only gets one function at a time?

If I want wgl, gl, glext would Glew do all of those?

Wgl(windows context)
Gl ( normal functions call)
Glext(shader)

I’ve never encountered that function, so I’d assume that it’s for internal use. The public interface is wglGetProcAddress, which returns a pointer to a function given its name as a string. If you’re doing it yourself, you’d declare a pointer-to-function variable for each non-1.1 function you wish to use then initialise each variable with a call to wglGetProcAddress. But normally you use GLEW or GLAD to do this.

I’m thinking I don’t want to redo the picking as of yet, so I would need to start below 3.0
2.9 maybe? Glew would allow for wgl,gl,glext?

GLEW just does all of the wglGetProcAddress stuff for you. You just have to call glewInit after the window and context have been created but before calling any OpenGL >1.1 functions.

If you want to use the legacy picking functions, just ensure that you don’t create a 3.1+ core profile context. Use either <=3.0 or 3.1+ compatibility profile. This is handled by the toolkit (GLUT, GLFW). If you’re using the win32 API directly, wglCreateContext will never create a core profile context.

OK after downloading the glew 2.2 and following the directions the libs didn’t work… :slight_smile:

However I did find the issue:

SO for those of you using MFC and document view architecture
I actually needed to compile the glew lib ( download the source from Source forge not just the binarys) and make a dynamic version of the dll because the binary that was in there was not valid it was static lib and I created a dynamic one and it compiled and linked!

So if you are not seeing the functions either glew or glu or wgl or whatever download http://dependencywalker.com/
Drop ANY dll on it and it will let you see if the function is even being exported in Opengl32 ( which was not in my case which is why glew was needed )

and now all the shader stuff is present in the code ( at least ready to use and project compiled).

(https://www.badprog.com/c-opengl-setting-up-visual-studio)
SO IF you are using a lib and dll, link to the lib normally by adding a lib, and also drop the dll next to your exe’s or apps and it should work.

Now to figure out how to actually load an shader and see if it runs? hmmm

Thanks everyone…!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.