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();
}
|