Thanks for the quick reply, I did program a loop in alongside the tutorial I was following, and it seemed to work fine for the programmer doing it. I’m new to the site, I apologise if this isn’t formatted correctly, I will edit it.
int main()
{
if (!glfwInit()) {
//GLFW failed to initialise
//closing program
fprintf(stderr, "GLFW Failed.");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4); //sets 4 anti-aliasing, which is 4 fragments per pixel
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //asking for opengl version 3
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); //and then .3, so 3.3
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //so we're using ONLY the core profile functions
GLFWwindow* window = glfwCreateWindow(640, 480, "My OpenGL", NULL, NULL);
//creates our window
//width, height, title, null, null
if (!window) {
//window failed
//closing program
fprintf(stderr, "Window Failed.");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window); //this is the window OpenGL will be applied to
glewExperimental = true; //sets newest glew for program
if (glewInit() != GLEW_OK)
{
//Glew failed
fprintf(stderr, "GLEW Failed.");
glfwTerminate();
return -1;
}
//Generate VAO
GLuint vaoID;
glGenVertexArrays(1, &vaoID); //create 1 array, referencing the ID for our vertex object, to be sent BACK to us when edited
glBindVertexArray(vaoID); //generate vertex arrays
static const GLfloat verts[] = {
// X, Y, Z
-1.0f, -1.0f, +0.0f,
+1.0f, -1.0f, +0.0f,
+0.0f, +1.0f, +0.0f
};
//Generate VBO
GLuint vboID;
glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID); //create our vertices data buffer for use
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
do {
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vboID); //paste again for safety
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glfwSwapBuffers(window);
glfwPollEvents(); //to check for any changes to the data/input
} while (glfwWindowShouldClose(window) == false);
return 0;
}
Edit: Thanks to mods for fixing my box.
Obviously I’ve left out the includes and comments at the top of the file, but any alterations that need to be made to this will.
This is all the programming I’ve done so far on this file, so this is all I can give you.
EDIT:
The window has mysteriously turned from white to black, so the window itself may be being used properly now. I switched from 32-bit to 64-bit, including libraries, dlls, etc. The window is still blank though. To make things weirder, I just pasted this into the loop to test:
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_TRIANGLES);
glVertex3f(-1.0f, -1.0f, +0.0f);
glVertex3f(+1.0f, -1.0f, +0.0f);
glVertex3f(+0.0f, +1.0f, +0.0f);
glEnd();
and still received nothing on the window. The window is likely programmed incorrectly, or I’ve messed up somewhere else