Initial commit
This commit is contained in:
commit
edfc5298e1
252 changed files with 93965 additions and 0 deletions
40
source/System/File.cpp
Normal file
40
source/System/File.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <Spectre/System/File.h>
|
||||
|
||||
namespace File
|
||||
{
|
||||
std::string getBasename(const std::string& path) {
|
||||
|
||||
size_t p = path.find_last_of('/');
|
||||
|
||||
if (p == std::string::npos)
|
||||
return path;
|
||||
return path.substr(p + 1);
|
||||
}
|
||||
|
||||
std::string getExtension(const std::string& path) {
|
||||
|
||||
std::string base_name = getBasename(path);
|
||||
size_t p = base_name.find_first_of('.');
|
||||
if (p == std::string::npos)
|
||||
return "";
|
||||
return base_name.substr(p + 1);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> read(const std::string& path) {
|
||||
|
||||
std::vector<unsigned char> buf;
|
||||
FILE *fd = fopen(path.c_str(), "rb");
|
||||
|
||||
if (fd) {
|
||||
fseek(fd, 0, SEEK_END);
|
||||
buf.resize(ftell(fd));
|
||||
rewind(fd);
|
||||
fread(&buf[0], 1, buf.size(), fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
};
|
||||
13
source/System/Log.cpp
Normal file
13
source/System/Log.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <Spectre/System/Log.h>
|
||||
|
||||
void log(const char *fmt, ...) {
|
||||
|
||||
va_list vl;
|
||||
|
||||
va_start(vl, fmt);
|
||||
vfprintf(stderr, fmt, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
7
source/System/MessageHandler.cpp
Normal file
7
source/System/MessageHandler.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#include <Spectre/Display/Display.h>
|
||||
#include <Spectre/System/MessageHandler.h>
|
||||
|
||||
void MessageHandler::onSizeChanged(Display* display, int width, int height)
|
||||
{
|
||||
}
|
||||
22
source/System/MessageQueue.cpp
Normal file
22
source/System/MessageQueue.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#include <Spectre/System/MessageQueue.h>
|
||||
|
||||
void MessageQueue::postEvent(SysEvent& event)
|
||||
{
|
||||
m_queue.push_back(event);
|
||||
}
|
||||
|
||||
bool MessageQueue::pollEvent(SysEvent& event)
|
||||
{
|
||||
if (!isEmpty()) {
|
||||
event = m_queue.front();
|
||||
m_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MessageQueue::isEmpty() const
|
||||
{
|
||||
return m_queue.empty();
|
||||
}
|
||||
16
source/System/SystemEvent.cpp
Normal file
16
source/System/SystemEvent.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
#include <Spectre/System/SystemEvent.h>
|
||||
|
||||
SysEvent::SysEvent(Type type) :
|
||||
type (type)
|
||||
{
|
||||
}
|
||||
|
||||
SysEvent SysEvent::sizeEvent(Display *display, int width, int height)
|
||||
{
|
||||
SysEvent event(Size);
|
||||
event.size.display = display;
|
||||
event.size.width = width;
|
||||
event.size.height = height;
|
||||
return event;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue