We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3141 - OpenGL: unresolved glActiveTexture()
Summary: OpenGL: unresolved glActiveTexture()
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.1
Hardware: x86_64 Windows 7
: P2 critical
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-08 15:06 UTC by igor
Modified: 2016-10-11 01:49 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description igor 2015-10-08 15:06:52 UTC
glActiveTexture() is not present in Windows version of opengl32.dll

In 2.0.3 it was possible to declare and define it using:

extern PFNGLACTIVETEXTUREARBPROC         glActiveTexture;
PFNGLACTIVETEXTUREARBPROC         glActiveTexture            = NULL;
glActiveTexture	           = (PFNGLACTIVETEXTUREARBPROC)         glGetProcAddressARB("glActiveTextureARB");

by using external glext.h rev:
Khronos $Revision: 28986 $ on $Date: 2014-11-18 18:43:15 -0800 (Tue, 18 Nov 2014) $

and in code:
#define NO_SDL_GLEXT
#include <SDL_opengl.h>
#include "glext.h"

Using internal glext caused linker error with glShaderSource()

in current 2.0.4 version (08 Oct 2015) it doesn't work with neither built-in or external glext.h

It causes unresolved symbol when you not declare/define glActiveTexture() manually (because Windows lacks definition), or causes redefinition when you define/declare it by getting processAddress.

Removing

GLAPI void GLAPIENTRY glActiveTexture( GLenum texture );

line from SDL2_opengl.h fixes issue under Windows, I can use both internal and external glext.h, manual definition works fine, but I have no idea how it will influence other platforms.

After looking into code a little looks like some defines have changes inside SDL_opengl.h which introduced this issue (but fixed issue with internal glext and glShaderSource)
You can test issue on next code https://github.com/igorko/flare-engine/tree/openGL
Comment 1 Sam Lantinga 2016-10-01 21:02:35 UTC
Ryan, can you look at this for 2.0.5?
Comment 2 Ryan C. Gordon 2016-10-02 00:00:35 UTC
(In reply to Sam Lantinga from comment #1)
> Ryan, can you look at this for 2.0.5?

yep!

--ryan.
Comment 3 igor 2016-10-04 20:33:11 UTC
Code, on which you can test issue has been moved here https://github.com/dorkster/flare-engine-next
Comment 4 Ryan C. Gordon 2016-10-11 01:49:15 UTC
Rereading this bug report, this isn't actually an SDL bug. You're redefining an OpenGL symbol as something else.

glActiveTexture is meant to be a function (even if it happens to not be listed in opengl32.dll), but your program is redefining it to be a function pointer, so this upsets the compiler since it saw a our previous definition.

If you want to load a function pointer from OpenGL with SDL_GL_GetProcAddress (or wgl or glX directly), you should pick a different name:

PFNGLACTIVETEXTUREARBPROC pglActiveTextureARB;  // note the 'p'.

Failing to do this will absolutely cause you problems on other platforms--if not on Windows too--when the dynamic loader ends up with a variable from your app where it thought it was getting a function in a DLL or vice versa.

--ryan.