mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
Школа такая поебота я не могу
This commit is contained in:
parent
9a074f8e82
commit
704c9b2f64
5 changed files with 59 additions and 110 deletions
|
|
@ -15,8 +15,18 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
# Debug stuff
|
||||
# i want die
|
||||
if(DEBUG)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -fno-omit-frame-pointer -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -fno-omit-frame-pointer -ggdb")
|
||||
if (MSVC)
|
||||
add_compile_options(/W4 /dynamicdeopt /Od /fsanitize /GS /guard /validate-charset)
|
||||
else()
|
||||
add_compile_options(-g3 -O0 -fno-omit-frame-pointer -ggdb -Wall)
|
||||
endif()
|
||||
else()
|
||||
# Optimization stuff
|
||||
if (MSVC)
|
||||
add_compile_options(/O2 /fp:fast /GA /GL /Gw Qpar /RTCu)
|
||||
else()
|
||||
add_compile_options(-0fast -ffast-math -fdevirtualize-speculatively -fspeculatively-call-stored-functions -fipa-pta -fdelete-null-pointer-checks -flimit-function-alignment)
|
||||
endif()
|
||||
endif()
|
||||
## Setup main source ##
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,9 @@
|
|||
#include "glstate.h"
|
||||
#include "quad.h"
|
||||
|
||||
namespace GLMeta
|
||||
{
|
||||
namespace GLMeta{
|
||||
|
||||
void subRectImageUpload(GLint srcW, GLint srcX, GLint srcY,
|
||||
GLint dstX, GLint dstY, GLsizei dstW, GLsizei dstH,
|
||||
SDL_Surface *src, GLenum format)
|
||||
{
|
||||
void subRectImageUpload(GLint srcW, GLint srcX, GLint srcY, GLint dstX, GLint dstY, GLsizei dstW, GLsizei dstH, SDL_Surface *src, GLenum format){
|
||||
if (gl.unpack_subimage){
|
||||
gl.PixelStorei(GL_UNPACK_ROW_LENGTH, srcW);
|
||||
gl.PixelStorei(GL_UNPACK_SKIP_PIXELS, srcX);
|
||||
|
|
@ -54,10 +50,8 @@ void subRectImageUpload(GLint srcW, GLint srcX, GLint srcY,
|
|||
}
|
||||
}
|
||||
|
||||
void subRectImageEnd()
|
||||
{
|
||||
if (gl.unpack_subimage)
|
||||
{
|
||||
void subRectImageEnd(){
|
||||
if (gl.unpack_subimage){
|
||||
gl.PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
gl.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
gl.PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||
|
|
@ -66,13 +60,11 @@ void subRectImageEnd()
|
|||
|
||||
#define HAVE_NATIVE_VAO false //gl.GenVertexArrays
|
||||
|
||||
static void vaoBindRes(VAO &vao)
|
||||
{
|
||||
static void vaoBindRes(VAO &vao){
|
||||
VBO::bind(vao.vbo);
|
||||
IBO::bind(vao.ibo);
|
||||
|
||||
for (size_t i = 0; i < vao.attrCount; ++i)
|
||||
{
|
||||
for (size_t i = 0; i < vao.attrCount; ++i){
|
||||
const VertexAttribute &va = vao.attr[i];
|
||||
|
||||
gl.EnableVertexAttribArray(va.index);
|
||||
|
|
@ -80,48 +72,39 @@ static void vaoBindRes(VAO &vao)
|
|||
}
|
||||
}
|
||||
|
||||
void vaoInit(VAO &vao, bool keepBound)
|
||||
{
|
||||
if (HAVE_NATIVE_VAO)
|
||||
{
|
||||
void vaoInit(VAO &vao, bool keepBound){
|
||||
if (HAVE_NATIVE_VAO){
|
||||
gl.GenVertexArrays(1, &vao.nativeVAO);
|
||||
gl.BindVertexArray(vao.nativeVAO);
|
||||
vaoBindRes(vao);
|
||||
if (!keepBound)
|
||||
gl.BindVertexArray(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keepBound)
|
||||
{
|
||||
else{
|
||||
if (keepBound){
|
||||
VBO::bind(vao.vbo);
|
||||
IBO::bind(vao.ibo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vaoFini(VAO &vao)
|
||||
{
|
||||
void vaoFini(VAO &vao){
|
||||
if (HAVE_NATIVE_VAO)
|
||||
gl.DeleteVertexArrays(1, &vao.nativeVAO);
|
||||
}
|
||||
|
||||
void vaoBind(VAO &vao)
|
||||
{
|
||||
void vaoBind(VAO &vao){
|
||||
if (HAVE_NATIVE_VAO)
|
||||
gl.BindVertexArray(vao.nativeVAO);
|
||||
else
|
||||
vaoBindRes(vao);
|
||||
}
|
||||
|
||||
void vaoUnbind(VAO &vao)
|
||||
{
|
||||
if (HAVE_NATIVE_VAO)
|
||||
{
|
||||
void vaoUnbind(VAO &vao){
|
||||
if (HAVE_NATIVE_VAO){
|
||||
gl.BindVertexArray(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
for (size_t i = 0; i < vao.attrCount; ++i)
|
||||
gl.DisableVertexAttribArray(vao.attr[i].index);
|
||||
|
||||
|
|
@ -132,14 +115,11 @@ void vaoUnbind(VAO &vao)
|
|||
|
||||
#define HAVE_NATIVE_BLIT false //gl.BlitFramebuffer
|
||||
|
||||
static void _blitBegin(FBO::ID fbo, const Vec2i &size)
|
||||
{
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
static void _blitBegin(FBO::ID fbo, const Vec2i &size){
|
||||
if (HAVE_NATIVE_BLIT){
|
||||
gl.BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo.gl);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
FBO::bind(fbo);
|
||||
glState.viewport.pushSet(IntRect(0, 0, size.x, size.y));
|
||||
|
||||
|
|
@ -150,45 +130,36 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
|
|||
}
|
||||
}
|
||||
|
||||
void blitBegin(TEXFBO &target)
|
||||
{
|
||||
void blitBegin(TEXFBO &target){
|
||||
_blitBegin(target.fbo, Vec2i(target.width, target.height));
|
||||
}
|
||||
|
||||
void blitBeginScreen(const Vec2i &size)
|
||||
{
|
||||
void blitBeginScreen(const Vec2i &size){
|
||||
_blitBegin(FBO::ID(0), size);
|
||||
}
|
||||
|
||||
void blitSource(TEXFBO &source)
|
||||
{
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
void blitSource(TEXFBO &source){
|
||||
if (HAVE_NATIVE_BLIT){
|
||||
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, source.fbo.gl);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
SimpleShader &shader = shState->shaders().simple;
|
||||
shader.setTexSize(Vec2i(source.width, source.height));
|
||||
TEX::bind(source.tex);
|
||||
}
|
||||
}
|
||||
|
||||
void blitRectangle(const IntRect &src, const Vec2i &dstPos)
|
||||
{
|
||||
void blitRectangle(const IntRect &src, const Vec2i &dstPos){
|
||||
blitRectangle(src, IntRect(dstPos.x, dstPos.y, src.w, src.h), false);
|
||||
}
|
||||
|
||||
void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
|
||||
{
|
||||
if (HAVE_NATIVE_BLIT)
|
||||
{
|
||||
void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth){
|
||||
if (HAVE_NATIVE_BLIT){
|
||||
gl.BlitFramebuffer(src.x, src.y, src.x+src.w, src.y+src.h,
|
||||
dst.x, dst.y, dst.x+dst.w, dst.y+dst.h,
|
||||
GL_COLOR_BUFFER_BIT, smooth ? GL_LINEAR : GL_NEAREST);
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
if (smooth)
|
||||
TEX::setSmooth(true);
|
||||
|
||||
|
|
@ -203,8 +174,7 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
|
|||
}
|
||||
}
|
||||
|
||||
void blitEnd()
|
||||
{
|
||||
void blitEnd(){
|
||||
if (!HAVE_NATIVE_BLIT)
|
||||
glState.viewport.pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,8 +258,7 @@ public:
|
|||
screenQuad.draw();
|
||||
}
|
||||
|
||||
if (flashEffect)
|
||||
{
|
||||
if (flashEffect){
|
||||
shader.setColor(f);
|
||||
screenQuad.draw();
|
||||
}
|
||||
|
|
@ -373,8 +372,7 @@ struct FPSLimiter{
|
|||
* relative to the ideal timestep */
|
||||
adj.idealDiff = diff - tpf + adj.idealDiff;
|
||||
|
||||
if (adj.resetFlag)
|
||||
{
|
||||
if (adj.resetFlag){
|
||||
adj.idealDiff = 0;
|
||||
adj.resetFlag = false;
|
||||
}
|
||||
|
|
@ -388,8 +386,7 @@ struct FPSLimiter{
|
|||
* of ticks behind the ideal timestep,
|
||||
* there's no choice but to skip frame(s)
|
||||
* to catch up */
|
||||
bool frameSkipRequired() const
|
||||
{
|
||||
bool frameSkipRequired() const{
|
||||
if (disabled)
|
||||
return false;
|
||||
|
||||
|
|
@ -405,15 +402,14 @@ private:
|
|||
req.tv_nsec = nsec % NS_PER_S;
|
||||
errno = 0;
|
||||
|
||||
while (nanosleep(&req, &req) == -1)
|
||||
{
|
||||
while (nanosleep(&req, &req) == -1){
|
||||
int err = errno;
|
||||
errno = 0;
|
||||
|
||||
if (err == EINTR)
|
||||
continue;
|
||||
|
||||
Debug() << "nanosleep failed. errno:" << err;
|
||||
Debug() << "[delayTicks] nanosleep failed. errno:" << err;
|
||||
SDL_Delay(ticks / tickFreqMS);
|
||||
break;
|
||||
}
|
||||
|
|
@ -577,8 +573,7 @@ struct GraphicsPrivate{
|
|||
}
|
||||
|
||||
void redrawScreen(){
|
||||
if (shState->oneshot().obscuredDirty)
|
||||
{
|
||||
if (shState->oneshot().obscuredDirty){
|
||||
TEX::bind(obscuredTex);
|
||||
TEX::uploadSubImage(0, 0, 640, 480, shState->oneshot().obscuredMap().data(), GL_LUMINANCE);
|
||||
shState->oneshot().obscuredDirty = false;
|
||||
|
|
@ -638,19 +633,15 @@ void Graphics::update(bool limitFps){
|
|||
return;
|
||||
|
||||
if (limitFps){
|
||||
if (p->fpsLimiter.frameSkipRequired())
|
||||
{
|
||||
if (p->threadData->config.frameSkip)
|
||||
{
|
||||
if (p->fpsLimiter.frameSkipRequired()){
|
||||
if (p->threadData->config.frameSkip){
|
||||
/* Skip frame */
|
||||
p->fpsLimiter.delay();
|
||||
++p->frameCount;
|
||||
p->threadData->ethread->notifyFrame();
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}else{
|
||||
/* Just reset frame adjust counter */
|
||||
p->fpsLimiter.resetFrameAdjust();
|
||||
}
|
||||
|
|
@ -676,10 +667,7 @@ void Graphics::freeze(){
|
|||
p->compositeToBuffer(p->frozenScene);
|
||||
}
|
||||
|
||||
void Graphics::transition(int duration,
|
||||
const char *filename,
|
||||
int vague)
|
||||
{
|
||||
void Graphics::transition(int duration, const char *filename, int vague){
|
||||
p->checkSyncLock();
|
||||
|
||||
if (!p->frozen)
|
||||
|
|
@ -824,8 +812,7 @@ void Graphics::fadeout(int duration){
|
|||
for (int i = duration-1; i > -1; --i){
|
||||
setBrightness(diff + (curr / duration) * i);
|
||||
|
||||
if (p->frozen)
|
||||
{
|
||||
if (p->frozen){
|
||||
GLMeta::blitBeginScreen(p->scSize);
|
||||
GLMeta::blitSource(p->frozenScene);
|
||||
|
||||
|
|
@ -836,8 +823,7 @@ void Graphics::fadeout(int duration){
|
|||
|
||||
p->swapGLBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
@ -852,8 +838,7 @@ void Graphics::fadein(int duration){
|
|||
for (int i = 1; i <= duration; ++i){
|
||||
setBrightness(curr + (diff / duration) * i);
|
||||
|
||||
if (p->frozen)
|
||||
{
|
||||
if (p->frozen){
|
||||
GLMeta::blitBeginScreen(p->scSize);
|
||||
GLMeta::blitSource(p->frozenScene);
|
||||
|
||||
|
|
@ -864,8 +849,7 @@ void Graphics::fadein(int duration){
|
|||
|
||||
p->swapGLBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
@ -912,7 +896,7 @@ void Graphics::resizeScreen(int width, int height){
|
|||
}
|
||||
|
||||
void Graphics::playMovie(const char *filename){
|
||||
Debug() << "Graphics.playMovie(" << filename << ") not implemented";
|
||||
Debug() << "[playMovie] Graphics.playMovie(" << filename << ") not implemented";
|
||||
}
|
||||
|
||||
DEF_ATTR_RD_SIMPLE(Graphics, Brightness, int, p->brightness)
|
||||
|
|
@ -1022,3 +1006,4 @@ void Graphics::remDisposable(Disposable *d){
|
|||
const TEX::ID &Graphics::obscuredTex() const{
|
||||
return p->obscuredTex;
|
||||
}
|
||||
|
||||
|
|
|
|||
19
src/main.cpp
19
src/main.cpp
|
|
@ -280,19 +280,8 @@ int main(int argc, char *argv[]){
|
|||
if (conf.windowTitle.empty())
|
||||
conf.windowTitle = conf.game.title;
|
||||
|
||||
//IMG_Init() and IMG_Quit() are no longer necessary. If an image format requires dynamically loading a support library, that will be done automatically.
|
||||
//int imgFlags = IMG_INIT_PNG;
|
||||
//if (IMG_Init(imgFlags) != imgFlags)
|
||||
//{
|
||||
// showInitError(std::string("Error initializing SDL_image: ") + SDL_GetError());
|
||||
// SDL_Quit();
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
if (TTF_Init() < 0){
|
||||
showInitError(std::string("Error initializing SDL_ttf: ") + SDL_GetError());
|
||||
//IMG_Quit();
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
|
|
@ -301,25 +290,23 @@ int main(int argc, char *argv[]){
|
|||
if (Sound_Init() == 0){
|
||||
showInitError(std::string("Error initializing SDL_sound: ") + Sound_GetError());
|
||||
TTF_Quit();
|
||||
//IMG_Quit();
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_Window *win;
|
||||
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS; //| SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS;
|
||||
|
||||
// #ifdef __APPLE__
|
||||
// winFlags |= SDL_WINDOW_RESIZABLE;
|
||||
// #endif
|
||||
|
||||
//SDL_CreateWindow() has been simplified and no longer takes a window position.
|
||||
|
||||
win = SDL_CreateWindow(conf.windowTitle.c_str(), conf.defScreenW, conf.defScreenH, winFlags);
|
||||
if (conf.fullscreen)
|
||||
SDL_SetWindowFullscreen(win, true);
|
||||
|
||||
|
||||
if (!win){
|
||||
showInitError(std::string("Error creating window: ") + SDL_GetError());
|
||||
return 0;
|
||||
|
|
@ -415,8 +402,6 @@ int main(int argc, char *argv[]){
|
|||
|
||||
Sound_Quit();
|
||||
TTF_Quit();
|
||||
//IMG_Init() and IMG_Quit() are no longer necessary. If an image format requires dynamically loading a support library, that will be done automatically.
|
||||
//IMG_Quit();
|
||||
SDL_Quit();
|
||||
|
||||
#ifdef STEAM
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@
|
|||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
class Transform
|
||||
{
|
||||
class Transform{
|
||||
public:
|
||||
Transform()
|
||||
: scale(1, 1),
|
||||
|
|
|
|||
Loading…
Reference in a new issue