mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
School is soooooo boooorrrrriiiiiinnnngggf
This commit is contained in:
parent
e1ced21b34
commit
d5bb0f501a
16 changed files with 145 additions and 302 deletions
|
|
@ -219,8 +219,6 @@ void graphicsBindingInit(){
|
|||
|
||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||
|
||||
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
|
||||
|
||||
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
|
||||
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
|
||||
INIT_GRA_PROP_BIND( Smooth, "smooth" );
|
||||
|
|
|
|||
123
src/etc.cpp
123
src/etc.cpp
|
|
@ -29,14 +29,12 @@
|
|||
#include <SDL3/SDL_pixels.h>
|
||||
|
||||
Color::Color(double red, double green, double blue, double alpha)
|
||||
: red(red), green(green), blue(blue), alpha(alpha)
|
||||
{
|
||||
: red(red), green(green), blue(blue), alpha(alpha){
|
||||
updateInternal();
|
||||
}
|
||||
|
||||
Color::Color(const Vec4 &norm)
|
||||
: norm(norm)
|
||||
{
|
||||
: norm(norm){
|
||||
updateExternal();
|
||||
}
|
||||
|
||||
|
|
@ -45,16 +43,14 @@ Color::Color(const Color &o)
|
|||
norm(o.norm)
|
||||
{}
|
||||
|
||||
bool Color::operator==(const Color &o) const
|
||||
{
|
||||
bool Color::operator==(const Color &o) const{
|
||||
return red == o.red &&
|
||||
green == o.green &&
|
||||
blue == o.blue &&
|
||||
alpha == o.alpha;
|
||||
}
|
||||
|
||||
const Color &Color::operator=(const Color &o)
|
||||
{
|
||||
const Color &Color::operator=(const Color &o){
|
||||
red = o.red;
|
||||
green = o.green;
|
||||
blue = o.blue;
|
||||
|
|
@ -64,8 +60,7 @@ const Color &Color::operator=(const Color &o)
|
|||
return o;
|
||||
}
|
||||
|
||||
void Color::set(double red, double green, double blue, double alpha)
|
||||
{
|
||||
void Color::set(double red, double green, double blue, double alpha){
|
||||
this->red = red;
|
||||
this->green = green;
|
||||
this->blue = blue;
|
||||
|
|
@ -74,46 +69,39 @@ void Color::set(double red, double green, double blue, double alpha)
|
|||
updateInternal();
|
||||
}
|
||||
|
||||
void Color::setRed(double value)
|
||||
{
|
||||
void Color::setRed(double value){
|
||||
red = value;
|
||||
norm.x = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setGreen(double value)
|
||||
{
|
||||
void Color::setGreen(double value){
|
||||
green = value;
|
||||
norm.y = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setBlue(double value)
|
||||
{
|
||||
void Color::setBlue(double value){
|
||||
blue = value;
|
||||
norm.z = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
void Color::setAlpha(double value)
|
||||
{
|
||||
void Color::setAlpha(double value){
|
||||
alpha = value;
|
||||
norm.w = clamp<double>(value, 0, 255) / 255;
|
||||
}
|
||||
|
||||
/* Serializable */
|
||||
int Color::serialSize() const
|
||||
{
|
||||
int Color::serialSize() const{
|
||||
return 4 * 8;
|
||||
}
|
||||
|
||||
void Color::serialize(char *buffer) const
|
||||
{
|
||||
void Color::serialize(char *buffer) const{
|
||||
writeDouble(&buffer, red);
|
||||
writeDouble(&buffer, green);
|
||||
writeDouble(&buffer, blue);
|
||||
writeDouble(&buffer, alpha);
|
||||
}
|
||||
|
||||
Color *Color::deserialize(const char *data, int len)
|
||||
{
|
||||
Color *Color::deserialize(const char *data, int len){
|
||||
if (len != 32)
|
||||
throw Exception(Exception::ArgumentError, "Color: Serialized data invalid");
|
||||
|
||||
|
|
@ -128,24 +116,21 @@ Color *Color::deserialize(const char *data, int len)
|
|||
return c;
|
||||
}
|
||||
|
||||
void Color::updateInternal()
|
||||
{
|
||||
void Color::updateInternal(){
|
||||
norm.x = red / 255;
|
||||
norm.y = green / 255;
|
||||
norm.z = blue / 255;
|
||||
norm.w = alpha / 255;
|
||||
}
|
||||
|
||||
void Color::updateExternal()
|
||||
{
|
||||
void Color::updateExternal(){
|
||||
red = norm.x * 255;
|
||||
green = norm.y * 255;
|
||||
blue = norm.z * 255;
|
||||
alpha = norm.w * 255;
|
||||
}
|
||||
|
||||
SDL_Color Color::toSDLColor() const
|
||||
{
|
||||
SDL_Color Color::toSDLColor() const{
|
||||
SDL_Color c;
|
||||
c.r = clamp<double>(red, 0, 255);
|
||||
c.g = clamp<double>(green, 0, 255);
|
||||
|
|
@ -157,8 +142,7 @@ SDL_Color Color::toSDLColor() const
|
|||
|
||||
|
||||
Tone::Tone(double red, double green, double blue, double gray)
|
||||
: red(red), green(green), blue(blue), gray(gray)
|
||||
{
|
||||
: red(red), green(green), blue(blue), gray(gray){
|
||||
updateInternal();
|
||||
}
|
||||
|
||||
|
|
@ -167,16 +151,14 @@ Tone::Tone(const Tone &o)
|
|||
norm(o.norm)
|
||||
{}
|
||||
|
||||
bool Tone::operator==(const Tone &o) const
|
||||
{
|
||||
bool Tone::operator==(const Tone &o) const{
|
||||
return red == o.red &&
|
||||
green == o.green &&
|
||||
blue == o.blue &&
|
||||
gray == o.gray;
|
||||
}
|
||||
|
||||
void Tone::set(double red, double green, double blue, double gray)
|
||||
{
|
||||
void Tone::set(double red, double green, double blue, double gray){
|
||||
this->red = red;
|
||||
this->green = green;
|
||||
this->blue = blue;
|
||||
|
|
@ -186,8 +168,7 @@ void Tone::set(double red, double green, double blue, double gray)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
const Tone& Tone::operator=(const Tone &o)
|
||||
{
|
||||
const Tone& Tone::operator=(const Tone &o){
|
||||
red = o.red;
|
||||
green = o.green;
|
||||
blue = o.blue;
|
||||
|
|
@ -199,32 +180,28 @@ const Tone& Tone::operator=(const Tone &o)
|
|||
return o;
|
||||
}
|
||||
|
||||
void Tone::setRed(double value)
|
||||
{
|
||||
void Tone::setRed(double value){
|
||||
red = value;
|
||||
norm.x = (float) clamp<double>(value, -255, 255) / 255;
|
||||
|
||||
valueChanged();
|
||||
}
|
||||
|
||||
void Tone::setGreen(double value)
|
||||
{
|
||||
void Tone::setGreen(double value){
|
||||
green = value;
|
||||
norm.y = (float) clamp<double>(value, -255, 255) / 255;
|
||||
|
||||
valueChanged();
|
||||
}
|
||||
|
||||
void Tone::setBlue(double value)
|
||||
{
|
||||
void Tone::setBlue(double value){
|
||||
blue = value;
|
||||
norm.z = (float) clamp<double>(value, -255, 255) / 255;
|
||||
|
||||
valueChanged();
|
||||
}
|
||||
|
||||
void Tone::setGray(double value)
|
||||
{
|
||||
void Tone::setGray(double value){
|
||||
gray = value;
|
||||
norm.w = (float) clamp<double>(value, 0, 255) / 255;
|
||||
|
||||
|
|
@ -232,21 +209,18 @@ void Tone::setGray(double value)
|
|||
}
|
||||
|
||||
/* Serializable */
|
||||
int Tone::serialSize() const
|
||||
{
|
||||
int Tone::serialSize() const{
|
||||
return 4 * 8;
|
||||
}
|
||||
|
||||
void Tone::serialize(char *buffer) const
|
||||
{
|
||||
void Tone::serialize(char *buffer) const{
|
||||
writeDouble(&buffer, red);
|
||||
writeDouble(&buffer, green);
|
||||
writeDouble(&buffer, blue);
|
||||
writeDouble(&buffer, gray);
|
||||
}
|
||||
|
||||
Tone *Tone::deserialize(const char *data, int len)
|
||||
{
|
||||
Tone *Tone::deserialize(const char *data, int len){
|
||||
if (len != 32)
|
||||
throw Exception(Exception::ArgumentError, "Tone: Serialized data invalid");
|
||||
|
||||
|
|
@ -261,8 +235,7 @@ Tone *Tone::deserialize(const char *data, int len)
|
|||
return t;
|
||||
}
|
||||
|
||||
void Tone::updateInternal()
|
||||
{
|
||||
void Tone::updateInternal(){
|
||||
norm.x = (float) clamp<double>(red, -255, 255) / 255;
|
||||
norm.y = (float) clamp<double>(green, -255, 255) / 255;
|
||||
norm.z = (float) clamp<double>(blue, -255, 255) / 255;
|
||||
|
|
@ -283,29 +256,25 @@ Rect::Rect(const IntRect &r)
|
|||
: x(r.x), y(r.y), width(r.w), height(r.h)
|
||||
{}
|
||||
|
||||
bool Rect::operator==(const Rect &o) const
|
||||
{
|
||||
bool Rect::operator==(const Rect &o) const{
|
||||
return x == o.x &&
|
||||
y == o.y &&
|
||||
width == o.width &&
|
||||
height == o.height;
|
||||
}
|
||||
|
||||
void Rect::operator=(const IntRect &rect)
|
||||
{
|
||||
void Rect::operator=(const IntRect &rect){
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
width = rect.w;
|
||||
height = rect.h;
|
||||
}
|
||||
|
||||
void Rect::set(int x, int y, int w, int h)
|
||||
{
|
||||
void Rect::set(int x, int y, int w, int h){
|
||||
if (this->x == x &&
|
||||
this->y == y &&
|
||||
width == w &&
|
||||
height == h)
|
||||
{
|
||||
height == h){
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -316,8 +285,7 @@ void Rect::set(int x, int y, int w, int h)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
const Rect &Rect::operator=(const Rect &o)
|
||||
{
|
||||
const Rect &Rect::operator=(const Rect &o){
|
||||
x = o.x;
|
||||
y = o.y;
|
||||
width = o.width;
|
||||
|
|
@ -328,8 +296,7 @@ const Rect &Rect::operator=(const Rect &o)
|
|||
return o;
|
||||
}
|
||||
|
||||
void Rect::empty()
|
||||
{
|
||||
void Rect::empty(){
|
||||
if (!(x || y || width || height))
|
||||
return;
|
||||
|
||||
|
|
@ -337,13 +304,11 @@ void Rect::empty()
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
bool Rect::isEmpty() const
|
||||
{
|
||||
bool Rect::isEmpty() const{
|
||||
return !(width && height);
|
||||
}
|
||||
|
||||
void Rect::setX(int value)
|
||||
{
|
||||
void Rect::setX(int value){
|
||||
if (x == value)
|
||||
return;
|
||||
|
||||
|
|
@ -351,8 +316,7 @@ void Rect::setX(int value)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
void Rect::setY(int value)
|
||||
{
|
||||
void Rect::setY(int value){
|
||||
if (y == value)
|
||||
return;
|
||||
|
||||
|
|
@ -360,8 +324,7 @@ void Rect::setY(int value)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
void Rect::setWidth(int value)
|
||||
{
|
||||
void Rect::setWidth(int value){
|
||||
if (width == value)
|
||||
return;
|
||||
|
||||
|
|
@ -369,8 +332,7 @@ void Rect::setWidth(int value)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
void Rect::setHeight(int value)
|
||||
{
|
||||
void Rect::setHeight(int value){
|
||||
if (height == value)
|
||||
return;
|
||||
|
||||
|
|
@ -378,21 +340,18 @@ void Rect::setHeight(int value)
|
|||
valueChanged();
|
||||
}
|
||||
|
||||
int Rect::serialSize() const
|
||||
{
|
||||
int Rect::serialSize() const{
|
||||
return 4 * 4;
|
||||
}
|
||||
|
||||
void Rect::serialize(char *buffer) const
|
||||
{
|
||||
void Rect::serialize(char *buffer) const{
|
||||
writeInt32(&buffer, x);
|
||||
writeInt32(&buffer, y);
|
||||
writeInt32(&buffer, width);
|
||||
writeInt32(&buffer, height);
|
||||
}
|
||||
|
||||
Rect *Rect::deserialize(const char *data, int len)
|
||||
{
|
||||
Rect *Rect::deserialize(const char *data, int len){
|
||||
if (len != 16)
|
||||
throw Exception(Exception::ArgumentError, "Rect: Serialized data invalid");
|
||||
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@
|
|||
#include <iconv.h>
|
||||
#endif
|
||||
|
||||
struct SDLRWIoContext
|
||||
{
|
||||
struct SDLRWIoContext{
|
||||
SDL_IOStream *ops;
|
||||
std::string filename;
|
||||
|
||||
|
|
@ -58,8 +57,7 @@ struct SDLRWIoContext
|
|||
"Failed to open file: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
~SDLRWIoContext()
|
||||
{
|
||||
~SDLRWIoContext(){
|
||||
SDL_CloseIO(ops);
|
||||
}
|
||||
};
|
||||
|
|
@ -233,10 +231,7 @@ static int SDL_RWopsCloseFree(void *userdata)
|
|||
* or the full string if srcN == -1. Never writes more
|
||||
* than dstMax, and guarantees dst to be null terminated.
|
||||
* Returns copied bytes (minus terminating null) */
|
||||
static size_t
|
||||
strcpySafe(char *dst, const char *src,
|
||||
size_t dstMax, int srcN)
|
||||
{
|
||||
static size_t strcpySafe(char *dst, const char *src, size_t dstMax, int srcN){
|
||||
if (srcN < 0)
|
||||
srcN = strlen(src);
|
||||
|
||||
|
|
@ -265,11 +260,7 @@ static const char *findExt(const char *filename){
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
initReadOps(PHYSFS_File *handle,
|
||||
SDL_IOStream* &ops)
|
||||
//bool freeOnClose)
|
||||
{
|
||||
static void initReadOps(PHYSFS_File *handle, SDL_IOStream* &ops){
|
||||
SDL_IOStreamInterface iface;
|
||||
SDL_INIT_INTERFACE(&iface);
|
||||
|
||||
|
|
@ -309,8 +300,7 @@ struct FileSystemPrivate{
|
|||
bool havePathCache;
|
||||
};
|
||||
|
||||
FileSystem::FileSystem(bool allowSymlinks)
|
||||
{
|
||||
FileSystem::FileSystem(bool allowSymlinks){
|
||||
p = new FileSystemPrivate;
|
||||
p->havePathCache = false;
|
||||
|
||||
|
|
@ -331,8 +321,7 @@ FileSystem::~FileSystem(){
|
|||
|
||||
void FileSystem::addPath(const char *path){
|
||||
/* Try the normal mount first */
|
||||
if (!PHYSFS_mount(path, 0, 1))
|
||||
{
|
||||
if (!PHYSFS_mount(path, 0, 1)){
|
||||
/* If it didn't work, try mounting via a wrapped
|
||||
* SDL_IOStream */
|
||||
PHYSFS_Io *io = createSDLRWIo(path);
|
||||
|
|
@ -359,8 +348,7 @@ struct CacheEnumData{
|
|||
#endif
|
||||
}
|
||||
|
||||
~CacheEnumData()
|
||||
{
|
||||
~CacheEnumData(){
|
||||
#ifdef OS_OSX
|
||||
iconv_close(nfd2nfc);
|
||||
#endif
|
||||
|
|
@ -622,10 +610,7 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename){
|
|||
throw Exception(Exception::NoFileError, "%s", filename);
|
||||
}
|
||||
|
||||
void FileSystem::openReadRaw(SDL_IOStream* &stream,
|
||||
const char *filename)
|
||||
//bool freeOnClose)
|
||||
{
|
||||
void FileSystem::openReadRaw(SDL_IOStream* &stream, const char *filename){
|
||||
PHYSFS_File *handle = PHYSFS_openRead(filename);
|
||||
if (!handle)
|
||||
throw Exception(Exception::NoFileError, "%s", filename);
|
||||
|
|
|
|||
|
|
@ -26,28 +26,23 @@
|
|||
|
||||
#include "gl-fun.h"
|
||||
|
||||
struct GLDebugLoggerPrivate
|
||||
{
|
||||
struct GLDebugLoggerPrivate{
|
||||
std::ostream *stream;
|
||||
time_t timestamp;
|
||||
GLDebugLoggerPrivate(const char *logFilename)
|
||||
{
|
||||
GLDebugLoggerPrivate(const char *logFilename){
|
||||
(void) logFilename;
|
||||
|
||||
stream = &std::clog;
|
||||
}
|
||||
|
||||
~GLDebugLoggerPrivate()
|
||||
{
|
||||
}
|
||||
~GLDebugLoggerPrivate(){}
|
||||
|
||||
void writeTimestamp(){
|
||||
time(×tamp);
|
||||
*stream << "[GLDEBUG " << ctime(×tamp) << "]";
|
||||
}
|
||||
|
||||
void writeLine(const char *line)
|
||||
{
|
||||
void writeLine(const char *line){
|
||||
*stream << line << "\n";
|
||||
stream->flush();
|
||||
}
|
||||
|
|
@ -76,8 +71,7 @@ static void APIENTRY arbDebugFunc(GLenum source,
|
|||
p->writeLine(message);
|
||||
}
|
||||
|
||||
GLDebugLogger::GLDebugLogger(const char *filename)
|
||||
{
|
||||
GLDebugLogger::GLDebugLogger(const char *filename){
|
||||
p = new GLDebugLoggerPrivate(filename);
|
||||
|
||||
if (gl.DebugMessageCallback)
|
||||
|
|
@ -86,7 +80,6 @@ GLDebugLogger::GLDebugLogger(const char *filename)
|
|||
Debug() << "DebugLogger: no debug extensions found";
|
||||
}
|
||||
|
||||
GLDebugLogger::~GLDebugLogger()
|
||||
{
|
||||
GLDebugLogger::~GLDebugLogger(){
|
||||
delete p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
struct GLDebugLoggerPrivate;
|
||||
|
||||
class GLDebugLogger
|
||||
{
|
||||
class GLDebugLogger{
|
||||
public:
|
||||
GLDebugLogger(const char *filename = 0);
|
||||
~GLDebugLogger();
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ GLFunctions gl;
|
|||
|
||||
typedef const GLubyte* (APIENTRYP _PFNGLGETSTRINGIPROC) (GLenum, GLuint);
|
||||
|
||||
static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet<std::string> &out)
|
||||
{
|
||||
static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet<std::string> &out){
|
||||
_PFNGLGETSTRINGIPROC GetStringi =
|
||||
(_PFNGLGETSTRINGIPROC) SDL_GL_GetProcAddress("glGetStringi");
|
||||
|
||||
|
|
@ -43,8 +42,7 @@ static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet<std:
|
|||
out.insert((const char*) GetStringi(GL_EXTENSIONS, i));
|
||||
}
|
||||
|
||||
static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::string> &out)
|
||||
{
|
||||
static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::string> &out){
|
||||
const char *ext = (const char*) GetString(GL_EXTENSIONS);
|
||||
|
||||
if (!ext)
|
||||
|
|
@ -53,8 +51,7 @@ static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::s
|
|||
char buffer[0x100];
|
||||
size_t bufferI;
|
||||
|
||||
while (*ext)
|
||||
{
|
||||
while (*ext){
|
||||
bufferI = 0;
|
||||
while (*ext && *ext != ' ')
|
||||
buffer[bufferI++] = *ext++;
|
||||
|
|
@ -74,8 +71,7 @@ static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet<std::s
|
|||
#define EXC(msg) \
|
||||
Exception(Exception::MKXPError, "%s", msg)
|
||||
|
||||
void initGLFunctions()
|
||||
{
|
||||
void initGLFunctions(){
|
||||
#define EXT_SUFFIX ""
|
||||
GL_20_FUN;
|
||||
|
||||
|
|
@ -87,8 +83,7 @@ void initGLFunctions()
|
|||
|
||||
bool gles = false;
|
||||
|
||||
if (!strncmp(ver, glesPrefix, glesPrefixN))
|
||||
{
|
||||
if (!strncmp(ver, glesPrefix, glesPrefixN)){
|
||||
gles = true;
|
||||
gl.glsles = true;
|
||||
|
||||
|
|
@ -101,8 +96,7 @@ void initGLFunctions()
|
|||
if (glMajor < 2)
|
||||
throw EXC("At least OpenGL (ES) 2.0 is required");
|
||||
|
||||
if (gles)
|
||||
{
|
||||
if (gles){
|
||||
GL_ES_FUN;
|
||||
}
|
||||
|
||||
|
|
@ -116,69 +110,58 @@ void initGLFunctions()
|
|||
#define HAVE_EXT(_ext) ext.contains("GL_" #_ext)
|
||||
|
||||
/* FBO entrypoints */
|
||||
if (glMajor >= 3 || HAVE_EXT(ARB_framebuffer_object))
|
||||
{
|
||||
if (glMajor >= 3 || HAVE_EXT(ARB_framebuffer_object)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX ""
|
||||
GL_FBO_FUN;
|
||||
GL_FBO_BLIT_FUN;
|
||||
}
|
||||
else if (gles && glMajor == 2)
|
||||
{
|
||||
else if (gles && glMajor == 2){
|
||||
GL_FBO_FUN;
|
||||
}
|
||||
else if (HAVE_EXT(EXT_framebuffer_object))
|
||||
{
|
||||
else if (HAVE_EXT(EXT_framebuffer_object)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX "EXT"
|
||||
GL_FBO_FUN;
|
||||
|
||||
if (HAVE_EXT(EXT_framebuffer_blit))
|
||||
{
|
||||
if (HAVE_EXT(EXT_framebuffer_blit)){
|
||||
GL_FBO_BLIT_FUN;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
throw EXC("No FBO support available");
|
||||
}
|
||||
|
||||
/* VAO entrypoints */
|
||||
if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3)
|
||||
{
|
||||
if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX ""
|
||||
GL_VAO_FUN;
|
||||
}
|
||||
else if (HAVE_EXT(APPLE_vertex_array_object))
|
||||
{
|
||||
else if (HAVE_EXT(APPLE_vertex_array_object)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX "APPLE"
|
||||
GL_VAO_FUN;
|
||||
}
|
||||
else if (HAVE_EXT(OES_vertex_array_object))
|
||||
{
|
||||
else if (HAVE_EXT(OES_vertex_array_object)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX "OES"
|
||||
GL_VAO_FUN;
|
||||
}
|
||||
|
||||
/* Debug callback entrypoints */
|
||||
if (HAVE_EXT(KHR_debug))
|
||||
{
|
||||
if (HAVE_EXT(KHR_debug)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX ""
|
||||
GL_DEBUG_KHR_FUN;
|
||||
}
|
||||
else if (HAVE_EXT(ARB_debug_output))
|
||||
{
|
||||
else if (HAVE_EXT(ARB_debug_output)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX "ARB"
|
||||
GL_DEBUG_KHR_FUN;
|
||||
}
|
||||
|
||||
if (HAVE_EXT(GREMEDY_string_marker))
|
||||
{
|
||||
if (HAVE_EXT(GREMEDY_string_marker)){
|
||||
#undef EXT_SUFFIX
|
||||
#define EXT_SUFFIX "GREMEDY"
|
||||
GL_GREMEMDY_FUN;
|
||||
|
|
|
|||
|
|
@ -207,8 +207,7 @@ typedef void (APIENTRYP _PFNGLRELEASESHADERCOMPILERPROC) (void);
|
|||
GL_FUN(StringMarker, _PFNGLSTRINGMARKERPROC)
|
||||
|
||||
|
||||
struct GLFunctions
|
||||
{
|
||||
struct GLFunctions{
|
||||
#define GL_FUN(name, type) type name;
|
||||
|
||||
GL_20_FUN
|
||||
|
|
|
|||
|
|
@ -73,3 +73,4 @@ void blitEnd();
|
|||
}
|
||||
|
||||
#endif // GLMETA_H
|
||||
|
||||
|
|
|
|||
|
|
@ -49,140 +49,115 @@ struct ID \
|
|||
};
|
||||
|
||||
/* 2D Texture */
|
||||
namespace TEX
|
||||
{
|
||||
namespace TEX{
|
||||
DEF_GL_ID
|
||||
|
||||
inline ID gen()
|
||||
{
|
||||
inline ID gen(){
|
||||
ID id;
|
||||
gl.GenTextures(1, &id.gl);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static inline void del(ID id)
|
||||
{
|
||||
static inline void del(ID id){
|
||||
gl.DeleteTextures(1, &id.gl);
|
||||
}
|
||||
|
||||
static inline void bind(ID id)
|
||||
{
|
||||
static inline void bind(ID id){
|
||||
gl.BindTexture(GL_TEXTURE_2D, id.gl);
|
||||
}
|
||||
|
||||
static inline void unbind()
|
||||
{
|
||||
static inline void unbind(){
|
||||
bind(ID(0));
|
||||
}
|
||||
|
||||
static inline void uploadImage(GLsizei width, GLsizei height, const void *data, GLenum format)
|
||||
{
|
||||
static inline void uploadImage(GLsizei width, GLsizei height, const void *data, GLenum format){
|
||||
gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
|
||||
static inline void uploadSubImage(GLint x, GLint y, GLsizei width, GLsizei height, const void *data, GLenum format)
|
||||
{
|
||||
static inline void uploadSubImage(GLint x, GLint y, GLsizei width, GLsizei height, const void *data, GLenum format){
|
||||
gl.TexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, format, GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
|
||||
static inline void allocEmpty(GLsizei width, GLsizei height)
|
||||
{
|
||||
static inline void allocEmpty(GLsizei width, GLsizei height){
|
||||
gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
}
|
||||
|
||||
static inline void setRepeat(bool mode)
|
||||
{
|
||||
static inline void setRepeat(bool mode){
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode ? GL_REPEAT : GL_CLAMP_TO_EDGE);
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode ? GL_REPEAT : GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
static inline void setSmooth(bool mode)
|
||||
{
|
||||
static inline void setSmooth(bool mode){
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode ? GL_LINEAR : GL_NEAREST);
|
||||
gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
/* Framebuffer Object */
|
||||
namespace FBO
|
||||
{
|
||||
namespace FBO{
|
||||
DEF_GL_ID
|
||||
|
||||
inline ID gen()
|
||||
{
|
||||
inline ID gen(){
|
||||
ID id;
|
||||
gl.GenFramebuffers(1, &id.gl);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static inline void del(ID id)
|
||||
{
|
||||
static inline void del(ID id){
|
||||
gl.DeleteFramebuffers(1, &id.gl);
|
||||
}
|
||||
|
||||
static inline void bind(ID id)
|
||||
{
|
||||
static inline void bind(ID id){
|
||||
gl.BindFramebuffer(GL_FRAMEBUFFER, id.gl);
|
||||
}
|
||||
|
||||
static inline void unbind()
|
||||
{
|
||||
static inline void unbind(){
|
||||
bind(ID(0));
|
||||
}
|
||||
|
||||
static inline void setTarget(TEX::ID target, unsigned colorAttach = 0)
|
||||
{
|
||||
static inline void setTarget(TEX::ID target, unsigned colorAttach = 0){
|
||||
gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0);
|
||||
}
|
||||
|
||||
static inline void clear()
|
||||
{
|
||||
static inline void clear(){
|
||||
gl.Clear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
template<GLenum target>
|
||||
struct GenericBO
|
||||
{
|
||||
struct GenericBO{
|
||||
DEF_GL_ID
|
||||
|
||||
static inline ID gen()
|
||||
{
|
||||
static inline ID gen(){
|
||||
ID id;
|
||||
gl.GenBuffers(1, &id.gl);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static inline void del(ID id)
|
||||
{
|
||||
static inline void del(ID id){
|
||||
gl.DeleteBuffers(1, &id.gl);
|
||||
}
|
||||
|
||||
static inline void bind(ID id)
|
||||
{
|
||||
static inline void bind(ID id){
|
||||
gl.BindBuffer(target, id.gl);
|
||||
}
|
||||
|
||||
static inline void unbind()
|
||||
{
|
||||
static inline void unbind(){
|
||||
bind(ID(0));
|
||||
}
|
||||
|
||||
static inline void uploadData(GLsizeiptr size, const GLvoid *data, GLenum usage = GL_STATIC_DRAW)
|
||||
{
|
||||
static inline void uploadData(GLsizeiptr size, const GLvoid *data, GLenum usage = GL_STATIC_DRAW){
|
||||
gl.BufferData(target, size, data, usage);
|
||||
}
|
||||
|
||||
static inline void uploadSubData(GLintptr offset, GLsizeiptr size, const GLvoid *data)
|
||||
{
|
||||
static inline void uploadSubData(GLintptr offset, GLsizeiptr size, const GLvoid *data){
|
||||
gl.BufferSubData(target, offset, size, data);
|
||||
}
|
||||
|
||||
static inline void allocEmpty(GLsizeiptr size, GLenum usage = GL_STATIC_DRAW)
|
||||
{
|
||||
static inline void allocEmpty(GLsizeiptr size, GLenum usage = GL_STATIC_DRAW){
|
||||
uploadData(size, 0, usage);
|
||||
}
|
||||
};
|
||||
|
|
@ -197,8 +172,7 @@ typedef struct GenericBO<GL_ELEMENT_ARRAY_BUFFER> IBO;
|
|||
|
||||
/* Convenience struct wrapping a framebuffer
|
||||
* and a 2D texture as its target */
|
||||
struct TEXFBO
|
||||
{
|
||||
struct TEXFBO{
|
||||
TEX::ID tex;
|
||||
FBO::ID fbo;
|
||||
int width, height;
|
||||
|
|
@ -207,13 +181,11 @@ struct TEXFBO
|
|||
: tex(0), fbo(0), width(0), height(0)
|
||||
{}
|
||||
|
||||
bool operator==(const TEXFBO &other) const
|
||||
{
|
||||
bool operator==(const TEXFBO &other) const{
|
||||
return (tex == other.tex) && (fbo == other.fbo);
|
||||
}
|
||||
|
||||
static inline void init(TEXFBO &obj)
|
||||
{
|
||||
static inline void init(TEXFBO &obj){
|
||||
obj.tex = TEX::gen();
|
||||
obj.fbo = FBO::gen();
|
||||
TEX::bind(obj.tex);
|
||||
|
|
@ -221,28 +193,24 @@ struct TEXFBO
|
|||
TEX::setSmooth(false);
|
||||
}
|
||||
|
||||
static inline void allocEmpty(TEXFBO &obj, int width, int height)
|
||||
{
|
||||
static inline void allocEmpty(TEXFBO &obj, int width, int height){
|
||||
TEX::bind(obj.tex);
|
||||
TEX::allocEmpty(width, height);
|
||||
obj.width = width;
|
||||
obj.height = height;
|
||||
}
|
||||
|
||||
static inline void linkFBO(TEXFBO &obj)
|
||||
{
|
||||
static inline void linkFBO(TEXFBO &obj){
|
||||
FBO::bind(obj.fbo);
|
||||
FBO::setTarget(obj.tex);
|
||||
}
|
||||
|
||||
static inline void fini(TEXFBO &obj)
|
||||
{
|
||||
static inline void fini(TEXFBO &obj){
|
||||
FBO::del(obj.fbo);
|
||||
TEX::del(obj.tex);
|
||||
}
|
||||
|
||||
static inline void clear(TEXFBO &obj)
|
||||
{
|
||||
static inline void clear(TEXFBO &obj){
|
||||
obj.tex = TEX::ID(0);
|
||||
obj.fbo = FBO::ID(0);
|
||||
obj.width = obj.height = 0;
|
||||
|
|
|
|||
|
|
@ -30,15 +30,12 @@
|
|||
struct Config;
|
||||
|
||||
template<typename T>
|
||||
struct GLProperty
|
||||
{
|
||||
~GLProperty()
|
||||
{
|
||||
struct GLProperty{
|
||||
~GLProperty(){
|
||||
assert(stack.size() == 0);
|
||||
}
|
||||
|
||||
void init(const T &value)
|
||||
{
|
||||
void init(const T &value){
|
||||
current = value;
|
||||
apply(value);
|
||||
}
|
||||
|
|
@ -46,22 +43,19 @@ struct GLProperty
|
|||
void push() { stack.push(current); }
|
||||
void pop() { if (!stack.empty()) { set(stack.top()); stack.pop(); } }
|
||||
const T &get() { return current; }
|
||||
void set(const T &value)
|
||||
{
|
||||
void set(const T &value){
|
||||
if (value == current)
|
||||
return;
|
||||
|
||||
init(value);
|
||||
}
|
||||
|
||||
void pushSet(const T &value)
|
||||
{
|
||||
void pushSet(const T &value){
|
||||
push();
|
||||
set(value);
|
||||
}
|
||||
|
||||
void refresh()
|
||||
{
|
||||
void refresh(){
|
||||
apply(current);
|
||||
}
|
||||
private:
|
||||
|
|
@ -72,13 +66,11 @@ private:
|
|||
};
|
||||
|
||||
|
||||
class GLClearColor : public GLProperty<Vec4>
|
||||
{
|
||||
class GLClearColor : public GLProperty<Vec4>{
|
||||
void apply(const Vec4 &);
|
||||
};
|
||||
|
||||
class GLScissorBox : public GLProperty<IntRect>
|
||||
{
|
||||
class GLScissorBox : public GLProperty<IntRect>{
|
||||
public:
|
||||
/* Sets the intersection of the current box with value */
|
||||
void setIntersect(const IntRect &value);
|
||||
|
|
@ -87,13 +79,11 @@ private:
|
|||
void apply(const IntRect &value);
|
||||
};
|
||||
|
||||
class GLScissorTest : public GLProperty<bool>
|
||||
{
|
||||
class GLScissorTest : public GLProperty<bool>{
|
||||
void apply(const bool &value);
|
||||
};
|
||||
|
||||
class GLBlendMode : public GLProperty<BlendType>
|
||||
{
|
||||
class GLBlendMode : public GLProperty<BlendType>{
|
||||
void apply(const BlendType &value);
|
||||
};
|
||||
|
||||
|
|
@ -102,19 +92,16 @@ class GLBlend : public GLProperty<bool>
|
|||
void apply(const bool &value);
|
||||
};
|
||||
|
||||
class GLViewport : public GLProperty<IntRect>
|
||||
{
|
||||
class GLViewport : public GLProperty<IntRect>{
|
||||
void apply(const IntRect &value);
|
||||
};
|
||||
|
||||
class GLProgram : public GLProperty<unsigned int> /* GLuint */
|
||||
{
|
||||
class GLProgram : public GLProperty<unsigned int> /* GLuint */{
|
||||
void apply(const unsigned int &value);
|
||||
};
|
||||
|
||||
|
||||
class GLState
|
||||
{
|
||||
class GLState{
|
||||
public:
|
||||
GLClearColor clearColor;
|
||||
GLScissorBox scissorBox;
|
||||
|
|
@ -124,8 +111,7 @@ public:
|
|||
GLViewport viewport;
|
||||
GLProgram program;
|
||||
|
||||
struct Caps
|
||||
{
|
||||
struct Caps{
|
||||
int maxTexSize;
|
||||
|
||||
Caps();
|
||||
|
|
|
|||
|
|
@ -894,10 +894,6 @@ void Graphics::resizeScreen(int width, int height){
|
|||
shState->eThread().requestWindowResize(width, height);
|
||||
}
|
||||
|
||||
void Graphics::playMovie(const char *filename){
|
||||
Debug() << "[playMovie] Graphics.playMovie(" << filename << ") not implemented";
|
||||
}
|
||||
|
||||
DEF_ATTR_RD_SIMPLE(Graphics, Brightness, int, p->brightness)
|
||||
|
||||
void Graphics::setBrightness(int value){
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ public:
|
|||
int width() const;
|
||||
int height() const;
|
||||
void resizeScreen(int width, int height);
|
||||
void playMovie(const char *filename);
|
||||
|
||||
void reset();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@
|
|||
|
||||
#include "tileatlas.h"
|
||||
|
||||
namespace TileAtlas
|
||||
{
|
||||
namespace TileAtlas{
|
||||
|
||||
/* A Column represents a Rect
|
||||
* with undefined width */
|
||||
struct Column
|
||||
{
|
||||
struct Column{
|
||||
int x, y, h;
|
||||
|
||||
Column(int x, int y, int h)
|
||||
|
|
|
|||
|
|
@ -39,28 +39,24 @@
|
|||
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
static inline int
|
||||
wrap(int value, int range){
|
||||
static inline int wrap(int value, int range){
|
||||
int res = value % range;
|
||||
return res < 0 ? res + range : res;
|
||||
}
|
||||
|
||||
static inline Vec2i
|
||||
wrap(const Vec2i &value, int range){
|
||||
static inline Vec2i wrap(const Vec2i &value, int range){
|
||||
return Vec2i(wrap(value.x, range),
|
||||
wrap(value.y, range));
|
||||
}
|
||||
|
||||
static inline int16_t
|
||||
tableGetWrapped(const Table &t, int x, int y, int z = 0){
|
||||
static inline int16_t tableGetWrapped(const Table &t, int x, int y, int z = 0){
|
||||
return t.get(wrap(x, t.xSize()),
|
||||
wrap(y, t.ySize()),
|
||||
z);
|
||||
}
|
||||
|
||||
/* Calculate the tile x/y on which this pixel x/y lies */
|
||||
static inline Vec2i
|
||||
getTilePos(const Vec2i &pixelPos){
|
||||
static inline Vec2i getTilePos(const Vec2i &pixelPos){
|
||||
/* Round the pixel position down to the nearest top left
|
||||
* tile boundary, by masking off the lower 5 bits (2^5 = 32).
|
||||
* Then divide by 32 to convert into tile units. */
|
||||
|
|
@ -209,8 +205,7 @@ private:
|
|||
return;
|
||||
|
||||
for (int x = 0; x < viewp.w; ++x)
|
||||
for (int y = 0; y < viewp.h; ++y)
|
||||
{
|
||||
for (int y = 0; y < viewp.h; ++y){
|
||||
Vec4 color;
|
||||
|
||||
if (!sampleFlashColor(color, x+viewp.x, y+viewp.y))
|
||||
|
|
|
|||
|
|
@ -1171,3 +1171,4 @@ void Tilemap::releaseResources(){
|
|||
delete p;
|
||||
atProxy.p = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -323,14 +323,12 @@ struct WindowPrivate {
|
|||
backgroundVert.vert = &vert[i];
|
||||
|
||||
/* Background */
|
||||
if (bgStretch)
|
||||
{
|
||||
if (bgStretch){
|
||||
Quad::setTexRect(&vert[i*4], backgroundSrc);
|
||||
Quad::setPosRect(&vert[i*4], bgRect);
|
||||
i += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
i += TileQuads::build(backgroundSrc, bgRect, &vert[i*4]);
|
||||
}
|
||||
|
||||
|
|
@ -372,13 +370,11 @@ struct WindowPrivate {
|
|||
int newH = baseTex.height;
|
||||
bool resizeNeeded = false;
|
||||
|
||||
if (size.x > baseTex.width)
|
||||
{
|
||||
if (size.x > baseTex.width){
|
||||
newW = findNextPow2(size.x);
|
||||
resizeNeeded = true;
|
||||
}
|
||||
if (size.y > baseTex.height)
|
||||
{
|
||||
if (size.y > baseTex.height){
|
||||
newH = findNextPow2(size.y);
|
||||
resizeNeeded = true;
|
||||
}
|
||||
|
|
@ -438,8 +434,7 @@ struct WindowPrivate {
|
|||
Vertex *vert = controlsQuadArray.vertices.data();
|
||||
|
||||
/* Cursor */
|
||||
if (!cursorRect->isEmpty())
|
||||
{
|
||||
if (!cursorRect->isEmpty()){
|
||||
/* Effective cursor rect has 16 xy offset to window */
|
||||
IntRect effectRect(cursorRect->x+16, cursorRect->y+16,
|
||||
cursorRect->width, cursorRect->height);
|
||||
|
|
@ -458,8 +453,7 @@ struct WindowPrivate {
|
|||
scrollArrows.t = IntRect(scroll.x, 4, 16, 8);
|
||||
scrollArrows.b = IntRect(scroll.x, size.y - 12, 16, 8);
|
||||
|
||||
if (contents)
|
||||
{
|
||||
if (contents){
|
||||
if (contentsOffset.x > 0)
|
||||
i += Quad::setTexPosRect(&vert[i*4], scrollArrowSrc.l, scrollArrows.l);
|
||||
|
||||
|
|
@ -474,8 +468,7 @@ struct WindowPrivate {
|
|||
}
|
||||
|
||||
/* Pause animation */
|
||||
if (pause)
|
||||
{
|
||||
if (pause){
|
||||
pauseAniVert.vert = &vert[i*4];
|
||||
i += Quad::setTexPosRect(&vert[i*4], pauseAniSrc[pauseAniQuad[pauseAniQuadIdx]],
|
||||
FloatRect((size.x - 16) / 2, size.y - 16, 16, 16));
|
||||
|
|
@ -491,15 +484,13 @@ struct WindowPrivate {
|
|||
|
||||
bool updateBaseQuadArray = false;
|
||||
|
||||
if (baseVertDirty)
|
||||
{
|
||||
if (baseVertDirty){
|
||||
buildBaseVert();
|
||||
baseVertDirty = false;
|
||||
updateBaseQuadArray = true;
|
||||
}
|
||||
|
||||
if (opacityDirty)
|
||||
{
|
||||
if (opacityDirty){
|
||||
updateBaseAlpha();
|
||||
opacityDirty = false;
|
||||
updateBaseQuadArray = true;
|
||||
|
|
@ -512,12 +503,10 @@ struct WindowPrivate {
|
|||
* and then draw this texture instead of the quad array */
|
||||
useBaseTex = opacity < 255;
|
||||
|
||||
if (useBaseTex)
|
||||
{
|
||||
if (useBaseTex){
|
||||
ensureBaseTexReady();
|
||||
|
||||
if (baseTexDirty)
|
||||
{
|
||||
if (baseTexDirty){
|
||||
redrawBaseTex();
|
||||
baseTexDirty = false;
|
||||
}
|
||||
|
|
@ -536,15 +525,12 @@ struct WindowPrivate {
|
|||
shader.applyViewportProj();
|
||||
shader.setTranslation(position + sceneOffset);
|
||||
|
||||
if (useBaseTex)
|
||||
{
|
||||
if (useBaseTex){
|
||||
shader.setTexSize(Vec2i(baseTex.width, baseTex.height));
|
||||
|
||||
TEX::bind(baseTex.tex);
|
||||
baseTexQuad.draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
}else{
|
||||
windowskin->bindTex(shader);
|
||||
TEX::setSmooth(true);
|
||||
|
||||
|
|
@ -561,8 +547,7 @@ struct WindowPrivate {
|
|||
if (size == Vec2i(0, 0))
|
||||
return;
|
||||
|
||||
if (controlsVertDirty)
|
||||
{
|
||||
if (controlsVertDirty){
|
||||
buildControlsVert();
|
||||
updateControls();
|
||||
controlsVertDirty = false;
|
||||
|
|
@ -582,8 +567,7 @@ struct WindowPrivate {
|
|||
shader.bind();
|
||||
shader.applyViewportProj();
|
||||
|
||||
if (!nullOrDisposed(windowskin))
|
||||
{
|
||||
if (!nullOrDisposed(windowskin)){
|
||||
shader.setTranslation(efPos);
|
||||
|
||||
/* Draw arrows / cursors */
|
||||
|
|
@ -595,8 +579,7 @@ struct WindowPrivate {
|
|||
TEX::setSmooth(false);
|
||||
}
|
||||
|
||||
if (!nullOrDisposed(contents))
|
||||
{
|
||||
if (!nullOrDisposed(contents)){
|
||||
/* Draw contents bitmap */
|
||||
glState.scissorBox.setIntersect(contentsRect);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue