(root)/src/sssnakesss.cpp @ 1 - Rev 3
Rev 2 |
Rev 4 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
#include "sssnakesss.hpp"
SSSNAKESSS::SSSNAKESSS()
{
running = false;
}
SSSNAKESSS::~SSSNAKESSS()
{
}
bool SSSNAKESSS::init()
{
if (!initSDL())
{
return false;
}
if (!initOpenGL())
{
return false;
}
initData();
return true;
}
bool SSSNAKESSS::initSDL()
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
return false;
}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screen = SDL_SetVideoMode(640, 480, 16, SDL_OPENGL);
if (!screen)
{
return false;
}
return true;
}
bool SSSNAKESSS::initOpenGL()
{
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glViewport(0, 0, 640, 480);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 640, 480, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return true;
}
void SSSNAKESSS::initData()
{
}
void SSSNAKESSS::run()
{
running = true;
while (running)
{
checkEvents();
update();
draw();
}
}
void SSSNAKESSS::checkEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
running = false;
break;
}
}
}
void SSSNAKESSS::update()
{
}
void SSSNAKESSS::draw()
{
}
void SSSNAKESSS::end()
{
}