text: Hi, I've recently started learning opengl and I've encountered a problem... I'm following this tutorial
  My problem is that my code doesn't draw the triangle! I've slightly altered the code but the whole thing SHOULD be working. My code is:
  #include <iostream> #include <GL/glew.h> #include <GL/glfw.h> int main() { // Initialize GLFW if (!glfwInit()) { std::cout << "Failed to initialize GLFW" << std::endl; return 1; } if (!glfwOpenWindow(1024, 768, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) { std::cout << "Failed to create window" << std::endl; glfwTerminate(); return 1; } // Adds support for experimental or pre-release graphics drivers glewExperimental = GL_TRUE; // Intialize GLEW if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW" << std::endl; return 1; } glfwSetWindowTitle("OpenGL Hacks"); GLuint vertexArrayID; glGenVertexArrays(1, &vertexArrayID); glBindVertexArray(vertexArrayID); static const GLfloat vertexBufferData[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f }; GLuint vertexBuffer; glGenBuffers(1, &vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertexBufferData), vertexBufferData, GL_STATIC_DRAW); glfwEnable(GLFW_STICKY_KEYS); while (glfwGetWindowParam(GLFW_OPENED)) { if (glfwGetKey(GLFW_KEY_ESC)) { break; } glClearColor(0.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(0); glfwSwapBuffers(); } glfwTerminate(); return 0; }
  I'm using GLFW 2.7.7, GLEW 1.9.0 and my OS is Arch Linux. However, I'm running Arch Linux on VirtualBox and obviously, you can't install graphics drivers using VirtualBox. So maybe that's the problem? I don't know, but I tried compiling on windows 7 using MinGW and it still doesn't draw the triangle. So I don't think that's the problem.
  Also, in the first tutorial, Opening a window, I didn't use the code:);
  Because otherwise, my program would crash. (Probably because of no graphics drivers from virtualizing the OS).
  Any help would be appreciated. Thanks.
  EDIT: Also, when compiling the code on Windows 7, I see the window open, but no triangle drawn and that the program instantly crashes after opening it. Yes, I've compiled GLEW and GLFW from source. Possibly something in the code is making my program crash in Windows. The program doesn't crash on Linux, however.
  Edited by Krankles, 10 February 2013 - 09:35 AM.