opengl access violation error

so i wrote this program that just creates a red window using SDL and then initializes GLEW..

Main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <GL\glew.h>
#include "window.h"

int main(int argc, char** argv)
{
	window Window("",100,100,500,400);


	while (Window.Update() != SDL_QUIT)
	{
		
	}


	return 0;
}



Window.H:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once
#include <GL\glew.h>
#include <SDL.h>
#include <iostream>

class window
{
private:
	SDL_Window* _pWindow;
	SDL_Event _event;
	char* _title = "";
	int _x = 100;
	int _y = 100;
	int _w = 500;
	int _h = 400;

public:
	window(char* title,int x, int y, int width, int height);
	int Update();
	~window();
};




Window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "window.h"



window::window(char* title, int x, int y, int width, int height) :
_title(title),
_x(x),
_y(y),
_w(width),
_h(height)
{
	SDL_Init(SDL_INIT_EVERYTHING);
	_pWindow = SDL_CreateWindow(_title, _x, _y, _w, _h, SDL_WINDOW_OPENGL);
	

	SDL_GL_CreateContext(_pWindow);
	if (glewInit() == GLEW_OK)
		std::cout << "glew ok" << std::endl;


	glClearColor(0.6f, 0.0f, 0.0f, 1.0f);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);


}


int window::Update()
{
	SDL_PollEvent(&_event);
	SDL_GL_SwapWindow(_pWindow);
	
	glClear(GL_COLOR_BUFFER_BIT);

	return _event.type;
}


window::~window()
{
	
	SDL_Quit();
}



when i run it, it says "glew ok" in the console and i get a red window as expected...

my problem is that when i then try and call the "glCreateBuffer" function, in main.cpp AFTER creating the window but before the while loop, i get this wired error:
1
2
3
Exception thrown at 0x00000000 in opengl_project.exe: 0xC0000005: Access violation executing location 0x00000000.

If there is a handler for this exception, the program may be safely continued.


can someone help me?
Is the OpenGL context still current after glewInit?
uhh im not sure....what exactly do you mean by current? :p
Topic archived. No new replies allowed.