hi I was working on my first sdl and opengl project every time I try to run my programe
I got this exception in glgenbuffers the linking way is right and this is my code of initilizing
SDL_Init(SDL_INIT_EVERYTHING);
window = SDL_CreateWindow("mine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, SDL_WINDOW_OPENGL);
if (window == nullptr) {
fatalerror("cant create (open) window");
}
SDL_GLContext context = SDL_GL_CreateContext(window);
if (context == nullptr) {
fatalerror("context cant be created ");
}
GLenum cerror = glewInit();
if (cerror != GLEW_OK)
{
fatalerror("cant init glew:(");
}
std::cout << "ok";
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
can any one help me please !?
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnableClientState(GL_COLOR_ARRAY);
s.draw();
SDL_GL_SwapWindow(window);
this is the part wich i used s.draw function in previous code
_x = x;
_y = y;
_w = w;
_h = h;
if (vboid == 0) {
glGenBuffers(1, &vboid);
}
float vertexdata[12];
//first triangle
vertexdata[0] = x + w;
vertexdata[1] = y + w;
vertexdata[2] = x;
vertexdata[3] = y + h;
vertexdata[4] = x;
vertexdata[5] = y;
//second triangle
vertexdata[6] = x;
vertexdata[7] = y ;
vertexdata[8] = x+h;
vertexdata[9] = y;
vertexdata[10] = x+w;
vertexdata[11] = y+h;
glBindBuffer(GL_ARRAY_BUFFER,vboid);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertexdata),vertexdata,GL_STATIC_DRAW)
;
User contributions licensed under CC BY-SA 3.0