Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SoyElHomerMalo

Pages: [1]
1
Graphics / Re: BlackScreen when try to load VAO and VBO on OpenGL 4.3
« on: August 01, 2014, 08:59:01 pm »
Quote
http://en.sfml-dev.org/forums/index.php?topic=15820.0

Sorry binary1248, I read that post but I though it wasn't the same problem....and I didn't read your posts.

Thank you, unbind all buffers was the key.

2
Graphics / BlackScreen when try to load VAO and VBO on OpenGL 4.3
« on: August 01, 2014, 08:28:41 pm »
Hi!

I was looking for my problem but I haven't found the solution.

So the problem is...I have the main menu of my game created and working with sfml 2.1. I have an OpenGL4.3 program working with GLFW3. Now, I want to write that program into my SFML project, but when I write the function LoadPlane(), that has the vertex_buffer and setup the VBO and VAO, and execute the project, the main menu disappears. I know the main menu is still working because I hear the music and the sounds and I can choose any option of the menu with de arrow keys, but I can't see anything, only a black screen.

Here is some code:

void LoadPlane() {
        // make and bind the VAO
        glGenVertexArrays(1, &gVAO);
        glBindVertexArray(gVAO);

        // Make a plane with triangles (two triangles per side)
        GLfloat vertex_positions[] =
        {
                // (X, Y), (U, V)
                -0.5f, -0.5f, 0.0f, 0.0f,
                -0.5f,  0.5f, 0.0f, 1.0f,
                 0.5f, -0.5f, 1.0f, 0.0f,
                 0.5f,  0.5f, 1.0f, 1.0f
        };

        // make and bind the VBO
        glGenBuffers(1, &gVBO);
        glBindBuffer(GL_ARRAY_BUFFER, gVBO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_positions), vertex_positions, GL_STATIC_DRAW);
        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), NULL);
        glEnableVertexAttribArray(1);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_TRUE, 4 * sizeof(GLfloat), (const GLvoid*)(2 * sizeof(GLfloat)));
}

        // init glew
                glewExperimental = true;
                if (glewInit() != GLEW_OK)
                        throw runtime_error("glewInit failed");

                // GLEW throws some errors, so discard all the errors so far
                while (glGetError() != GL_NO_ERROR) {}

                // make sure OpenGL version 4.3 API is available
                if (!GLEW_VERSION_4_3)
                        throw runtime_error("OpenGL 4.3 API is not available.");

                // OpenGL settings
                program = 0;
                glEnable(GL_DEPTH_TEST);
                glDepthFunc(GL_LESS);

                // Create the program and attach all the shaders
                LoadProgram();

                // create buffer and fill it with the points of the triangle
                LoadPlane();

                // load texture
                LoadTexture();

                // setup tessellation
                glPatchParameteri(GL_PATCH_VERTICES, 4);

                // setup model-view-projection matrix
                projectM = perspective((float)PI / 3, ((float) window.getSize().x / window.getSize().y), 0.1f, 100.0f);
                viewM = lookAt(pos, target, vec3(0, 1, 0));
                modelM = mat4();
                window.pushGLStates();

        // main loop with render and update

            #pragma region OpenGL Render
            win.popGLStates();
                        // use the progam
                        glUseProgram(program);

                        // calculate the mvp matrix and set the "mvp" uniform
                        glUniformMatrix4fv(glGetUniformLocation(program, "mvp"), 1, GL_FALSE, value_ptr(projectM * viewM * modelM));

                        // draw the VAO
                        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                        glDrawArrays(GL_PATCHES, 0, 4);

                        win.pushGLStates();

                        // print GUI with sfml

If I comment LoadPlane(), I can see all the main menu.

Can someone help me?

Pages: [1]
anything