I've been trying to follow a tutorial of glew, but i can't run this glGenVertexArrays, it always leads to a memmory access violation!...
I tried glExperimental = GL_TRUE too, also updated my video card driver 2 times, but it doesn't run.
Btw, there's my code (to TRY to generate a simple triangle):
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
#include <glew.h>
#include <glfw.h>
#include <glm/glm.hpp>
using namespace glm;
#define GLFW_DLL
//#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
//#pragma comment(linker, "/ENTRY:mainCRTStartup")
int main()
{
//glewExperimental = GL_TRUE;
if(!glfwInit())
{
cout << "Failed to load graphics... " << endl;
return -1;
}
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
static const GLfloat g_vertex_buffer_data[] =
{
-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(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_VERSION_MINOR, 1);
//glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);
if(!glfwOpenWindow(1024, 768, 0, 0, 0, 0, 32, 0, GLFW_WINDOW))
{
cout << "Failed to open window";
glfwTerminate();
return -2;
}
glfwSetWindowTitle("IfUSeeingThisMsgTheShitWorked");
glfwEnable(GLFW_STICKY_KEYS);
//Main loop
do
{
cout << "happaned";
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();
}while(glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED));
return 0;
}
Also, I want to point out that this function doesn't work:
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
so I had to change it to:
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, 0);
Does it have anything to do with my error? hm.
I'm posting it here, just to make sure that there's no other thing I can do, other than buy a new video card. I really want to use the modern OpenGL, it is pointless to learn the old one.
sizeofand get the size of a pointer instead of the size of an array. (not saying that's the case here). You may want to look for similar errors. – Byte56 Feb 21 at 23:39