mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-18 04:53:06 +01:00
Added GL 3.1 core profile shader patching.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
// OpenGL 2.1 Reference Pages
|
||||
// http://www.opengl.org/sdk/docs/man/
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_PLATFORM_WINDOWS || BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
GL_IMPORT____(false, PFNGLGETERRORPROC, glGetError);
|
||||
GL_IMPORT____(false, PFNGLREADPIXELSPROC, glReadPixels);
|
||||
GL_IMPORT____(false, PFNGLTEXIMAGE2DPROC, glTexImage2D);
|
||||
@@ -100,6 +100,7 @@ GL_IMPORT____(false, PFNGLGENRENDERBUFFERSPROC, glGenRenderbuff
|
||||
GL_IMPORT____(false, PFNGLDELETERENDERBUFFERSPROC, glDeleteRenderbuffers);
|
||||
GL_IMPORT____(false, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
|
||||
GL_IMPORT____(false, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
|
||||
GL_IMPORT____(false, PFNGLBINDFRAGDATALOCATIONPROC, glBindFragDataLocation);
|
||||
#else
|
||||
GL_IMPORT_EXT(false, PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebuffer);
|
||||
GL_IMPORT_EXT(false, PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffers);
|
||||
|
||||
@@ -1109,6 +1109,10 @@ namespace bgfx
|
||||
GLint activeAttribs;
|
||||
GLint activeUniforms;
|
||||
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
GL_CHECK(glBindFragDataLocation(m_id, 0, "bgfx_FragColor") );
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTES, &activeAttribs) );
|
||||
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniforms) );
|
||||
|
||||
@@ -1910,6 +1914,31 @@ namespace bgfx
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
size_t codeLen = strlen(code);
|
||||
size_t tempLen = codeLen + 1024;
|
||||
char* temp = (char*)alloca(tempLen);
|
||||
bx::StaticMemoryBlockWriter writer(temp, tempLen);
|
||||
|
||||
writeString(&writer, "#version 140\n");
|
||||
if (_type == GL_FRAGMENT_SHADER)
|
||||
{
|
||||
writeString(&writer, "#define varying in\n");
|
||||
writeString(&writer, "#define texture2D texture\n");
|
||||
writeString(&writer, "#define texture3D texture\n");
|
||||
writeString(&writer, "#define textureCube texture\n");
|
||||
writeString(&writer, "out vec4 bgfx_FragColor;\n");
|
||||
writeString(&writer, "#define gl_FragColor bgfx_FragColor\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
writeString(&writer, "#define attribute in\n");
|
||||
writeString(&writer, "#define varying out\n");
|
||||
}
|
||||
|
||||
bx::write(&writer, code, codeLen);
|
||||
bx::write(&writer, '\0');
|
||||
code = temp;
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGLES2
|
||||
|
||||
GL_CHECK(glShaderSource(m_id, 1, (const GLchar**)&code, NULL) );
|
||||
|
||||
Reference in New Issue
Block a user