#include <iostream>
//#include <GL/glew.h>
#include <GLFW/glfw3.h>
using namespace std;
GLFWwindow* window = glfwCreateWindow(640, 480, "Minecraft", NULL, NULL);
class Camera
{
double mouseposx = 0, mouseposy = 0;
double xzdir = 0, ydir = 0, x, y, z;
int sizex = 0, sizey = 0;
public:
void Cam(void)
{
glfwGetWindowSize(window, &sizex, &sizey);
glfwGetCursorPos(window, &mouseposx, &mouseposy);
glfwSetCursorPos(window, sizex/2, sizey/2);
cout << mouseposx << " " << mouseposy << endl;
};
};
int main(void)
{
Camera player;
if(!glfwInit())
{
glfwTerminate();
cout << "Failed to launch" << endl;
return -1;
}
GLFWwindow* window = glfwCreateWindow(640, 480, "Minecraft", NULL, NULL);
if(!window)
glfwTerminate();
glfwMakeContextCurrent(window);
while(!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT);
player.Cam();
glfwSwapBuffers(window);
glfwWaitEvents();// if this line is missing it crash
}
glfwTerminate();
}
So I was messing around with the functions, and I had some ideas to make a game, because I found gluLookAt, so first I did something basic that detect any movement of mouse, so I wanted to test how does work my mouse, but it crashed, and crashed again…