_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include "shaders.h"
#include <stdint.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_opengl_glext.h>
#include <stdlib.h>
#include <regex>
#include <iostream>
#include <fstream>
#include "stratagus.h"
#include "parameters.h"
#include "video.h"
#include "game.h"
#include "iolib.h"
#include "script.h"
#include "./shaders/noshader.glsl"
#include "./shaders/crt.glsl"
#include "./shaders/vhs.glsl"
#include "./shaders/xbrz.glsl"
Macros | |
#define | CCONV __stdcall |
#define | canUseShaders (shadersLoaded == 1) |
#define | shadersAreInitialized (shadersLoaded != -1) |
#define | setCanUseShaders(x) (shadersLoaded = (x ? 1 : 0)) |
#define | COMPILE_BUILTIN_SHADER(name) |
Functions | |
void (CCONV *lazyGlBegin)(GLenum) | |
static std::regex | invalidQuoteReplaceRegex ("\"([a-zA-Z0-9 -\\.]+)\"") |
static GLuint | compileShader (const char *source, GLuint shaderType) |
static GLuint | compileProgramSource (std::string source) |
static GLuint | compileProgram (std::string shaderFile) |
static int | loadShaders () |
static bool | RenderWithShaderInternal (SDL_Renderer *renderer, SDL_Window *win, SDL_Texture *backBuffer) |
bool | RenderWithShader (SDL_Renderer *renderer, SDL_Window *win, SDL_Texture *backBuffer) |
static int | CclGetShader (lua_State *l) |
static int | CclSetShader (lua_State *l) |
static int | CclGetShaderNames (lua_State *l) |
bool | LoadShaderExtensions () |
Variables | |
PFNGLCREATESHADERPROC | glCreateShader |
PFNGLSHADERSOURCEPROC | glShaderSource |
PFNGLCOMPILESHADERPROC | glCompileShader |
PFNGLGETSHADERIVPROC | glGetShaderiv |
PFNGLGETSHADERINFOLOGPROC | glGetShaderInfoLog |
PFNGLDELETESHADERPROC | glDeleteShader |
PFNGLATTACHSHADERPROC | glAttachShader |
PFNGLCREATEPROGRAMPROC | glCreateProgram |
PFNGLLINKPROGRAMPROC | glLinkProgram |
PFNGLVALIDATEPROGRAMPROC | glValidateProgram |
PFNGLGETPROGRAMIVPROC | glGetProgramiv |
PFNGLGETPROGRAMINFOLOGPROC | glGetProgramInfoLog |
PFNGLUSEPROGRAMPROC | glUseProgram |
PFNGLGETUNIFORMLOCATIONPROC | glGetUniformLocation |
PFNGLUNIFORM1IPROC | glUniform1i |
PFNGLUNIFORM1FPROC | glUniform1f |
PFNGLUNIFORM2FPROC | glUniform2f |
PFNGLUNIFORMMATRIX4FVPROC | glUniformMatrix4fv |
PFNGLGETATTRIBLOCATIONPROC | glGetAttribLocation |
PFNGLVERTEXATTRIB4FPROC | glVertexAttrib4f |
GLfloat | |
GLint GLfloat | GLint |
GLint GLfloat | GLsizei |
GLdouble | |
static const int | MAX_SHADERS = 128 |
static GLuint | shaderPrograms [MAX_SHADERS+1] = { (GLuint) 0 } |
static const char * | shaderNames [MAX_SHADERS+1] = { NULL } |
static char | shadersLoaded = -1 |
static int | currentShaderIdx = 0 |
const char * | none |
const char * | CRT |
const char * | VHS |
const char * | xBRZ |
static int | LastShaderIndex = -1 |
static GLuint | ShaderProgram |
static GLint | Texture |
static GLint | MVPMatrix |
static GLint | FrameDirection |
static GLint | FrameCount |
static GLint | OutputSize |
static GLint | TextureSize |
static GLint | InputSize |
static GLint | VertexCoord |
static GLint | TexCoord |
static int | RecacheCount = 0 |
uint8_t | SizeChangeCounter |
Just a counter to cache window data on in other places when the size changes. More... | |
static uint16_t | LastSizeVersion = -1 |
static int | LastVideoWidth = -1 |
static int | LastVideoHeight = -1 |
static double | LastVideoVerticalPixelSize = -1.0 |
static int | DrawableWidth |
static int | DrawableHeight |
static int | XBorder |
static int | YBorder |
static GLfloat | modelview [4 *4] |
static GLfloat | projection [4 *4] |
static GLfloat | matrix [4 *4] = {0.0f} |
#define canUseShaders (shadersLoaded == 1) |
#define CCONV __stdcall |
#define COMPILE_BUILTIN_SHADER | ( | name | ) |
#define setCanUseShaders | ( | x | ) | (shadersLoaded = (x ? 1 : 0)) |
#define shadersAreInitialized (shadersLoaded != -1) |
|
static |
Description
Get the active shader.
Example:
shader_name = GetShader() print(shader_name)
|
static |
Description
Get the list of shaders.
Example:
shaders = GetShaderNames() for i,name in ipairs(shaders) do print(name) end
|
static |
Description
Apply a shader.
Example:
– Apply a VHS shader SetShader("VHS")
|
static |
|
static |
|
static |
|
static |
bool LoadShaderExtensions | ( | ) |
|
static |
bool RenderWithShader | ( | SDL_Renderer * | renderer, |
SDL_Window * | win, | ||
SDL_Texture * | backBuffer | ||
) |
|
static |
void | ( | CCONV * | lazyGlBegin | ) |
const char* CRT |
|
static |
|
static |
|
static |
|
static |
|
static |
PFNGLATTACHSHADERPROC glAttachShader |
PFNGLCOMPILESHADERPROC glCompileShader |
PFNGLCREATEPROGRAMPROC glCreateProgram |
PFNGLCREATESHADERPROC glCreateShader |
MIT License
Copyright (c) 2020 Tim Felgentreff Copyright (c) 2017 Augusto Ruiz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PFNGLDELETESHADERPROC glDeleteShader |
GLdouble |
GLfloat |
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation |
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog |
PFNGLGETPROGRAMIVPROC glGetProgramiv |
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog |
PFNGLGETSHADERIVPROC glGetShaderiv |
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation |
GLint GLfloat GLint |
PFNGLLINKPROGRAMPROC glLinkProgram |
PFNGLSHADERSOURCEPROC glShaderSource |
PFNGLUNIFORM1FPROC glUniform1f |
PFNGLUNIFORM1IPROC glUniform1i |
PFNGLUNIFORM2FPROC glUniform2f |
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv |
PFNGLUSEPROGRAMPROC glUseProgram |
PFNGLVALIDATEPROGRAMPROC glValidateProgram |
PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
const char* none |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
uint8_t SizeChangeCounter |
Just a counter to cache window data on in other places when the size changes.
|
static |
|
static |
|
static |
|
static |
const char* VHS |
|
static |
const char* xBRZ |
|
static |