Compare commits
No commits in common. "a04cf1236dc60f5a9c9bd1e288a45db823784345" and "833d7b6e7ba4234e7751aaa58ac325378ff04bee" have entirely different histories.
a04cf1236d
...
833d7b6e7b
3 changed files with 10 additions and 34 deletions
34
main.c
34
main.c
|
|
@ -8,17 +8,15 @@
|
||||||
#include "./Libraries/stb/stb_image.h"
|
#include "./Libraries/stb/stb_image.h"
|
||||||
#include "headers/shader.h"
|
#include "headers/shader.h"
|
||||||
#define FULLSCREEN 0
|
#define FULLSCREEN 0
|
||||||
#define EXPERIMENTAL_FEATURES 0
|
|
||||||
/* ## DEBUG MODE ##
|
/* ## DEBUG MODE ##
|
||||||
* 0 for all
|
* 0 for all
|
||||||
* 1 for nothing
|
* 1 for nothing
|
||||||
* 2 for FPS
|
* 2 for FPS
|
||||||
* 3 for cursor position
|
* 3 for cursor position
|
||||||
* 5 for scroll level and precision
|
|
||||||
*
|
*
|
||||||
* 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 5
|
#define DEBUG_MODE 3
|
||||||
|
|
||||||
GLuint screenWidth = 720, screenHeight = 480;
|
GLuint screenWidth = 720, screenHeight = 480;
|
||||||
const GLFWvidmode* mode;
|
const GLFWvidmode* mode;
|
||||||
|
|
@ -31,12 +29,11 @@ void setupVAO();
|
||||||
unsigned int VAO;
|
unsigned int VAO;
|
||||||
|
|
||||||
float currentTime, deltaTime, lastFrame,startTime;
|
float currentTime, deltaTime, lastFrame,startTime;
|
||||||
float mousePosX,mousePosY,camPosX,camPosY,camPosZ;
|
float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ;
|
||||||
float fovValue=1.0;
|
|
||||||
//283=3.14/2 * 180
|
//283=3.14/2 * 180
|
||||||
const int maxYmouse = 283;
|
const int maxYmouse = 283;
|
||||||
// more precision means less speed
|
// more precision means less speed
|
||||||
float camPrecision = 2.;
|
const int camPrecision = 2;
|
||||||
|
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
|
|
@ -62,27 +59,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
|
||||||
{
|
|
||||||
int stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
|
|
||||||
|
|
||||||
// we only use yoffset as it is present on normal mice
|
|
||||||
if (DEBUG_MODE % 5 == 0)
|
|
||||||
printf("scroll value : %f | precision : %f | ",yoffset, camPrecision);
|
|
||||||
printf((stateControl == GLFW_PRESS) ? "ctrl -> speed" : "Zooming");
|
|
||||||
printf("\n");
|
|
||||||
if (stateControl == GLFW_PRESS) {
|
|
||||||
camPrecision += yoffset/2;
|
|
||||||
if (camPrecision <= 1)
|
|
||||||
camPrecision=1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fovValue += yoffset/5;
|
|
||||||
if (fovValue <= 0.2 && EXPERIMENTAL_FEATURES == 0)
|
|
||||||
fovValue=0.2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
|
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
|
|
@ -160,7 +136,6 @@ int main (){
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
glfwSetScrollCallback(window, scroll_callback);
|
|
||||||
|
|
||||||
GLFWimage images[1];
|
GLFWimage images[1];
|
||||||
images[0].pixels = stbi_load("./assets/icon.png", &images[0].width, &images[0].height, 0, 4); //rgba channels
|
images[0].pixels = stbi_load("./assets/icon.png", &images[0].width, &images[0].height, 0, 4); //rgba channels
|
||||||
|
|
@ -202,7 +177,8 @@ int main (){
|
||||||
glUniform1f(glGetUniformLocation(quad_shader, "iTime"), currentTime-startTime);
|
glUniform1f(glGetUniformLocation(quad_shader, "iTime"), currentTime-startTime);
|
||||||
glUniform2f(glGetUniformLocation(quad_shader, "iMousePos"), mousePosX,mousePosY);
|
glUniform2f(glGetUniformLocation(quad_shader, "iMousePos"), mousePosX,mousePosY);
|
||||||
glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ);
|
glUniform3f(glGetUniformLocation(quad_shader, "iCamPos"), camPosX,camPosY,camPosZ);
|
||||||
glUniform1f(glGetUniformLocation(quad_shader, "iFovValue"), fovValue);
|
glUniform3f(glGetUniformLocation(quad_shader, "iCamDir"), camDirX,camDirY,camDirZ);
|
||||||
|
|
||||||
// glBindVertexArray(0); // no need to unbind it every time
|
// glBindVertexArray(0); // no need to unbind it every time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ out vec2 FragCoord;
|
||||||
out float Time;
|
out float Time;
|
||||||
out vec2 MousePos;
|
out vec2 MousePos;
|
||||||
out vec3 CamPos;
|
out vec3 CamPos;
|
||||||
out float fovValue;
|
out vec3 CamDir;
|
||||||
|
|
||||||
uniform float iTime;
|
uniform float iTime;
|
||||||
uniform vec2 iMousePos;
|
uniform vec2 iMousePos;
|
||||||
uniform vec3 iCamPos;
|
uniform vec3 iCamPos;
|
||||||
uniform float iFovValue;
|
uniform vec3 iCamDir;
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
@ -22,5 +22,5 @@ void main()
|
||||||
Time=iTime;
|
Time=iTime;
|
||||||
MousePos = iMousePos;
|
MousePos = iMousePos;
|
||||||
CamPos = iCamPos;
|
CamPos = iCamPos;
|
||||||
fovValue = iFovValue;
|
CamDir = iCamDir;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ in vec2 FragCoord;
|
||||||
in float Time;
|
in float Time;
|
||||||
in vec2 MousePos;
|
in vec2 MousePos;
|
||||||
in vec3 CamPos;
|
in vec3 CamPos;
|
||||||
in float fovValue;
|
in vec3 CamDir;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
//uniform sampler2D generalTexture;
|
//uniform sampler2D generalTexture;
|
||||||
|
|
@ -97,7 +97,7 @@ void main(){
|
||||||
vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
||||||
vec3 ey = cross(ex,ez);
|
vec3 ey = cross(ex,ez);
|
||||||
|
|
||||||
vec3 dir = normalize(FragCoord.x * ex + FragCoord.y*ey + fovValue*ez);
|
vec3 dir = normalize(FragCoord.x * ex + FragCoord.y*ey + 1.5*ez);
|
||||||
|
|
||||||
|
|
||||||
//float c=Mandel(FragCoord*1.5);
|
//float c=Mandel(FragCoord*1.5);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue