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 45 46 47 48 49 50 51 52
|
log->logMessage(log->GL, "Initializing SDL");
if (SDL_Init(SDL_INIT_VIDEO) < 0) /* Initialize SDL's Video subsystem */
{
log->logMessage(log->GLERR, "Could not initialize SDL!");
log->logMessage(log->GLERR, SDL_GetError());
return false;
}
log->logMessage(log->GL, "Setting SDL Attributes");
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
log->logMessage(log->GL, "Setting SDL VideoMode");
mainwindow = SDL_CreateWindow("Echoes Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!mainwindow) /* Die if creation failed */
{
log->logMessage(log->WNDERR, "Could not create game window!");
log->logMessage(log->WNDERR, SDL_GetError());
return false;
}
SDL_GLContext maincontext;
maincontext = SDL_GL_CreateContext(mainwindow);
if(*SDL_GetError() != '\0')
{
log->logMessage(log->GLERR, "Could not create OpenGL context!");
log->logMessage(log->GLERR, SDL_GetError());
return false;
}
glViewport(0, 0, 800, 600);
glOrtho(0, 800, 600, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
log->logMessage(log->GL, "SDL and OpenGL successfully initialized");
|