adding orthogonal view control
This commit is contained in:
parent
0b1e5da2c4
commit
e17b0a95c0
9 changed files with 54 additions and 11 deletions
18
main.c
18
main.c
|
@ -15,8 +15,7 @@ shaders/sierp.fs
|
||||||
shaders/joliesformes.fs
|
shaders/joliesformes.fs
|
||||||
shaders/orthogonalView.fs
|
shaders/orthogonalView.fs
|
||||||
*/
|
*/
|
||||||
#define SCENE "shaders/orthogonalView.fs"
|
#define SCENE "shaders/default.fs"
|
||||||
//#define SCENE "shaders/immeublesparisiens.fs"
|
|
||||||
#define FULLSCREEN 0
|
#define FULLSCREEN 0
|
||||||
#define EXPERIMENTAL_FEATURES 0
|
#define EXPERIMENTAL_FEATURES 0
|
||||||
/* ## DEBUG MODE ##
|
/* ## DEBUG MODE ##
|
||||||
|
@ -25,10 +24,11 @@ shaders/orthogonalView.fs
|
||||||
* 2 for FPS
|
* 2 for FPS
|
||||||
* 3 for cursor position
|
* 3 for cursor position
|
||||||
* 5 for scroll level and precision
|
* 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
|
* 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;
|
GLuint screenWidth = 720, screenHeight = 480;
|
||||||
const GLFWvidmode* mode;
|
const GLFWvidmode* mode;
|
||||||
|
@ -61,6 +61,7 @@ bool leftar = false;
|
||||||
bool rightar = false;
|
bool rightar = false;
|
||||||
bool forwardar = false;
|
bool forwardar = false;
|
||||||
bool backwardar = false;
|
bool backwardar = false;
|
||||||
|
int orthoView = 0;
|
||||||
|
|
||||||
float fovValue=1.0;
|
float fovValue=1.0;
|
||||||
//281=3.13/2 * 180
|
//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);
|
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)
|
if (key == GLFW_KEY_BACKSPACE)
|
||||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
if (key == GLFW_KEY_SPACE)
|
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, "iEy"), ey[0],ey[1],ey[2]);
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iEz"), ez[0],ez[1],ez[2]);
|
glUniform3f(glGetUniformLocation(quad_shader, "iEz"), ez[0],ez[1],ez[2]);
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ);
|
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
|
// glBindVertexArray(0); // no need to unbind it every time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -215,7 +216,7 @@ void main(){
|
||||||
|
|
||||||
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
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);
|
//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.);
|
FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.);
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -11,6 +11,7 @@ out vec3 Ez;
|
||||||
out vec3 CamPos;
|
out vec3 CamPos;
|
||||||
out float fovValue;
|
out float fovValue;
|
||||||
out float FacteurLargeur;
|
out float FacteurLargeur;
|
||||||
|
out float OrthoView;
|
||||||
|
|
||||||
uniform float iTime;
|
uniform float iTime;
|
||||||
uniform vec3 iEx;
|
uniform vec3 iEx;
|
||||||
|
@ -19,6 +20,7 @@ uniform vec3 iEz;
|
||||||
uniform vec3 iCamPos;
|
uniform vec3 iCamPos;
|
||||||
uniform float iFovValue;
|
uniform float iFovValue;
|
||||||
uniform float iFacteurLargeur;
|
uniform float iFacteurLargeur;
|
||||||
|
uniform int iOrthoView;
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -32,4 +34,5 @@ void main()
|
||||||
CamPos = iCamPos;
|
CamPos = iCamPos;
|
||||||
fovValue = iFovValue;
|
fovValue = iFovValue;
|
||||||
FacteurLargeur=iFacteurLargeur;
|
FacteurLargeur=iFacteurLargeur;
|
||||||
|
OrthoView = iOrthoView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -134,6 +135,10 @@ void main(){
|
||||||
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
||||||
|
|
||||||
|
|
||||||
|
if(OrthoView == 1.){
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//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.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -170,6 +171,10 @@ void main(){
|
||||||
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
||||||
|
|
||||||
|
|
||||||
|
if(OrthoView == 1.){
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//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.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -152,5 +153,10 @@ void main(){
|
||||||
|
|
||||||
|
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//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.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -215,7 +216,7 @@ void main(){
|
||||||
|
|
||||||
vec3 dir = normalize(FragCoord.x * normalize(Ex) + FragCoord.y * normalize(Ey) + fovValue * Ez);
|
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);
|
//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.);
|
FragColor=vec4(Get_Color(posCam+fovValue*FragCoord.x*normalize(Ex)+fovValue*FragCoord.y*normalize(Ey),normalize(Ez)),1.);//c,c,c,1.);
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -120,5 +121,10 @@ void main(){
|
||||||
|
|
||||||
|
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//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.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ in vec3 Ez;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in float fovValue;
|
||||||
in float FacteurLargeur;
|
in float FacteurLargeur;
|
||||||
|
in float OrthoView;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
@ -217,5 +218,10 @@ void main(){
|
||||||
|
|
||||||
|
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//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.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue