diff --git a/main.c b/main.c index 85b2ca7..90b1e28 100644 --- a/main.c +++ b/main.c @@ -15,8 +15,7 @@ shaders/sierp.fs shaders/joliesformes.fs shaders/orthogonalView.fs */ -#define SCENE "shaders/orthogonalView.fs" -//#define SCENE "shaders/immeublesparisiens.fs" +#define SCENE "shaders/default.fs" #define FULLSCREEN 0 #define EXPERIMENTAL_FEATURES 0 /* ## DEBUG MODE ## @@ -25,10 +24,11 @@ shaders/orthogonalView.fs * 2 for FPS * 3 for cursor position * 5 for scroll level and precision + * 7 for orthogonal information * * For instance if you want fps and position set the value to 2*3=6 */ -#define DEBUG_MODE 1 +#define DEBUG_MODE 7 GLuint screenWidth = 720, screenHeight = 480; const GLFWvidmode* mode; @@ -61,6 +61,7 @@ bool leftar = false; bool rightar = false; bool forwardar = false; bool backwardar = false; +int orthoView = 0; float fovValue=1.0; //281=3.13/2 * 180 @@ -108,6 +109,14 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); } } + if (key == GLFW_KEY_TAB) { + orthoView = (orthoView + 1) % 2; + if (DEBUG_MODE % 7 == 0) { + printf("Orthogonal view : "); + printf((orthoView == 1) ? "on" : "off"); + printf("\n"); + } + } if (key == GLFW_KEY_BACKSPACE) glfwSetWindowShouldClose(window, GLFW_TRUE); if (key == GLFW_KEY_SPACE) @@ -331,7 +340,8 @@ int main (){ glUniform3f(glGetUniformLocation(quad_shader, "iEy"), ey[0],ey[1],ey[2]); glUniform3f(glGetUniformLocation(quad_shader, "iEz"), ez[0],ez[1],ez[2]); glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ); - glUniform1f(glGetUniformLocation(quad_shader, "iFovValue"), fovValue*fovValue*multiplicatorFov); + glUniform1f(glGetUniformLocation(quad_shader, "iFovValue"), (orthoView == 1) ? 2/(fovValue*fovValue*multiplicatorFov) : fovValue*fovValue*multiplicatorFov); + glUniform1i(glGetUniformLocation(quad_shader, "iOrthoView"), orthoView); // glBindVertexArray(0); // no need to unbind it every time } diff --git a/shaders/default.fs b/shaders/default.fs index b12722d..f25070d 100644 --- a/shaders/default.fs +++ b/shaders/default.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -215,7 +216,7 @@ void main(){ vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez); - if(sin(Time)<0.){ + if(OrthoView == 1.){ //float c=Mandel(FragCoord*1.5); FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); }else{ diff --git a/shaders/generic.vs b/shaders/generic.vs index d92dcfc..c039f9d 100644 --- a/shaders/generic.vs +++ b/shaders/generic.vs @@ -11,6 +11,7 @@ out vec3 Ez; out vec3 CamPos; out float fovValue; out float FacteurLargeur; +out float OrthoView; uniform float iTime; uniform vec3 iEx; @@ -19,6 +20,7 @@ uniform vec3 iEz; uniform vec3 iCamPos; uniform float iFovValue; uniform float iFacteurLargeur; +uniform int iOrthoView; void main() @@ -32,4 +34,5 @@ void main() CamPos = iCamPos; fovValue = iFovValue; FacteurLargeur=iFacteurLargeur; + OrthoView = iOrthoView; } diff --git a/shaders/immeublesparisiens.fs b/shaders/immeublesparisiens.fs index 6682a27..96c1eac 100644 --- a/shaders/immeublesparisiens.fs +++ b/shaders/immeublesparisiens.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -134,6 +135,10 @@ void main(){ vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez); + if(OrthoView == 1.){ //float c=Mandel(FragCoord*1.5); - FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); + }else{ + FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + } } diff --git a/shaders/joliesformes.fs b/shaders/joliesformes.fs index 9338f31..c631662 100644 --- a/shaders/joliesformes.fs +++ b/shaders/joliesformes.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -170,6 +171,10 @@ void main(){ vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez); + if(OrthoView == 1.){ //float c=Mandel(FragCoord*1.5); - FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); + }else{ + FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + } } diff --git a/shaders/menger.fs b/shaders/menger.fs index 866a3bf..916f038 100644 --- a/shaders/menger.fs +++ b/shaders/menger.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -152,5 +153,10 @@ void main(){ //float c=Mandel(FragCoord*1.5); - FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + if(OrthoView == 1.){ + //float c=Mandel(FragCoord*1.5); + FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); + }else{ + FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + } } diff --git a/shaders/orthogonalView.fs b/shaders/orthogonalView.fs index b12722d..f25070d 100644 --- a/shaders/orthogonalView.fs +++ b/shaders/orthogonalView.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -215,7 +216,7 @@ void main(){ vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez); - if(sin(Time)<0.){ + if(OrthoView == 1.){ //float c=Mandel(FragCoord*1.5); FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); }else{ diff --git a/shaders/quad.fs b/shaders/quad.fs index 0501b90..d27321d 100644 --- a/shaders/quad.fs +++ b/shaders/quad.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -120,5 +121,10 @@ void main(){ //float c=Mandel(FragCoord*1.5); - FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + if(OrthoView == 1.){ + //float c=Mandel(FragCoord*1.5); + FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); + }else{ + FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + } } diff --git a/shaders/sierp.fs b/shaders/sierp.fs index cd304cc..fbe113d 100644 --- a/shaders/sierp.fs +++ b/shaders/sierp.fs @@ -8,6 +8,7 @@ in vec3 Ez; in vec3 CamPos; in float fovValue; in float FacteurLargeur; +in float OrthoView; out vec4 FragColor; //uniform sampler2D generalTexture; @@ -217,5 +218,10 @@ void main(){ //float c=Mandel(FragCoord*1.5); - FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + if(OrthoView == 1.){ + //float c=Mandel(FragCoord*1.5); + FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.); + }else{ + FragColor=vec4(Get_Color(posCam,dir),1.);//c,c,c,1.); + } }