File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
src/atta/graphics/apis/openGL Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,21 @@ Shader::~Shader() {
2626}
2727
2828std::string Shader::generateApiCode (ShaderType type, std::string iCode) {
29- std::string apiCode = " #version 300 es\n "
30- " precision mediump float;\n " +
31- iCode;
29+ uint32_t openGLVersion = gfx::getGraphicsAPI ()->getAPIVersion ();
30+ std::string apiCode;
31+
32+ if (openGLVersion >= 410 ) {
33+ // macOS (OpenGL Core 4.1)
34+ apiCode = " #version 410 core\n " ;
35+ } else if (openGLVersion >= 300 && openGLVersion < 400 ) {
36+ // OpenGL ES (Linux, Android, Web)
37+ apiCode = " #version 300 es\n "
38+ " precision mediump float;\n " ;
39+ } else {
40+ // Default fallback (use OpenGL 3.0 if nothing else works)
41+ apiCode = " #version 300 core\n " ;
42+ }
43+ apiCode += iCode;
3244
3345 // Replace perFrame/perDraw
3446 apiCode = std::regex_replace (apiCode, std::regex (R"( \b(perFrame|perDraw))" ), " uniform" );
You can’t perform that action at this time.
0 commit comments