mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Add ScopedAllegro class.
This commit is contained in:
parent
5963bb96d9
commit
78d3b80df3
@ -154,6 +154,7 @@ add_library(aseprite-library
|
|||||||
objects_container_impl.cpp
|
objects_container_impl.cpp
|
||||||
recent_files.cpp
|
recent_files.cpp
|
||||||
resource_finder.cpp
|
resource_finder.cpp
|
||||||
|
scoped_allegro.cpp
|
||||||
ui_context.cpp
|
ui_context.cpp
|
||||||
undo_transaction.cpp
|
undo_transaction.cpp
|
||||||
xml_exception.cpp
|
xml_exception.cpp
|
||||||
|
26
src/main.cpp
26
src/main.cpp
@ -18,16 +18,15 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <allegro.h>
|
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "base/exception.h"
|
#include "base/exception.h"
|
||||||
#include "base/memory.h"
|
#include "base/memory.h"
|
||||||
#include "base/memory_dump.h"
|
#include "base/memory_dump.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "loadpng.h"
|
|
||||||
#include "resource_finder.h"
|
#include "resource_finder.h"
|
||||||
|
#include "scoped_allegro.h"
|
||||||
|
|
||||||
|
#include <allegro.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winalleg.h>
|
#include <winalleg.h>
|
||||||
#endif
|
#endif
|
||||||
@ -51,25 +50,6 @@ public:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// Allegro libray initialization
|
|
||||||
|
|
||||||
class Allegro {
|
|
||||||
public:
|
|
||||||
Allegro() {
|
|
||||||
allegro_init();
|
|
||||||
set_uformat(U_ASCII);
|
|
||||||
install_timer();
|
|
||||||
|
|
||||||
// Register PNG as a supported bitmap type
|
|
||||||
register_bitmap_file_type("png", load_png, save_png);
|
|
||||||
}
|
|
||||||
~Allegro() {
|
|
||||||
remove_timer();
|
|
||||||
allegro_exit();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool get_memory_dump_filename(std::string& filename)
|
static bool get_memory_dump_filename(std::string& filename)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -90,7 +70,7 @@ int main(int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
base::MemoryDump memoryDump;
|
base::MemoryDump memoryDump;
|
||||||
Allegro allegro;
|
ScopedAllegro allegro;
|
||||||
#ifdef MEMLEAK
|
#ifdef MEMLEAK
|
||||||
MemLeak memleak;
|
MemLeak memleak;
|
||||||
#endif
|
#endif
|
||||||
|
40
src/scoped_allegro.cpp
Normal file
40
src/scoped_allegro.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ASEPRITE
|
||||||
|
* Copyright (C) 2001-2012 David Capello
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "scoped_allegro.h"
|
||||||
|
|
||||||
|
#include <allegro.h>
|
||||||
|
#include "loadpng.h"
|
||||||
|
|
||||||
|
ScopedAllegro::ScopedAllegro()
|
||||||
|
{
|
||||||
|
allegro_init();
|
||||||
|
set_uformat(U_ASCII);
|
||||||
|
install_timer();
|
||||||
|
|
||||||
|
// Register PNG as a supported bitmap type
|
||||||
|
register_bitmap_file_type("png", load_png, save_png);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedAllegro::~ScopedAllegro()
|
||||||
|
{
|
||||||
|
remove_timer();
|
||||||
|
allegro_exit();
|
||||||
|
}
|
28
src/scoped_allegro.h
Normal file
28
src/scoped_allegro.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* ASEPRITE
|
||||||
|
* Copyright (C) 2001-2012 David Capello
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SCOPED_ALLEGRO_H
|
||||||
|
#define SCOPED_ALLEGRO_H
|
||||||
|
|
||||||
|
class ScopedAllegro {
|
||||||
|
public:
|
||||||
|
ScopedAllegro();
|
||||||
|
~ScopedAllegro();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user