mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-02-17 20:31:57 -05:00
Added GL 3.1 core profile shader patching.
This commit is contained in:
parent
0f3d6037a6
commit
7e656fa4ef
68 changed files with 34 additions and 6 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,4 @@
|
|||
FSHƒòá#version 120
|
||||
|
||||
uniform vec3 u_lightDir;
|
||||
FSHƒòáuniform vec3 u_lightDir;
|
||||
uniform mat4 u_mtx;
|
||||
varying vec2 v_texcoord0;
|
||||
varying vec4 v_color0;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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) );
|
||||
|
|
|
@ -530,7 +530,7 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, const std::string& _code, bx::
|
|||
}
|
||||
else
|
||||
{
|
||||
writef(_writer, "#version %s\n\n", profile);
|
||||
// writef(_writer, "#version %s\n\n", profile);
|
||||
}
|
||||
|
||||
bx::write(_writer, optimizedShader, (int32_t)strlen(optimizedShader) );
|
||||
|
@ -1833,7 +1833,7 @@ int main(int _argc, const char* _argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
writef(&writer, "#version %s\n\n", profile);
|
||||
// writef(&writer, "#version %s\n\n", profile);
|
||||
}
|
||||
}
|
||||
writer.write(preprocessor.m_preprocessed.c_str(), (int32_t)preprocessor.m_preprocessed.size() );
|
||||
|
|
Loading…
Reference in a new issue