renamed Video module to AV

git-svn-id: svn://anubis/anaglym/trunk@260 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-02-24 03:17:59 +00:00
parent 2763da5f43
commit 0cf1ea45a2
6 changed files with 33 additions and 34 deletions

View File

@ -1,5 +1,5 @@
#include "Video.h" #include "AV.h"
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include <SDL.h> #include <SDL.h>
@ -8,7 +8,7 @@
#include <math.h> #include <math.h>
using namespace std; using namespace std;
static void Video_sound_callback(void * userdata, Uint8 * stream, int len) static void AV_sound_callback(void * userdata, Uint8 * stream, int len)
{ {
static int pos = 0; static int pos = 0;
Sint16 * str = (Sint16 *) stream; Sint16 * str = (Sint16 *) stream;
@ -20,7 +20,7 @@ static void Video_sound_callback(void * userdata, Uint8 * stream, int len)
} }
} }
Video::Video() AV::AV()
{ {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
{ {
@ -51,7 +51,7 @@ Video::Video()
desired.format = AUDIO_S16SYS; desired.format = AUDIO_S16SYS;
desired.channels = 2; desired.channels = 2;
desired.samples = 4096; desired.samples = 4096;
desired.callback = Video_sound_callback; desired.callback = AV_sound_callback;
desired.userdata = this; desired.userdata = this;
if (SDL_OpenAudio(&desired, NULL) < 0) if (SDL_OpenAudio(&desired, NULL) < 0)
{ {
@ -60,13 +60,13 @@ Video::Video()
} }
} }
Video::~Video() AV::~AV()
{ {
Sound_Quit(); Sound_Quit();
SDL_Quit(); SDL_Quit();
} }
void Video::start(int width, int height, bool fullscreen, bool grab_input, void AV::start(int width, int height, bool fullscreen, bool grab_input,
int samples) int samples)
{ {
if (m_surface == NULL) if (m_surface == NULL)
@ -111,7 +111,7 @@ void Video::start(int width, int height, bool fullscreen, bool grab_input,
} }
} }
void Video::stop() void AV::stop()
{ {
if (m_surface != NULL) if (m_surface != NULL)
{ {

View File

@ -4,11 +4,11 @@
#include <SDL.h> #include <SDL.h>
class Video class AV
{ {
public: public:
Video(); AV();
~Video(); ~AV();
void start(int width = 0, int height = 0, void start(int width = 0, int height = 0,
bool fullscreen = true, bool grab_input = true, bool fullscreen = true, bool grab_input = true,
int samples = 4); int samples = 4);

View File

@ -2,7 +2,7 @@
#include "ag.h" #include "ag.h"
#include "anaglym.h" #include "anaglym.h"
#include "Engine.h" #include "Engine.h"
#include "Video.h" #include "AV.h"
#include "PhyObj/PhyObj.h" #include "PhyObj/PhyObj.h"
#include "sdl_keymap.h" #include "sdl_keymap.h"
#include <lua.hpp> #include <lua.hpp>
@ -85,8 +85,8 @@ static void checkGLErrorLine(const char * function, int line)
/******** Engine functions ********/ /******** Engine functions ********/
Engine::Engine(const string & path, Video & video) Engine::Engine(const string & path, AV & av)
: m_video(video) : m_av(av)
{ {
m_next_object_index = 1; m_next_object_index = 1;
m_next_joint_index = 1; m_next_joint_index = 1;
@ -108,10 +108,10 @@ Engine::Engine(const string & path, Video & video)
m_fileLoader = new EngineFileLoader(this); m_fileLoader = new EngineFileLoader(this);
m_event_time = 0; m_event_time = 0;
m_font = NULL; m_font = NULL;
m_engine_cursor_visible = m_video.getCursorVisible(); m_engine_cursor_visible = m_av.getCursorVisible();
m_script_cursor_visible = false; m_script_cursor_visible = false;
m_input_grabbed = m_video.getInputGrabbed(); m_input_grabbed = m_av.getInputGrabbed();
m_screen_dist = (m_video.getHeight() / 2.0) / tan(30.0 * M_PI / 180.0); m_screen_dist = (m_av.getHeight() / 2.0) / tan(30.0 * M_PI / 180.0);
size_t pos = path.find_last_of("\\/"); size_t pos = path.find_last_of("\\/");
m_engine_path = (pos != string::npos) ? string(path, 0, pos) : "."; m_engine_path = (pos != string::npos) ? string(path, 0, pos) : ".";
@ -652,9 +652,9 @@ refptr< vector<int> > Engine::pickObjects(int x, int y)
cross_product(right, forward, up); cross_product(right, forward, up);
dRFrom2Axes(r, right[0], right[1], right[2], dRFrom2Axes(r, right[0], right[1], right[2],
forward[0], forward[1], forward[2]); forward[0], forward[1], forward[2]);
initial_direction[0] = x - m_video.getWidth() / 2; initial_direction[0] = x - m_av.getWidth() / 2;
initial_direction[1] = m_screen_dist; initial_direction[1] = m_screen_dist;
initial_direction[2] = m_video.getHeight() / 2 - y; initial_direction[2] = m_av.getHeight() / 2 - y;
dMultiply0(rotated_direction, r, initial_direction, 3, 3, 1); dMultiply0(rotated_direction, r, initial_direction, 3, 3, 1);
normalize(rotated_direction); normalize(rotated_direction);
@ -684,8 +684,8 @@ void Engine::debug_hook(lua_Debug * debug)
void Engine::getScreenSize(int * width, int * height) void Engine::getScreenSize(int * width, int * height)
{ {
*width = m_video.getWidth(); *width = m_av.getWidth();
*height = m_video.getHeight(); *height = m_av.getHeight();
} }
void Engine::drawText(const char * text, GLfloat r, GLfloat g, GLfloat b, void Engine::drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
@ -877,13 +877,13 @@ void Engine::run()
case SDLK_ESCAPE: case SDLK_ESCAPE:
goto RET; goto RET;
case SDLK_F1: case SDLK_F1:
m_video.toggleFullScreen(); m_av.toggleFullScreen();
break; break;
case SDLK_F2: case SDLK_F2:
m_engine_cursor_visible = !m_engine_cursor_visible; m_engine_cursor_visible = !m_engine_cursor_visible;
m_input_grabbed = !m_input_grabbed; m_input_grabbed = !m_input_grabbed;
updateCursorVisibility(); updateCursorVisibility();
m_video.setInputGrabbed(m_input_grabbed); m_av.setInputGrabbed(m_input_grabbed);
break; break;
case SDLK_F5: case SDLK_F5:
reloadProgram(); reloadProgram();
@ -961,8 +961,8 @@ void Engine::update_overlay_event()
glPushAttrib(GL_ENABLE_BIT); glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
int width = m_video.getWidth(); int width = m_av.getWidth();
int height = m_video.getHeight(); int height = m_av.getHeight();
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();

View File

@ -10,7 +10,7 @@
#include "OdeWorld/OdeWorld.h" #include "OdeWorld/OdeWorld.h"
#include "TextureCache/TextureCache.h" #include "TextureCache/TextureCache.h"
#include "wfobj/WFObj.h" #include "wfobj/WFObj.h"
#include "Video.h" #include "AV.h"
#include "refptr/refptr.h" #include "refptr/refptr.h"
#include "ftgl.h" #include "ftgl.h"
#include "PhyObj/PhyObj.h" #include "PhyObj/PhyObj.h"
@ -134,7 +134,7 @@ class Engine
Engine * m_engine; Engine * m_engine;
}; };
Engine(const std::string & path, Video & video); Engine(const std::string & path, AV & av);
~Engine(); ~Engine();
std::string locateResource(const std::string & shortname); std::string locateResource(const std::string & shortname);
@ -245,11 +245,11 @@ class Engine
void checkForAllHandlerFunctions(); void checkForAllHandlerFunctions();
void updateCursorVisibility() void updateCursorVisibility()
{ {
m_video.setCursorVisible( m_av.setCursorVisible(
m_engine_cursor_visible || m_script_cursor_visible); m_engine_cursor_visible || m_script_cursor_visible);
} }
Video & m_video; AV & m_av;
bool m_engine_cursor_visible; bool m_engine_cursor_visible;
bool m_script_cursor_visible; bool m_script_cursor_visible;
bool m_input_grabbed; bool m_input_grabbed;

1
ag.cc
View File

@ -3,7 +3,6 @@
#include "ag_lua.h" #include "ag_lua.h"
#include "anaglym.h" #include "anaglym.h"
#include "Engine.h" #include "Engine.h"
#include "Video.h"
#include <SDL.h> #include <SDL.h>
#include "wfobj/WFObj.h" #include "wfobj/WFObj.h"
#include <unistd.h> /* usleep() */ #include <unistd.h> /* usleep() */

View File

@ -1,5 +1,5 @@
#include "Video.h" #include "AV.h"
#include "anaglym.h" #include "anaglym.h"
#include "Engine.h" #include "Engine.h"
#include "SDL.h" #include "SDL.h"
@ -71,15 +71,15 @@ int main(int argc, char * argv[])
srand(time(NULL)); srand(time(NULL));
Video video; AV av;
video.start(width, height, fullscreen, grab_input); av.start(width, height, fullscreen, grab_input);
dInitODE(); dInitODE();
g_engine = new Engine(argv[0], video); g_engine = new Engine(argv[0], av);
if (g_engine->load(program)) if (g_engine->load(program))
g_engine->run(); g_engine->run();
delete g_engine; delete g_engine;
video.stop(); av.stop();
dCloseODE(); dCloseODE();
return 0; return 0;