Skip to content

Commit

Permalink
Shader changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphalaneous committed Jul 25, 2024
1 parent ec5f5eb commit 6aaa219
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 7 additions & 1 deletion assets/shaders/cubemap/cubemap_frag.glsl
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#version 300 es

precision highp float;

uniform vec2 center;
uniform vec2 resolution;
uniform float time;
uniform vec2 mouse;

uniform samplerCube skybox;

out vec4 FragColor;

void main(){

float rotX = (time / resolution.x) * -20.0 * 3.14;
Expand All @@ -22,6 +28,6 @@ void main(){

vec3 dir = normalize(-uv.x * camR + uv.y * camU + camD);

gl_FragColor = texture(skybox, dir);
FragColor = texture(skybox, dir);

}
4 changes: 3 additions & 1 deletion assets/shaders/cubemap/cubemap_vert.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
attribute vec4 aPosition;
#version 300 es

in vec4 aPosition;

void main() {
gl_Position = aPosition;
Expand Down
22 changes: 7 additions & 15 deletions src/utils/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ void Shader::setup(std::string vertexSource, std::string fragmentSource){

vertex = glCreateShader(GL_VERTEX_SHADER);
const char* vertexSources[] = {
#ifdef GEODE_IS_WINDOWS
"#version 130\n",
#endif
#ifdef GEODE_IS_MOBILE
"precision highp float;\n",
#endif
vertexSource.c_str()
};

Expand All @@ -33,6 +27,9 @@ void Shader::setup(std::string vertexSource, std::string fragmentSource){
auto vertexLog = string::trim(getShaderLog(vertex));

glGetShaderiv(vertex, GL_COMPILE_STATUS, &res);

log::info("vertex log: {}", vertexLog);

if(!res) {
glDeleteShader(vertex);
vertex = 0;
Expand All @@ -41,12 +38,6 @@ void Shader::setup(std::string vertexSource, std::string fragmentSource){

fragment = glCreateShader(GL_FRAGMENT_SHADER);
const char* fragmentSources[] = {
#ifdef GEODE_IS_WINDOWS
"#version 130\n",
#endif
#ifdef GEODE_IS_MOBILE
"precision highp float;\n",
#endif
fragmentSource.c_str()
};

Expand All @@ -56,6 +47,9 @@ void Shader::setup(std::string vertexSource, std::string fragmentSource){
auto fragmentLog = string::trim(getShaderLog(fragment));

glGetShaderiv(fragment, GL_COMPILE_STATUS, &res);

log::info("fragment log: {}", fragmentLog);

if(!res) {
glDeleteShader(vertex);
glDeleteShader(fragment);
Expand All @@ -74,10 +68,8 @@ void Shader::setup(std::string vertexSource, std::string fragmentSource){
vertex = 0;
fragment = 0;

log::info("vertex log: {}", vertexLog);
log::info("fragment log: {}", fragmentLog);

glGetProgramiv(program, GL_LINK_STATUS, &res);

if(!res) {
glDeleteProgram(program);
program = 0;
Expand Down

0 comments on commit 6aaa219

Please sign in to comment.