PDA

View Full Version : glCreateBuffers Access Violation Exception GLFW/GLEW



puregainz
03-06-2017, 05:12 PM
Hello guys,

This issue has been adressed multiples times, but I followed every suggested solutions and nothing seems to work:

I get :

Exception thrown at 0x0000000000000000 in Program.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

I already done:
-Creating a GLFW OpenGL 3.2 context with forward compatibility for the 3.0+ functionnalities to be available
-Inited in the right order GLFW > the Window context > GLEW with experimental = true

my code:


#include <stdio.h>
#include <stdlib.h>

#include <math.h>

#include "codefortress_core.h"

#include "dataparser.h"
#include "utils.h"

using namespace std;

using namespace utils;
using namespace dataparser;

// -------------------------------- MAIN ------------------------------- //
int main()
{

// -------------------------------- INIT ------------------------------- //

// Init GLFW
if (glfwInit() != GL_TRUE) {
graphic_engine::ge_crash("Failed to initialize GLFW\n");
//fprintf(stderr, "Failed to initialize GLFW\n");
//return -1;
}

// Create a rendering window with OpenGL 3.2 context
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //3.2 works //4.3
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

GLFWwindow* window = glfwCreateWindow(800, 600, "OpenGL", NULL, NULL); //glfwGetPrimaryMonitor() avant dernier parama
glfwMakeContextCurrent(window);

if (!window)
{
fprintf(stderr, "Failed to open GLFW window.\n");
glfwTerminate();
exit(EXIT_FAILURE);
}

glfwMakeContextCurrent(window);

glfwSetKeyCallback(window, graphic_engine::key_callback);

// Init GLEW
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
graphic_engine::ge_crash("Failed to initialize GLEW\n");
//fprintf(stderr, "Failed to initialize GLEW\n");
//return -1;
}

// ----------------------------- RESOURCES ----------------------------- //

//map values
const int map_size = 16;
const int spice = 28; //colored differently
int map[map_size*map_size];
for (int i = 0; i < map_size*map_size;i++) {
if (i%spice == 0) {
map[i] = 1;
}else {
map[i] = 0;
}
}

//declarations
GLuint vao;
GLuint buffer[1]; //map buffer

//first VAO
glCreateVertexArrays(1, &vao);

//buffer
glCreateBuffers(1, &buffer[0]);
glNamedBufferStorage(buffer[0],sizeof(map),map,0);
glVertexArrayVertexBuffer(vao, 0, buffer[0], 0, sizeof(int));

//attrib linked
glVertexArrayAttribFormat(vao,0,1,GL_INT,GL_FALSE, 0);
glVertexArrayAttribBinding(vao, 0, 0);
glEnableVertexArrayAttrib(vao, 0);

// ---------------------------- RENDERING LOOP ------------------------------ //

static GLfloat color[] = { 0.0f,0.0f, 0.0f, 1.0f };

while (!glfwWindowShouldClose(window))
{

//flashy background
float curtime = (float)glfwGetTime();

color[0] = cosf(curtime)*0.5f + 0.5f;
color[1] = sinf(curtime)*0.5f + 0.5f;

glClearBufferfv(GL_COLOR, 0, color);

glfwSwapBuffers(window);
glfwPollEvents();

}

glfwTerminate();

return 0;
}


Any help is very appreciated, thanks in advance !
(sorry for my english, and I had trouble posting, maybe I did this thread in duplicate ?)

mhagain
03-07-2017, 12:17 AM
What GPU have you?

puregainz
03-07-2017, 01:26 AM
What GPU have you?

I have a Latitude E5540 laptop with Intel® Integrated HD Graphics 4400 , It can run games of the current era, I don't think glCreateBuffers is some kind of last generation graphics function only supported by GTi Titans ...

EDIT:
I just ran glewinfo.exe and my GPU doesn't support OpenGL 4.3+
In another forum post I found glCreateBuffers are GL 4.5, Okay it makes sense now.

So I guess I will stick with glGenBuffers for now ?

Silence
03-07-2017, 02:09 AM
You don't have to move to another forum. All information about OpenGL functions are on this website (khronos):

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCreateBuffers.xhtml

You can try to update your drivers and see if things change...

Otherwise, yes. Stick with GenBuffers.

puregainz
03-07-2017, 02:18 AM
You don't have to move to another forum. All information about OpenGL functions are on this website (khronos):

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCreateBuffers.xhtml

You can try to update your drivers and see if things change...

Otherwise, yes. Stick with GenBuffers.

That's exactly the page I found, my drivers are up to date, but it's ok, I have learned things today..

Thank you all for everything !