Hi! I am developing a simple convex hull algorithm and visual representation of the solution. I want to render it using glfw3 and OpenGL. However, the window is created and everything it clears everything with the exact color I need but it will not render anything... Not even a simple quad.
main.cpp
Code:
int main(){
const char *title = "testing";
GLFWwindow* window = initWindow(640, 480,title);
while(!glfwWindowShouldClose(window)){
glClearColor(0.658824, 0.658824, 0.658824, 0.658824);
glClear(GL_COLOR_BUFFER_BIT);
glOrtho(0, 680, 0, 480, 0, 680);
glColor3f(1.0,0.0,0.0);
glBegin(GL_TRIANGLES);
drawPoint(300, 300, 10);
glEnd();
glFlush();
glfwSwapBuffers(window);
glfwPollEvents();
}
return 0;
}
initWindow
Code:
GLFWwindow* initWindow(int screen_width, int screen_height, const char* title){
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if(!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
window = glfwCreateWindow(screen_width, screen_height, title, NULL, NULL);
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
return window;
}
drawPoint
Code:
void drawPoint(int a_x, int a_y, int size=DEFAULT_POINT_SIZE){
//set the position of the point
int x = a_x - (int)size/2;
int y = a_y - (int)size/2;
//draw first triangle
glVertex2f(x,y);
glVertex2f(x,y+size+1);
glVertex2f(x+size+1,y);
//draw second triangle
glVertex2f(x,y+size+1);
glVertex2f(x+size+1, y+size+1);
glVertex2f(x+size+1,y);
}
Any ideas? Thanks in advance!
EDIT: I probably should mention that I a using a Linux machine