0
votes

I am going through tutorial from this video https://www.youtube.com/watch?v=6u1FkksyNCk. After copying code from this guy to mine visual studio community 2015 I don't get triangle on the screen. There is just empty black window. Do I have a version problem? I configurated visual as he did in his second video https://www.youtube.com/watch?v=vGptI11wRxE

Code looks like:

#include <windows.h>
#include <GL/GL.h>
#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow *window;

    //initialisie the GLFW
    if(!glfwInit())
    {
        return -1;
    }

    //create a window mode OpenGL Context
    window = glfwCreateWindow(640, 480, "OpenGL Project Tutorial", NULL, NULL);

    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    // make window 's context current

    float vertices[] =
    {
        0.0, 0.5, 0.0, // top
        -0.5, -0.5, 0.0, // bottom
        0.5, -0.5, 0.0 // bottom right
    };

    //loop unitl the user closes the window
    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        // Render OpenGL here
        glEnableClientState(GL_VERTEX_ARRAY);
        glVertexPointer(3, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_TRIANGLES, 0, 3 );
        glDisableClientState( GL_VERTEX_ARRAY);
        //render the OpenGL here

        //sweap front and back buffers
        glfwSwapBuffers(window);

        //poll for and process events
        glfwPollEvents();
    }

    glfwTerminate();
}
1
You really shouldn't expect people here watching video tutorials just to find the source code you might be using.derhass

1 Answers

0
votes

Your code lacks a

glfwMakeContextCurrent(window);

right after the

// make window 's context current

comment.