GLES2/src/glesw.c parse_version not always work

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
longer
Kobold
Posts: 25
Joined: Tue Aug 19, 2014 10:46 am

GLES2/src/glesw.c parse_version not always work

Post by longer » Wed Sep 27, 2017 1:30 pm

Code: Select all

    const char* pcVer = (const char*)glGetString(GL_VERSION);
    sscanf(pcVer, "OpenGL ES %u.%u", &version.major, &version.minor);
when i use PowerVR\GraphicsSDK\SDK_3.3 sdk and run GLES2 RenderSystem at win 10.

the pcVer value is "4.4.0 - Build 21.20.16.4541";can not success sscanf by "OpenGL ES" prefix.
I think the old version for glesw.c:

Code: Select all

	if (!glGetIntegerv)
		return -1;

	glGetIntegerv(GL_MAJOR_VERSION, &version.major);
	glGetIntegerv(GL_MINOR_VERSION, &version.minor);
is best clear api version.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 339
Joined: Sun Mar 30, 2014 2:51 pm
Contact:

Re: GLES2/src/glesw.c parse_version not always work

Post by paroj » Wed Sep 27, 2017 2:10 pm

the PowerVR SDK violates the spec:
https://www.khronos.org/registry/OpenGL ... String.xml

GL_MAJOR_VERSION is not available in GLES2.
0 x

longer
Kobold
Posts: 25
Joined: Tue Aug 19, 2014 10:46 am

Re: GLES2/src/glesw.c parse_version not always work

Post by longer » Fri Sep 29, 2017 4:09 am

It's my mistake.some reason i must maintain my own project build.
I use the RenderSystems\GLSupport\src\win32 for build the GLSupport static lib.and use it for win RenderSystems\GLES2.
because the api:

Code: Select all

    
    // RenderSystems\GLSupport\src\EGL\WIN32\OgreWin32EGLSupport.cpp
    // this is special for GLES2,can not work at GL and GL3+
    GLNativeSupport* getGLSupport(int profile)
    {
        return new Win32EGLSupport(profile);
    }
    // RenderSystems\GLSupport\src\win32\OgreWin32GLSupport.cpp
    // this is special for GL and GL3+.can not work at GLES2.
    GLNativeSupport* getGLSupport(int profile)
    {
        return new Win32GLSupport(profile);
    }
so the error version it's "4.4.0 - Build 21.20.16.4541".it's come from the error Win32GLSupport context.

the seccond error at:

Code: Select all

    void GLES2RenderSystem::initialiseContext(RenderWindow* primary)
    ......

#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
        // EAGL2Support redirects to glesw for get_proc. Overwriting it there would create an infinite loop.
        if (glGetError == NULL && gleswInit())
#elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		if (glGetError == NULL && gleswInit())
#else
        if (gleswInit2(get_proc))
#endif
        {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR,
                        "Could not initialize glesw",
                        "GLES2RenderSystem::initialiseContext");
        }
At windows the gleswInit2(get_proc) not work.it's might PowerVR\GraphicsSDK\SDK_3.3 sdk reason.
I think at windows use PowerVR,LoadLibraryA("libGLESv2.dll"); is need.

The third:
Components\RTShaderSystem\src\OgreShaderGLSLESProgramWriter.cpp(150)

Code: Select all

        void GLSLESProgramWriter::discoverFunctionDependencies(const FunctionInvocation &invoc, FunctionVector &depVector)
        {
            // Uses recursion to find any functions that the supplied function invocation depends on
            FunctionMap::const_iterator itCache = mFunctionCacheMap.begin();
            String body;

            // Find the function in the cache and retrieve the body
            for (; itCache != mFunctionCacheMap.end(); ++itCache)
            {
                if(!(invoc == (*itCache).first))
                    continue;

                body = (*itCache).second;
                break;
            }

            if(!body.empty())
            {
                // Trim whitespace
                StringUtil::trim(body);
                StringVector tokens = StringUtil::split(body, "(");

                for (StringVector::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
                {
                    StringVector moreTokens = StringUtil::split(*it, " \n");

                    if (!moreTokens.empty())
                    {
                    FunctionMap::const_iterator itFuncCache = mFunctionCacheMap.begin();

                        for (; itFuncCache != mFunctionCacheMap.end(); ++itFuncCache)
                        {

                            const FunctionInvocation& fi = itFuncCache->first;
                        
                            if(fi.getFunctionName() == moreTokens.back())
                            {
                                // Add the function declaration
                                depVector.push_back(FunctionInvocation((*itFuncCache).first));

                                discoverFunctionDependencies(itFuncCache->first, depVector);
                            }
                        }
                    }
                }
                
            }
            else
            {
                LogManager::getSingleton().logMessage("ERROR: Cached function not found " + invoc.getFunctionName());
            }
        }

Code: Select all

FunctionInvocation fi = itFuncCache->first;// original version.
const FunctionInvocation& fi = itFuncCache->first;// my version.
here will case copy at my MSVC performance analysis.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 339
Joined: Sun Mar 30, 2014 2:51 pm
Contact:

Re: GLES2/src/glesw.c parse_version not always work

Post by paroj » Fri Sep 29, 2017 11:47 pm

The third:
Components\RTShaderSystem\src\OgreShaderGLSLESProgramWriter.cpp(150)
nice catch!
0 x

Post Reply