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/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
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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.);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue