adding some user control

This commit is contained in:
MagicTINTIN 2023-02-14 23:11:43 +01:00
parent b3bd9857a4
commit 9f17ec9b56
4 changed files with 17 additions and 7 deletions

View file

@ -50,4 +50,9 @@ Essayez d'adapter les méthodes montrées ci-dessus, aucune garantie que cela fo
### V0.2.2
![Capture d'écran de la toute première version](./screenshots/v0.2.2.png)<br>
Capture d'écran de la toute première version d'EnginPasTangible (v0.2.2)
Capture d'écran de la toute première version d'EnginPasTangible (v0.2.2)
### V0.2.5
![Capture d'écran de la toute première version](./screenshots/EnginPasTangiblev0.2.5.gif)<br>
Rotation autour du centre contrôlée par la souris (v0.2.5)

14
main.c
View file

@ -1,4 +1,4 @@
#define APPNAMEVERSION "EnginPasTangible (alpha 0.2.4)"
#define APPNAMEVERSION "EnginPasTangible (alpha 0.2.5)"
#include "./Libraries/glad/glad.h"
#include <stdio.h>
#include <math.h>
@ -29,10 +29,13 @@ void setupVAO();
unsigned int VAO;
float currentTime, deltaTime, lastFrame,startTime;
float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ;
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
if (!action == GLFW_PRESS)
return;
if (key == GLFW_KEY_ESCAPE)
{
//glfwSetWindowShouldClose(window, GLFW_TRUE);
pause=!pause;
@ -48,13 +51,15 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
}
/*if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
glfwSetCursorPos(window, 640/2, 480/2);*/
if (key == GLFW_KEY_BACKSPACE)
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
{
mousePosX = xpos;
mousePosY = ypos;
if (DEBUG_MODE % 3 == 0)
printf("x:%f | y:%f\n",xpos, ypos);
}
@ -119,7 +124,6 @@ int main (){
stbi_image_free(images[0].pixels);
int window_width, window_height;
float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ;
char FPS[20];
startTime = glfwGetTime();
while (!glfwWindowShouldClose(window))

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View file

@ -72,7 +72,8 @@ float Mandel(vec2 co){
void main()
{
vec3 lookingAt = vec3(0.);
vec3 posCam = vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
//vec3 posCam = vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500))));
vec3 ez = normalize(lookingAt-posCam);////base orthonormée
vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));