Compare commits

...

No commits in common. "master" and "master" have entirely different histories.

239 changed files with 41428 additions and 10889 deletions

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
*.o
build
bin_unix/native_*
build

View File

@ -1,80 +0,0 @@
# OctaCore license
All new OctaCore code is provided to you under the terms of the BSD-2-Clause
license, while the original Tesseract/Sauerbraten portions retain their original
license. OctaCore only ships the altered source code of the original projects,
without the media content.
Copyright (c) 2020 Daniel "q66" Kolesa
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
**THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.**
# Tesseract
OctaCore is derived from the Tesseract codebase:
Tesseract game engine source code, any release.
Copyright (C) 2001-2020 Wouter van Oortmerssen, Lee Salzman, Mike Dysart,
Robert Pointon, Quinton Reeves, and Benjamin Segovia
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
# Sauerbraten
Tesseract is based on Sauerbraten:
Sauerbraten game engine source code, any release.
Copyright (C) 2001-2020 Wouter van Oortmerssen, Lee Salzman, Mike Dysart,
Robert Pointon, and Quinton Reeves
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

16
README
View File

@ -18,7 +18,6 @@ It provides a bunch of new rendering features such as:
* HDR rendering with tonemapping and bloom
* real-time diffuse global illumination for sunlight (radiance hints)
* volumetric lighting
* transparent shadows
* screen-space ambient occlusion
* screen-space reflections and refractions for water and glass (use as many water planes as you want now!)
* screen-space refractive alpha cubes
@ -82,18 +81,3 @@ Set attribute 5 of a light entity to 4.
The intensity of the volumetric lighting medium can be controlled by volscale and the color can by controlled by volcolour.
To make transparent shadows:
This is toggled on a per-map basis by setting "alphashadow" to 0 (off), 1 (sunlight), or 2 (sunlight and point lights).
If set to 1, you must set attribute 5 of a light entity to 16 to enable transparent shadows for that point light.
If set to 2, all point lights automatically cast transparent shadows.
If a light is volumetric, regardless of "alphashadow" setting, the light entity's attribute 5 must be set to 20 (4 | 16) for it
to cast a volumetric transparent shadow.
To make a cube cast transparent shadows, use the "alpha" material. The texalpha/valpha commands can be then used to control the alpha
of the cube, which then is used to determine the intensity of the transparent shadow. This intensity can be further scaled by setting
the global map variable "alphashadowscale" (0..2).
If a texture slot has an alpha texture (slot "a"), this can be used to mask the alpha of the cube. This masked alpha will then be used
to further mask the transparent shadow.

View File

@ -1,9 +1,3 @@
# OctaCore
**Last Tesseract SVN import:** 2425
This is the work in progress engine part of the newly revived OctaForge
project.
Nothing much to see here yet, besides a stripped down, partially refactored
Tesseract codebase.
OctaCore is the engine component of OctaForge 2.0.

101
bin_unix/readme.txt 100644
View File

@ -0,0 +1,101 @@
* Installing and Running Tesseract
*nix versions of Tesseract clients and standalone servers.
The clients function identical to the win32 client, see config.html for more
information about command-line options if necessary.
Please run "tesseract_unix" from the root Tesseract dir (NOT from inside the "bin_unix"
directory) to launch these, or set the TESS_DATA variable at the top of the "tesseract_unix"
script to an absolute path to allow it to be run from any location. Note that the "tesseract_unix"
script is set up to write any files (saved maps, configs, etc.) into the user's home
directory at "~/.tesseract".
Clients will need the following dynamic link libraries present:
* libGL (OpenGL)
* SDL2 (>= 2.0.0)
* SDL2_image
* SDL2_mixer
* libpng
* libjpeg
* zlib
If native binaries for your platform are not included, then try the following:
1) Ensure you have the DEVELOPMENT VERSIONS of the above libraries installed.
2) Type "make -C src install".
3) Re-run the "tesseract_unix" script if it succeeded.
The servers (bin_unix/linux_server or bin_unix/native_server) should need no libs
other than libstdc++ and zlib. Note that for the server to see the "config/server-init.cfg",
it must be run from the root Tesseract directory. If you run a server with the
"tesseract_unix -d" command, this happens automatically. However, if you wish to
run the standalone servers instead, then you may need to write an appropriate wrapper
script to change to the appropriate data directory before running the standalone
server binary, as described below in the packaging guide.
* Packaging Guide for Unix-like Operating System Developers/Maintainers
If you are packaging Tesseract up for redistribution in a Linux distribution or other
similar OS, please avoid using the "tesseract_unix" script in its default/unmodified form.
You should at least set the TESS_DATA variable to appropriately find the common Tesseract
data files, or better yet replace it with a more appropriate way of starting Tesseract using
the script as a basis. If the distribution happens to place program binaries in a specific
directory separate from data files, such as "/usr/bin", then much of the lines within the script
that deal with finding an appropriate binary can be removed, as they only exist to help people
running from the original Tesseract tarball. An example run script is shown further
below.
Also, please note, that if your distribution chooses to package the binaries and game data
as separate packages due to whatever licensing rules or cross-architecture package sharing,
that client binaries from newer Tesseract editions are NOT compatible with older versions of
game data, on whole, nor obviously compatible with newer versions of game data. Game data, as a
whole, and client binaries are only roughly compatible within individual Tesseract editions,
though patches to individual Tesseract editions generally always retain compatibility with
the game data.
For those writing custom Tesseract run scripts for packaging, they should adhere to the following
guidelines:
Tesseract finds all game files relative to the current directory from which Tesseract is run,
so any script running Tesseract should set its current directory to where the Tesseract data
files are located before it runs the Tesseract client binaries. No silly symlinking tricks should
be at all necessary.
When running the Tesseract client, one command-line switch should ALWAYS be supplied to
the client binary. This is "-u${HOME}/.tesseract", which will instruct Tesseract to
write any user private files such as saved maps and configurations to a private ".tesseract"
directory within each user's home directory. Tesseract will automatically create this
directory and any subdirectories for each user running it, so do not pre-create this directory
or install any symlinks within it - as some Linux distribution packages have erroneously done.
All command-line switches supplied to the Tesseract run script should be passed to the
Tesseract client after the "-u${HOME}/.tesseract" switch.
A simple script such as the following (with directory/file names set as appropriate) would
ultimately suffice for the client:
#!/bin/sh
TESS_DATA=/usr/share/games/tesseract
TESS_BIN=/usr/bin/tesseract_client
TESS_OPTIONS="-u${HOME}/.tesseract"
cd ${TESS_DATA}
exec ${TESS_BIN} ${TESS_OPTIONS} "$@"
A simple script for the server, which assumes a global default "config/server-init.cfg" in TESS_DATA,
but allows per-user overriding via the home directory, might be:
#!/bin/sh
TESS_DATA=/usr/share/games/tesseract
TESS_SERV_BIN=/usr/bin/tesseract_server
TESS_SERV_OPTIONS="-u${HOME}/.tesseract"
cd ${TESS_DATA}
exec ${TESS_SERV_BIN} ${TESS_SERV_OPTIONS} "$@"
With respect to libraries, make sure that you do not link Tesseract against any other ENet package
than the one that comes included with the Tesseract, as it may be different from the official ENet
releases and might fail to compile or communicate properly.

View File

@ -11,7 +11,7 @@ name "unnamed"
///////////////////////////////////////////////////////////////////////////////
miniconfilter 0x300 // display chat and team chat in mini-console
confilter (&~ 0xFFF $miniconfilter) // don't display other player frags or mini-console stuff in console
fullconsole = 0
///////////////////////////////////////////////////////////////////////////////
// Universal Mouse Scrollwheel //

View File

@ -16,17 +16,20 @@ setdefaultenv = [
if $emptymap [setdefaultenv]
materialreset
texture glass "mat_glass/nieb/scratch2.png" // Glass Normals
texture water "mat_water/nieb/water.png" // Water (Unused)
texture 1 "mat_water/appleflap/water_normal.png" // Water Normals
texture 1 "mat_water/nieb/waterfall.png" // Waterfall Diffuse
texture 1 "mat_water/nieb/waterfall_normal.png" // Waterfall Normals
texture lava "mat_lava/nieb/lava.png" // Lava Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lava Normals
texture 1 "mat_lava/nieb/lava.png" // Lavafall Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lavafall Normals
loop+ i 1 4 [
texture [glass@i] "mat_glass/nieb/scratch2.png" // Glass Normals
texture [water@i] "mat_water/nieb/water.png" // Water (Unused)
texture 1 "mat_water/appleflap/water_normal.png" // Water Normals
texture 1 "mat_water/nieb/waterfall.png" // Waterfall Diffuse
texture 1 "mat_water/nieb/waterfall_normal.png" // Waterfall Normals
texture [lava@i] "mat_lava/nieb/lava.png" // Lava Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lava Normals
texture 1 "mat_lava/nieb/lava.png" // Lavafall Diffuse
texture 1 "mat_lava/nieb/lava_normal.png" // Lavafall Normals
]
decalreset
decalload "nieb/complex/loadingbay"
texturereset // Start world texture list
texsky // Dummy "sky" texture
@ -37,4 +40,142 @@ texturereset // Start world texture list
texload "base/white"
texload "base/glow"
// Nieb/Complex
texload "nieb/complex/door_rail"
texload "nieb/complex/door_rail"; texrotate 1
texload "nieb/complex/electrical-outlet"
texload "nieb/complex/glass_2"
texload "nieb/complex/glass_subtle"
texload "nieb/complex/light-switch"
texload "nieb/complex/light01_off"
texload "nieb/complex/light01_on"
texload "nieb/complex/step01"
texload "nieb/complex/step01"; texrotate 1
texload "nieb/complex/step02"
texload "nieb/complex/step02"; texrotate 1
texload "nieb/complex/step03"
texload "nieb/complex/step03"; texrotate 1
texload "nieb/complex/tile01"
texload "nieb/complex/tile02"
texload "nieb/complex/vent"
texload "nieb/complex/wall01"
texload "nieb/complex/woodfloor01"
texload "nieb/complex/woodfloor02"
texload "nieb/complex/woodfloor03"
// CGTextures
texload "cgtextures/buildingshighrise0290"
texload "cgtextures/buildingshighrise0341"
texload "cgtextures/buildingshighrise0436"
texload "cgtextures/carpet01"
texload "cgtextures/ceilingtile01"
texload "cgtextures/tilesplain0119"
texload "cgtextures/tilesplain0119"; texrotate 1
// AGF81
texload "agf81/concrete1"
texload "agf81/concrete1w"
texload "agf81/concrete2"
texload "agf81/concrete2"; texrotate 1
texload "agf81/concrete3"
texload "agf81/concrete3"; texrotate 1
texload "agf81/concrete4"
texload "agf81/concrete5"
texload "agf81/door_texture_2"
texload "agf81/metal_a2"
// Nobiax
texload "nobiax/pattern019"
texload "nobiax/pattern037"
texload "nobiax/pattern042"
texload "nobiax/pattern044"
texload "nobiax/pattern045"
texload "nobiax/pattern047"
texload "nobiax/pattern055"
texload "nobiax/pattern056"
texload "nobiax/pattern057"
texload "nobiax/pattern205"
texload "nobiax/pattern208"
// philipk2
texload "philipk2/pk02_ceiling03"
texload "philipk2/pk02_door01"
texload "philipk2/pk02_door02"
texload "philipk2/pk02_door03"
texload "philipk2/pk02_floor01"
texload "philipk2/pk02_floor02"
texload "philipk2/pk02_floor03"
texload "philipk2/pk02_floor04"
texload "philipk2/pk02_floor05"
texload "philipk2/pk02_floor06a"
texload "philipk2/pk02_floor06b"
texload "philipk2/pk02_floor07"
texload "philipk2/pk02_floor08a"
texload "philipk2/pk02_floor08b"
texload "philipk2/pk02_floor09a"
texload "philipk2/pk02_floor09b"
texload "philipk2/pk02_floor10"
texload "philipk2/pk02_floor11"
texload "philipk2/pk02_floor12a"
texload "philipk2/pk02_floor12b"
texload "philipk2/pk02_floor13a"
texload "philipk2/pk02_floor13b"
texload "philipk2/pk02_floor_cyl01"
texload "philipk2/pk02_floor_cyl02"
texload "philipk2/pk02_generic01a"
texload "philipk2/pk02_generic01b"
texload "philipk2/pk02_light01a"
texload "philipk2/pk02_light01b"
texload "philipk2/pk02_panels01a"
texload "philipk2/pk02_panels01b"
texload "philipk2/pk02_panels01c"
texload "philipk2/pk02_plates01a"
texload "philipk2/pk02_plates01b"
texload "philipk2/pk02_rock01"
texload "philipk2/pk02_sand01"
texload "philipk2/pk02_switches01a"
texload "philipk2/pk02_trim01"
texload "philipk2/pk02_trim02"
texload "philipk2/pk02_trim03"
texload "philipk2/pk02_trim04a"
texload "philipk2/pk02_trim04b"
texload "philipk2/pk02_trim_set01a"
texload "philipk2/pk02_trim_set01b"
texload "philipk2/pk02_trim_set02a"
texload "philipk2/pk02_trim_set02b"
texload "philipk2/pk02_wall01"
texload "philipk2/pk02_wall03a"
texload "philipk2/pk02_wall03b"
texload "philipk2/pk02_wall04a"
texload "philipk2/pk02_wall04b"
texload "philipk2/pk02_wall05a"
texload "philipk2/pk02_wall05b"
texload "philipk2/pk02_wall05c"
texload "philipk2/pk02_wall06a"
texload "philipk2/pk02_wall06b"
texload "philipk2/pk02_wall07a"
texload "philipk2/pk02_wall07b"
texload "philipk2/pk02_wall_big01a"
texload "philipk2/pk02_wall_big01b"
texload "philipk2/pk02_wall_big02a"
texload "philipk2/pk02_wall_big02b"
texload "philipk2/pk02_wall08a"
texload "philipk2/pk02_wall08b"
texload "philipk2/pk02_ceiling02"
texload "philipk2/pk02_computer01a"
texload "philipk2/pk02_computer01b"
texload "philipk2/pk02_computer01c"
texload "philipk2/pk02_light02a"
texload "philipk2/pk02_light02b"
texload "philipk2/pk02_light02c"
texload "philipk2/pk02_light02"
texload "philipk2/pk02_light03"
texload "philipk2/pk02_pipes01"
texload "philipk2/pk02_switches01b"
texload "philipk2/pk02_switches01c"
texload "philipk2/pk02_wall02a"
texload "philipk2/pk02_wall02b"
texload "philipk2/pk02_wall02c"
setshader "stdworld"

View File

@ -10,7 +10,6 @@ exec "config/glsl/gi.cfg"
exec "config/glsl/particle.cfg"
exec "config/glsl/stain.cfg"
exec "config/glsl/material.cfg"
exec "config/glsl/smfilter.cfg"
exec "config/glsl/deferred.cfg"
exec "config/glsl/tonemap.cfg"
exec "config/glsl/volumetric.cfg"

View File

@ -5,19 +5,15 @@
////////////////////////////////////////////////
lazyshader 0 "tqaaresolve" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
@(? $tqaaresolvegather [
varying vec2 texcoord1;
])
out vec2 texcoord0;
out vec2 texcoord1;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
@(? $tqaaresolvegather [
texcoord1 = vtexcoord0 - 0.5;
])
texcoord1 = vtexcoord0 - 0.5;
}
] [
@(gfetchdefs tex2)
@ -26,11 +22,9 @@ lazyshader 0 "tqaaresolve" [
uniform mat4 reprojectmatrix;
uniform vec2 maxvelocity;
uniform vec2 colorweight;
varying vec2 texcoord0;
@(? $tqaaresolvegather [
varying vec2 texcoord1;
])
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec2 texcoord1;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex2, texcoord0)] [
@ -42,28 +36,19 @@ lazyshader 0 "tqaaresolve" [
vec2 vel = prevtc.xy/prevtc.w - texcoord0;
float scale = clamp(maxvelocity.x*inversesqrt(dot(vel, vel) + 1e-6), 0.0, 1.0);
float mask = 1.0 - texture2DRect(tex0, texcoord0 + quincunx.xy).a;
vec4 color = texture2DRect(tex0, texcoord0 + mask*quincunx.xy);
vec4 prevcolor = texture2DRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale));
float mask = 1.0 - textureRect(tex0, texcoord0 + quincunx.xy).a;
vec4 color = textureRect(tex0, texcoord0 + mask*quincunx.xy);
vec4 prevcolor = textureRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale));
@(? $tqaaresolvegather [
vec4 l0 = textureGather(tex0, texcoord1, 1);
vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1);
float l2 = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
float l3 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
vec4 l01min = min(l0, l1), l01max = max(l0, l1);
l01min.xy = min(l01min.xy, l01min.zw);
l01max.xy = max(l01max.xy, l01max.zw);
float lmin = min(min(l01min.x, l01min.y), min(l2, l3));
float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
] [
float l0 = texture2DRect(tex0, texcoord0 + vec2(-1.0, -0.5)).g;
float l1 = texture2DRect(tex0, texcoord0 + vec2( 0.5, -1.0)).g;
float l2 = texture2DRect(tex0, texcoord0 + vec2( 1.0, 0.5)).g;
float l3 = texture2DRect(tex0, texcoord0 + vec2(-0.5, 1.0)).g;
float lmin = min(color.g, min(min(l0, l1), min(l2, l3)));
float lmax = max(color.g, max(max(l0, l1), max(l2, l3)));
])
vec4 l0 = textureGather(tex0, texcoord1, 1);
vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1);
float l2 = textureRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
float l3 = textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
vec4 l01min = min(l0, l1), l01max = max(l0, l1);
l01min.xy = min(l01min.xy, l01min.zw);
l01max.xy = max(l01max.xy, l01max.zw);
float lmin = min(min(l01min.x, l01min.y), min(l2, l3));
float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
float weight = 0.5 - 0.5*clamp((colorweight.x*max(prevcolor.g - lmax, lmin - prevcolor.g) + colorweight.y) / (lmax - lmin + 1e-4), 0.0, 1.0);
weight *= clamp(1.0 - 2.0*(prevcolor.a - color.a), 0.0, 1.0);

View File

@ -25,10 +25,10 @@ ambientobscurancevariantshader = [
derivnormal = (>= (strstr $arg2 "d") 0)
maxaotaps = $arg3
shader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
@(screentexcoord 1)
varying vec2 texcoord0, texcoord1;
out vec2 texcoord0, texcoord1;
void main(void)
{
gl_Position = vvertex;
@ -53,8 +53,8 @@ ambientobscurancevariantshader = [
#define depthtc texcoord0
])
uniform vec3 gdepthpackparams;
varying vec2 texcoord0, texcoord1;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0, texcoord1;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(if (&& $derivnormal [= $aodepthformat 1]) [result [
@ -90,7 +90,7 @@ ambientobscurancevariantshader = [
normal *= normscale > 0.75 ? normscale : 0.0;
normal = normalmatrix * normal;
]])
vec2 noise = texture2D(tex2, texcoord1).rg*2.0-1.0;
vec2 noise = texture(tex2, texcoord1).rg*2.0-1.0;
float obscure = 0.0;
@(loopconcat i $maxaotaps [result [
vec2 offset@[i] = reflect(vec2(@(at $aotapoffsets $i)), noise);
@ -127,9 +127,9 @@ ambientobscuranceshader = [
]
shader 0 "linearizedepth" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -138,8 +138,8 @@ shader 0 "linearizedepth" [
] [
@(gfetchdefs tex0 $msaasamples)
uniform vec3 gdepthpackparams;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(if (! $aodepthformat) [
@ -165,14 +165,14 @@ bilateralvariantshader = [
reduced = $arg4
filterdir = $arg5
shader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(if $reduced [result [
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
]])
@(if $upscaled [result [
@(screentexcoord 1)
varying vec2 texcoord1;
out vec2 texcoord1;
]])
void main(void)
{
@ -185,27 +185,27 @@ bilateralvariantshader = [
uniform sampler2DRect tex0;
uniform vec2 bilateralparams;
uniform vec3 gdepthpackparams;
@(? $reduced [varying vec2 texcoord0;])
@(? $upscaled [varying vec2 texcoord1;])
fragdata(0) vec4 fragcolor;
@(? $reduced [in vec2 texcoord0;])
@(? $upscaled [in vec2 texcoord1;])
layout(location = 0) out vec4 fragcolor;
void main(void)
{
#define tc @(? $upscaled [texcoord1] [gl_FragCoord.xy])
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i))
#define texval(i) textureRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) textureRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex1, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex1, depthtc, tapvec(ivec2, i))
@(cond [$packed] [
if $aodepthformat [result [
vec2 vals = texture2DRect(tex0, tc).rg;
vec2 vals = textureRect(tex0, tc).rg;
#define color vals.x
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
#define depth vals.y
]])
]] [result [
vec4 vals = texture2DRect(tex0, tc);
vec4 vals = textureRect(tex0, tc);
#define color vals.a
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
float depth = dot(vals.rgb, gdepthunpackparams);
@ -219,7 +219,7 @@ bilateralvariantshader = [
float depth = dot(gfetch(tex1, depthtc).rgb, gdepthunpackparams);
]])
]] [result [
float color = texture2DRect(tex0, tc).r;
float color = textureRect(tex0, tc).r;
@(gdepthunpack depth [gfetch(tex1, depthtc)])
]])
float weights = 1.0;

View File

@ -6,12 +6,12 @@
blurshader = [
shader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
uniform float offsets[8];
varying vec2 texcoord0, texcoordp1, texcoordn1;
out vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i;
out vec2 texcoordp@i, texcoordn@i;
]])
void main(void)
{
@ -33,11 +33,11 @@ blurshader = [
uniform float weights[8];
uniform float offsets[8];
uniform sampler@[arg4] tex0;
varying vec2 texcoord0, texcoordp1, texcoordn1;
in vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i;
in vec2 texcoordp@i, texcoordn@i;
]])
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
#define texval(coords) texture@[arg4](tex0, (coords))

View File

@ -51,22 +51,22 @@ decalvariantshader = [
defuniformparam "bumpblend" 1 // alpha-blend strength for normals
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex;
in vec4 vvertex;
@(? (dtopt "n") [
attribute vec4 vtangent;
varying mat3 world;
in vec4 vtangent;
out mat3 world;
] [
varying vec3 nvec;
out vec3 nvec;
])
attribute vec4 vnormal;
attribute vec3 vtexcoord0;
in vec4 vnormal;
in vec3 vtexcoord0;
uniform mat4 camprojmatrix;
varying vec4 texcoord0;
out vec4 texcoord0;
@(? (|| (dtopt "p") (dtopt "r")) [
uniform vec3 camera;
varying vec3 camvec;
out vec3 camvec;
])
@(? (dtopt "G") [uniform float millis; flat varying float pulse;])
@(? (dtopt "G") [uniform float millis; flat out float pulse;])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -91,38 +91,37 @@ decalvariantshader = [
}
] [
@(cond [dtopt "0"] [result [
fragdata(0) vec4 gcolor;
fragblend(0) vec4 gcolorblend;
layout(location = 0) out vec4 gcolor;
layout(location = 0, index = 1) out vec4 gcolorblend;
]] [dtopt "1"] [
? $usepacknorm [
fragdata(0) vec4 gnormal;
layout(location = 0) out vec4 gnormal;
] [
fragdata(0) vec4 gnormal;
fragblend(0) vec4 gnormalblend;
layout(location = 0) out vec4 gnormal;
layout(location = 0, index = 1) out vec4 gnormalblend;
]
] [result [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
]])
uniform sampler2D diffusemap;
uniform vec4 colorparams;
varying vec4 texcoord0;
in vec4 texcoord0;
@(? (dtopt "n") [
uniform sampler2D normalmap;
varying mat3 world;
in mat3 world;
] [
varying vec3 nvec;
#define bumpblend vec4(1.0)
in vec3 nvec;
])
@(? (|| (dtopt "p") (dtopt "r")) [varying vec3 camvec;])
@(? (|| (dtopt "p") (dtopt "r")) [in vec3 camvec;])
@(? (|| (dtopt "g") (dtopt "S")) [uniform sampler2D glowmap;])
@(? (dtopt "G") [flat varying float pulse;])
@(? (dtopt "G") [flat in float pulse;])
@(? (dtopt "r") [uniform samplerCube envmap;])
void main(void)
{
@(if (dtopt "n") [result [
@(? (dtopt "p") [
float height = texture2D(normalmap, texcoord0.xy).a;
float height = texture(normalmap, texcoord0.xy).a;
vec3 camvecn = normalize(camvec);
vec2 dtc = texcoord0.xy + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [
@ -130,7 +129,7 @@ decalvariantshader = [
])
@(? (|| (! (dtopt "0")) (dtopt "r")) [
vec3 bump = texture2D(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bump = texture(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bumpw = world * bump;
#define nvec bumpw
])
@ -138,10 +137,10 @@ decalvariantshader = [
#define dtc texcoord0.xy
]])
vec4 diffuse = texture2D(diffusemap, dtc);
vec4 diffuse = texture(diffusemap, dtc);
@(if (dtopt "g") [result [
vec4 glowspec = texture2D(glowmap, dtc);
vec4 glowspec = texture(glowmap, dtc);
#define glow glowspec.rgb
#define spec glowspec.a
glow *= @(? (dtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@ -150,7 +149,7 @@ decalvariantshader = [
@(if (dtopt "0") [result [
@(if (&& (dtopt "S") [! (dtopt "g")]) [result [
float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture2D(glowmap, dtc).r] [texture2D(normalmap, dtc).a]);
float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture(glowmap, dtc).r] [texture(normalmap, dtc).a]);
]])
@(gspecpack [gloss.x] (if (dtopt "s") [? (dtopt "S") [spec * specscale.x] [specscale.x]]))
]])
@ -168,7 +167,7 @@ decalvariantshader = [
])
float invfresnel = dot(camvecn, nvec);
vec3 rvec = 2.0*nvec*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb * diffuse.a;
vec3 reflect = texture(envmap, rvec).rgb * diffuse.a;
@(? (dtopt "R") [
vec3 rmod = envscale.xyz*spec;
] [

View File

@ -36,7 +36,7 @@ msaadetectedges = [
]
lazyshader 0 msaaedgedetect [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
@ -55,9 +55,7 @@ lazyshader 0 msaaedgedetect [
// deferredlighttype:
// p -> point-light shadow (default cubemap)
// P -> point-light color shadow
// c -> CSM
// C -> color CSM
// a -> AO
// A -> AO sun
// r -> radiance hints
@ -66,7 +64,6 @@ lazyshader 0 msaaedgedetect [
// E -> 5x5 weighted bilinear filter
// F -> 3x3 weighted bilinear filter
// f -> 4x rotated grid filter
// N -> no filtering
// m -> minimap
// M -> multisampled
// O -> sample 1
@ -119,21 +116,16 @@ deferredlightvariantshader = [
numlights = (+ $arg6 0)
baselight = (< (mod $arg2 4) 2)
spotlight = (>= (mod $arg2 8) 4)
transparent = (<= 8 $arg2 15)
avatar = (<= 24 $arg2 31)
local colorshadow
colorshadow = (|| (? (<= 16 $arg2 23) 2) [&& (dlopt "C") [! $transparent] [! $avatar]])
transparent = (<= 8 $arg2 16)
avatar = (<= 17 $arg2 31)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 lightmatrix;
void main(void)
{
gl_Position = lightmatrix * vvertex;
}
]) [
@(? (&& (dlopt "S") [< $glslversion 400]) [
#extension GL_ARB_sample_shading : enable
])
@(? (&& (dlopt "T") [glext "GL_EXT_shader_samples_identical"]) [
#extension GL_EXT_shader_samples_identical : enable
])
@ -178,22 +170,6 @@ deferredlightvariantshader = [
uniform sampler3D tex6, tex7, tex8, tex9;
]])
]])
@(? $colorshadow [
uniform sampler2DRect tex10;
#define sunshadowtype vec3
#define filtersunshadow(tc) (filtershadow(tc) * filtercolorshadow(tex10, tc))
] [
#define sunshadowtype float
#define filtersunshadow filtershadow
])
@(? (> $colorshadow 1) [
uniform sampler2DRect tex11;
#define lightshadowtype vec3
#define filterlightshadow(tc) (filtershadow(tc) * filtercolorshadow(tex11, tc))
] [
#define lightshadowtype float
#define filterlightshadow filtershadow
])
uniform vec3 camera;
uniform mat4 worldmatrix;
uniform vec4 fogdir;
@ -204,7 +180,7 @@ deferredlightvariantshader = [
uniform vec4 lightscale;
@(? (&& (dlopt "a") [! $avatar] [! $transparent]) [uniform sampler2DRect tex5; uniform vec2 aoscale; uniform vec4 aoparams;])
@(gdepthunpackparams)
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
@(if (dlopt "p") [
? $spotlight [
@ -228,19 +204,104 @@ deferredlightvariantshader = [
])
@(if (|| (dlopt "p") [dlopt "c"]) [
cond [dlopt "G"] [
smfilterg5 $colorshadow
] [dlopt "g"] [
smfilterg3 $colorshadow
] [dlopt "E"] [
smfilterb5 $colorshadow
] [dlopt "F"] [
smfilterb3 $colorshadow
] [dlopt "f"] [
smfilterrg $colorshadow
] [
smfilternone $colorshadow
]
cond [dlopt "G"] [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
vec4 group1 = shadowgather(center, -2, -2);
vec4 group2 = shadowgather(center, 0, -2);
vec4 group3 = shadowgather(center, 2, -2);
vec4 group4 = shadowgather(center, -2, 0);
vec4 group5 = shadowgather(center, 0, 0);
vec4 group6 = shadowgather(center, 2, 0);
vec4 group7 = shadowgather(center, -2, 2);
vec4 group8 = shadowgather(center, 0, 2);
vec4 group9 = shadowgather(center, 2, 2);
vec4 locols = vec4(group1.ab, group3.ab);
vec4 hicols = vec4(group7.rg, group9.rg);
locols.yz += group2.ab;
hicols.yz += group8.rg;
vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +
vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +
mix(locols, hicols, offset.y);
vec4 cols = group5 + vec4(group2.rg, group8.ab);
cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);
return dot(cols, vec4(1.0/25.0));
}
]] [dlopt "g"] [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5), center = (shadowtc.xy - offset)*shadowatlasscale;
vec4 group1 = shadowgather(center, -1, -1);
vec4 group2 = shadowgather(center, 1, -1);
vec4 group3 = shadowgather(center, -1, 1);
vec4 group4 = shadowgather(center, 1, 1);
vec4 cols = vec4(group1.rg, group2.rg) + vec4(group3.ab, group4.ab) + mix(vec4(group1.ab, group2.ab), vec4(group3.rg, group4.rg), offset.y);
return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
}
]] [dlopt "E"] [result [
#define shadowval(xy, xoff, yoff) float(textureRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec4 center = vec4(shadowtc.xy - offset + 0.5, shadowtc.xy - offset*0.5);
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/25.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center.zw, -1.5, -1.5),
shadowval(center.zw, 2.0, -1.5),
shadowval(center.zw, -1.5, 2.0),
shadowval(center.zw, 2.0, 2.0))) +
(2.0/25.0)*dot(size,
vec4(shadowval(center.zy, 2.0, 0.0),
shadowval(center.xw, 0.0, 2.0),
shadowval(center.zy, -1.5, 0.0),
shadowval(center.xw, 0.0, -1.5))) +
(4.0/25.0)*shadowval(center.xy, 0.0, 0.0);
}
]] [dlopt "F"] [result [
#define shadowval(center, xoff, yoff) float(textureRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec3 center = shadowtc;
//center.xy -= offset;
//vec4 size = vec4(offset + 1.0, 2.0 - offset), weight = vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0);
//return (1.0/9.0)*dot(size.zxzx*size.wwyy,
// vec4(shadowval(center, weight.zw),
// shadowval(center, weight.xw),
// shadowval(center, weight.zy),
// shadowval(center, weight.xy)));
center.xy -= offset*0.5;
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center, -0.5, -0.5),
shadowval(center, 1.0, -0.5),
shadowval(center, -0.5, 1.0),
shadowval(center, 1.0, 1.0)));
}
]] [dlopt "f"] [result [
#define shadowval(center, xoff, yoff) float(textureRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
return dot(vec4(0.25),
vec4(shadowval(shadowtc, -0.4, 1.0),
shadowval(shadowtc, -1.0, -0.4),
shadowval(shadowtc, 0.4, -1.0),
shadowval(shadowtc, 1.0, 0.4)));
}
]] [result [
#define filtershadow(shadowtc) float(textureRect(tex4, shadowtc))
]]
])
@(if (dlopt "c") [result [
@ -281,7 +342,7 @@ deferredlightvariantshader = [
]])
tc.xy += 0.5;
tc.z = tc.z * @(divf 1 $numrh) + offset;
vec4 shr = texture3D(tex6, tc), shg = texture3D(tex7, tc), shb = texture3D(tex8, tc), sha = texture3D(tex9, tc);
vec4 shr = texture(tex6, tc), shg = texture(tex7, tc), shb = texture(tex8, tc), sha = texture(tex9, tc);
shr.rgb -= 0.5;
shg.rgb -= 0.5;
shb.rgb -= 0.5;
@ -308,7 +369,7 @@ deferredlightvariantshader = [
#define accumalpha(alpha) resolved.a += alpha
@(if (&& [dlopt "a"] [! $avatar] [! $transparent]) [result [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
float ao = textureRect(tex5, gl_FragCoord.xy*aoscale).r;
]])
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
@ -322,7 +383,7 @@ deferredlightvariantshader = [
#define accumalpha(alpha) fragcolor.a = alpha
]]
] [result [
#define gfetch(sampler, coords) texture2DRect(sampler, coords)
#define gfetch(sampler, coords) textureRect(sampler, coords)
#define accumlight(light) fragcolor.rgb = light
#define accumalpha(alpha) fragcolor.a = alpha
@ -405,7 +466,7 @@ deferredlightvariantshader = [
@(if (&& (dlopt "a") [! $avatar] [! $transparent]) [result [
@(? (! (&& (dlopt "M") [dlopt "R"])) [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r;
float ao = textureRect(tex5, gl_FragCoord.xy*aoscale).r;
])
@(if (dlopt "d") [result [
#define aomask ao
@ -431,7 +492,7 @@ deferredlightvariantshader = [
{
@(if (= (+ (? (dlopt "p") $numlights) (dlopt "c")) 1) [unpackdistbias])
vec3 csmtc = getcsmtc(pos.xyz, distbias);
sunshadowtype sunoccluded = filtersunshadow(csmtc);
float sunoccluded = filtershadow(csmtc);
@(if (dlopt "m") [result [
light += diffuse.rgb*sunfacing * sunlightcolor * sunoccluded;
]] [result [
@ -491,16 +552,14 @@ deferredlightvariantshader = [
@(if $spotlight [
if (dlopt "p") [result [
vec3 spot@[j]tc = getspottc(light@[j]dir, spot@[j]dist, spotparams[@@j], shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
lightshadowtype light@[j]shadow = light@[j]atten * spot@[j]atten * filterlightshadow(spot@[j]tc);
light@[j]atten *= spot@[j]atten * filtershadow(spot@[j]tc);
]] [result [
float light@[j]shadow = light@[j]atten * spot@[j]atten;
light@[j]atten *= spot@[j]atten;
]]
] [
if (dlopt "p") [result [
vec3 shadow@[j]tc = getshadowtc(light@[j]dir, shadowparams[@@j], shadowoffset[@@j], distbias * lightpos[@@j].w);
lightshadowtype light@[j]shadow = light@[j]atten * filterlightshadow(shadow@[j]tc);
]] [result [
#define light@[j]shadow light@[j]atten
light@[j]atten *= filtershadow(shadow@[j]tc);
]]
])
@(if (= (+ $numlights $baselight) 1) [result [
@ -512,14 +571,14 @@ deferredlightvariantshader = [
]])
light@[j]facing *= light@[j]invdist;
@(if (dlopt "m") [result [
light += diffuse.rgb*light@[j]facing * lightcolor[@@j].rgb * light@[j]shadow;
light += diffuse.rgb*light@[j]facing * lightcolor[@@j].rgb * light@[j]atten;
]] [result [
@(if (= (+ $numlights (dlopt "c")) 1) [unpackspec])
float light@[j]spec = pow(clamp(light@[j]facing*facing - light@[j]invdist*dot(camdir, light@[j]dir), 0.0, 1.0), gloss) * specscale;
@(if (dlopt "z") [result [
light@[j]spec *= lightcolor[@@j].a;
]])
light += (diffuse.rgb*light@[j]facing + light@[j]spec) * lightcolor[@@j].rgb * light@[j]shadow;
light += (diffuse.rgb*light@[j]facing + light@[j]spec) * lightcolor[@@j].rgb * light@[j]atten;
@(? (= (+ $numlights $baselight) 1) [
float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
light *= foglerp;
@ -567,14 +626,12 @@ deferredlightshader = [
maxvariants = $basevariants
if (dlopt "t") [maxvariants = (+ $maxvariants $basevariants 1)]
if (dlopt "d") [maxvariants = (+ $maxvariants $basevariants 1)]
if (dlopt "P") [maxvariants = (+ $maxvariants (* (max $arg6 1) (? (dlopt "s") 2 1)))]
deferredlightvariantshader $shadername -1 $arg1 $arg4 $arg5 0 $maxvariants // null base shader
deferredlightvariantshader $shadername 0 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 0, base shader, sunlight
deferredlightvariantshader $shadername -1 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // base shader, no points lights, sunlight
if (dlopt "t") [
deferredlightvariantshader $shadername 8 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 8, transparency, base shader, sunlight
deferredlightvariantshader $shadername 16 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 16, trasparency, base shader, no points lights, sunlight
]
if (dlopt "d") [
deferredlightvariantshader $shadername 24 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 24, avatar, base shader, sunlight
deferredlightvariantshader $shadername 17 (concatword $arg1 $arg3) $arg4 $arg5 0 $maxvariants // row 17, avatar, base shader, no points lights, sunlight
]
loop+ i 1 (max $arg6 1) [
if (dlopt "b") [
@ -607,18 +664,6 @@ deferredlightshader = [
deferredlightvariantshader $shadername 15 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 15, transparent, shadowed spot lights
]
]
if (dlopt "P") [
if (dlopt "b") [
deferredlightvariantshader $shadername 17 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 17, color shadow, shadowed point lights, sunlight
]
deferredlightvariantshader $shadername 19 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 19, color shadow, shadowed point lights
if (dlopt "s") [
if (dlopt "b") [
deferredlightvariantshader $shadername 21 (concatword $arg1 $arg2 $arg3) $arg4 $arg5 $i $maxvariants // row 21, color shadow, shadowed spot lights, sunlight
]
deferredlightvariantshader $shadername 23 (concatword $arg1 $arg2) $arg4 $arg5 $i $maxvariants // row 23, color shadow, shadowed spot lights
]
]
if (dlopt "d") [
if (dlopt "b") [
deferredlightvariantshader $shadername 24 (concatword $arg1 $arg3) $arg4 $arg5 $i $maxvariants // row 24, avatar, point lights, sunlight

View File

@ -5,12 +5,12 @@
////////////////////////////////////////////////
shader 0 "blendbrush" [
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform vec4 texgenS, texgenT;
uniform float ldrscale;
varying vec4 color;
varying vec2 texcoord0;
out vec4 color;
out vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -19,22 +19,22 @@ shader 0 "blendbrush" [
}
] [
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 color;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = texture2D(tex0, texcoord0).r * color;
fragcolor = texture(tex0, texcoord0).r * color;
}
]
lazyshader 0 "prefab" [
attribute vec4 vvertex, vcolor;
attribute vec3 vnormal;
in vec4 vvertex, vcolor;
in vec3 vnormal;
uniform mat4 prefabmatrix;
uniform mat3 prefabworld;
varying vec3 nvec;
varying vec4 color;
out vec3 nvec;
out vec4 color;
@(msaainterpvert)
void main(void)
@ -45,8 +45,8 @@ lazyshader 0 "prefab" [
@(msaapackvert)
}
] [
varying vec3 nvec;
varying vec4 color;
in vec3 nvec;
in vec4 color;
@(msaainterpfrag)
void main(void)

View File

@ -216,9 +216,9 @@ fxaadefs = [
]
shader 0 [fxaa@fxaapreset@fxaaopts] [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -226,17 +226,17 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
}
] [
@fxaadefs
varying vec2 texcoord0;
in vec2 texcoord0;
uniform sampler2DRect tex0;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
#define posM texcoord0
vec4 rgbyM = texture2DRect(tex0, posM);
float lumaS = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, 1)));
float lumaE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 0)));
float lumaN = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, -1)));
float lumaW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 0)));
vec4 rgbyM = textureRect(tex0, posM);
float lumaS = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 0, 1)));
float lumaE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, 0)));
float lumaN = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 0, -1)));
float lumaW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, 0)));
#define lumaM FXAA_LUMA(rgbyM)
float maxSM = max(lumaS, lumaM);
@ -258,10 +258,10 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
return;
}
float lumaNW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, -1)));
float lumaSE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 1)));
float lumaNE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, -1)));
float lumaSW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 1)));
float lumaNW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, -1)));
float lumaSE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, 1)));
float lumaNE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, -1)));
float lumaSW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, 1)));
float lumaNS = lumaN + lumaS;
float lumaWE = lumaW + lumaE;
@ -311,9 +311,9 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
vec2 posN = posB - offNP * FXAA_QUALITY_P0;
vec2 posP = posB + offNP * FXAA_QUALITY_P0;
float subpixD = ((-2.0)*subpixC) + 3.0;
float lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN));
float lumaEndN = FXAA_LUMA(textureRect(tex0, posN));
float subpixE = subpixC * subpixC;
float lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP));
float lumaEndP = FXAA_LUMA(textureRect(tex0, posP));
if(!pairN) lumaNN = lumaSS;
float gradientScaled = gradient * 1.0/4.0;
@ -332,8 +332,8 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
#if (FXAA_QUALITY_PS > @i)
if(contN || contP)
{
if(contN) lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN));
if(contP) lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP));
if(contN) lumaEndN = FXAA_LUMA(textureRect(tex0, posN));
if(contP) lumaEndP = FXAA_LUMA(textureRect(tex0, posP));
if(contN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(contP) lumaEndP = lumaEndP - lumaNN * 0.5;
contN = abs(lumaEndN) < gradientScaled;
@ -369,7 +369,7 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
if(!horzSpan) posS.x += pixelOffsetSubpix * lengthSign;
if( horzSpan) posS.y += pixelOffsetSubpix * lengthSign;
fragcolor = texture2DRect(tex0, posS);
fragcolor = textureRect(tex0, posS);
}
]

View File

@ -5,15 +5,15 @@
////////////////////////////////////////////////
lazyshader 0 "rsmsky" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 rsmmatrix;
void main(void)
{
gl_Position = rsmmatrix * vvertex;
}
] [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
void main(void)
{
gcolor = vec4(0.0, 0.0, 0.0, 1.0);
@ -170,11 +170,11 @@ rsmtapoffsets32 = [
radiancehintsshader = [
numtaps = (cond [> $arg1 20] 32 [> $arg1 12] 20 12)
shader 0 [radiancehints@arg1] [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
in vec4 vvertex;
in vec3 vtexcoord0;
uniform mat4 rsmtcmatrix;
varying vec3 rhcenter;
varying vec2 rsmcenter;
out vec3 rhcenter;
out vec2 rsmcenter;
void main(void)
{
gl_Position = vvertex;
@ -187,20 +187,20 @@ radiancehintsshader = [
uniform vec2 rsmspread;
uniform float rhatten, rhspread, rhaothreshold, rhaoatten, rhaoheight;
uniform vec3 rsmdir;
varying vec3 rhcenter;
varying vec2 rsmcenter;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
in vec3 rhcenter;
in vec2 rsmcenter;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void calcrhsample(vec3 rhtap, vec2 rsmtap, inout vec4 shr, inout vec4 shg, inout vec4 shb, inout vec4 sha)
{
vec3 rhpos = rhcenter + rhtap*rhspread;
vec2 rsmtc = rsmcenter + rsmtap*rsmspread;
float rsmdepth = texture2DRect(tex0, rsmtc).x;
vec3 rsmcolor = texture2DRect(tex1, rsmtc).rgb;
vec3 rsmnormal = texture2DRect(tex2, rsmtc).xyz*2.0 - 1.0;
float rsmdepth = textureRect(tex0, rsmtc).x;
vec3 rsmcolor = textureRect(tex1, rsmtc).rgb;
vec3 rsmnormal = textureRect(tex2, rsmtc).xyz*2.0 - 1.0;
vec3 rsmpos = (rsmworldmatrix * vec4(rsmtc, rsmdepth, 1.0)).xyz;
vec3 dir = rhpos - rsmpos;
@ -234,9 +234,9 @@ radiancehintsshader = [
]
lazyshader 0 radiancehintsborder [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
varying vec3 texcoord0;
in vec4 vvertex;
in vec3 vtexcoord0;
out vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -245,27 +245,27 @@ lazyshader 0 radiancehintsborder [
] [
uniform sampler3D tex3, tex4, tex5, tex6;
uniform vec3 bordercenter, borderrange, borderscale;
varying vec3 texcoord0;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
in vec3 texcoord0;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{
float outside = clamp(borderscale.z*(abs(texcoord0.z - bordercenter.z) - borderrange.z), 0.0, 1.0);
vec3 tc = vec3(texcoord0.xy, clamp(texcoord0.z, bordercenter.z - borderrange.z, bordercenter.z + borderrange.z));
rhr = mix(texture3D(tex3, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhg = mix(texture3D(tex4, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhb = mix(texture3D(tex5, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rha = mix(texture3D(tex6, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhr = mix(texture(tex3, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhg = mix(texture(tex4, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhb = mix(texture(tex5, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rha = mix(texture(tex6, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
}
]
lazyshader 0 radiancehintscached [
attribute vec4 vvertex;
attribute vec3 vtexcoord0;
varying vec3 texcoord0;
in vec4 vvertex;
in vec3 vtexcoord0;
out vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -273,23 +273,23 @@ lazyshader 0 radiancehintscached [
}
] [
uniform sampler3D tex7, tex8, tex9, tex10;
varying vec3 texcoord0;
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
in vec3 texcoord0;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{
rhr = texture3D(tex7, texcoord0);
rhg = texture3D(tex8, texcoord0);
rhb = texture3D(tex9, texcoord0);
rha = texture3D(tex10, texcoord0);
rhr = texture(tex7, texcoord0);
rhg = texture(tex8, texcoord0);
rhb = texture(tex9, texcoord0);
rha = texture(tex10, texcoord0);
}
]
lazyshader 0 radiancehintsdisable [
attribute vec4 vvertex;
in vec4 vvertex;
uniform vec3 rhcenter;
uniform float rhbounds;
void main(void)
@ -297,10 +297,10 @@ lazyshader 0 radiancehintsdisable [
gl_Position = vec4((vvertex.xy - rhcenter.xy)/rhbounds, vvertex.zw);
}
] [
fragdata(0) vec4 rhr;
fragdata(1) vec4 rhg;
fragdata(2) vec4 rhb;
fragdata(3) vec4 rha;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{

View File

@ -13,24 +13,18 @@ grassvariantshader = [
local grasstype
grasstype = $arg2
variantshader 0 $arg1 (? (grassopt "b") 0 -1) [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
attribute vec4 vtangent;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec3 camera;
uniform vec3 grassmargin;
@(ginterpvert)
varying vec2 texcoord0;
varying vec4 colorscale;
varying vec2 bounds;
@(? (grassopt "b") [uniform vec4 blendmapparams; varying vec2 texcoord1;])
out vec2 texcoord0;
out vec4 colorscale;
@(? (grassopt "b") [uniform vec4 blendmapparams; out vec2 texcoord1;])
void main(void)
{
gl_Position = camprojmatrix * vvertex;
colorscale = vcolor;
texcoord0 = vtexcoord0;
vec2 camdir = (camera.xy - vvertex.xy) * grassmargin.y;
bounds = vec2(dot(camdir, vtangent.xy), dot(camdir, vtangent.zw)) + grassmargin.z;
texcoord0 = vtexcoord0;
@(? (grassopt "b") [
texcoord1 = (vvertex.xy - blendmapparams.xy)*blendmapparams.zw;
])
@ -40,20 +34,16 @@ grassvariantshader = [
uniform sampler2D tex0;
uniform float grasstest;
@(ginterpfrag)
varying vec2 texcoord0;
varying vec4 colorscale;
varying vec2 bounds;
@(? (grassopt "b") [uniform sampler2D tex1; varying vec2 texcoord1;])
in vec2 texcoord0;
in vec4 colorscale;
@(? (grassopt "b") [uniform sampler2D tex1; in vec2 texcoord1;])
void main(void)
{
vec4 color = texture2D(tex0, texcoord0) * colorscale;
color.a *= clamp(min(bounds.x, bounds.y), 0.0, 1.0);
vec4 color = texture(tex0, texcoord0) * colorscale;
@(? (grassopt "b") [
color.a *= texture2D(tex1, texcoord1).r;
color.a *= texture(tex1, texcoord1).r;
])
vec2 coords = fract((gl_FragCoord.xy - 0.5)*0.5);
float dither = coords.x + 1.5*coords.y - 4.0*coords.x*coords.y + 0.25;
if(color.a <= grasstest * dither)
if(color.a <= grasstest)
discard;
gcolor = vec4(color.rgb, 0.0);
@(gnormpack [vec3(0.5, 0.5, 1.0)])

View File

@ -5,11 +5,11 @@
///////////////////////////////////////////////////
shader 0 "hud" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -18,22 +18,22 @@ shader 0 "hud" [
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "hudtext" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -43,12 +43,12 @@ shader 0 "hudtext" [
] [
uniform sampler2D tex0;
uniform vec4 textparams;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
float dist = texture2D(tex0, texcoord0).r;
float dist = texture(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);
@ -56,11 +56,11 @@ shader 0 "hudtext" [
]
shader 0 "hudrgb" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -69,29 +69,29 @@ shader 0 "hudrgb" [
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
fragcolor.rgb = colorscale.rgb * color.rgb;
fragcolor.a = colorscale.a;
}
]
shader 0 "hudnotexture" [
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 hudmatrix;
varying vec4 color;
out vec4 color;
void main(void)
{
gl_Position = hudmatrix * vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;
@ -99,11 +99,11 @@ shader 0 "hudnotexture" [
]
shader 0 "hudrect" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 hudmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -112,21 +112,21 @@ shader 0 "hudrect" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
fragcolor = colorscale * textureRect(tex0, texcoord0);
}
]
shader 0 "hud3d" [
attribute vec4 vvertex, vcolor;
attribute vec3 vtexcoord0;
in vec4 vvertex, vcolor;
in vec3 vtexcoord0;
uniform mat4 hudmatrix;
varying vec3 texcoord0;
varying vec4 color;
out vec3 texcoord0;
out vec4 color;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -135,21 +135,21 @@ shader 0 "hud3d" [
}
] [
uniform sampler3D tex0;
varying vec3 texcoord0;
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec3 texcoord0;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color * texture3D(tex0, texcoord0);
fragcolor = color * texture(tex0, texcoord0);
}
]
shader 0 "hudcubemap" [
attribute vec4 vvertex, vcolor;
attribute vec3 vtexcoord0;
in vec4 vvertex, vcolor;
in vec3 vtexcoord0;
uniform mat4 hudmatrix;
varying vec3 texcoord0;
varying vec4 colorscale;
out vec3 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = hudmatrix * vvertex;
@ -158,12 +158,12 @@ shader 0 "hudcubemap" [
}
] [
uniform samplerCube tex0;
varying vec3 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec3 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = colorscale * textureCube(tex0, texcoord0);
fragcolor = colorscale * texture(tex0, texcoord0);
}
]

View File

@ -5,7 +5,7 @@
///////////////////////////////////////////////////
shader 0 "refractmask" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 camprojmatrix;
void main(void)
{
@ -14,7 +14,7 @@ shader 0 "refractmask" [
] [
@(gfetchdefs tex0)
uniform vec3 gdepthpackparams;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(if (= $gdepthformat 1) [result [
@ -28,7 +28,7 @@ shader 0 "refractmask" [
]
lazyshader 0 "waterminimap" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 camprojmatrix;
@(ginterpvert)
void main(void)
@ -50,16 +50,15 @@ lazyshader 0 "waterminimap" [
watershader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec3 camera;
uniform vec2 watertexgen;
uniform float millis;
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3;
varying vec3 surface;
out vec2 texcoord0, texcoord1;
out vec3 surface;
@(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix;
varying vec3 esurface;
out vec3 esurface;
])
@(ginterpvert 1)
void main(void)
@ -69,21 +68,17 @@ watershader = [
@(? (>= (strstr $arg1 "reflect") 0) [
esurface = (raymatrix * vvertex).xyz;
])
vec2 tc = vvertex.xy * watertexgen;
texcoord0 = tc * 0.18 + millis*vec2( 0.25, 0.75)*0.1250;
texcoord1 = tc * 0.18 + millis*vec2(-0.75, -0.25)*0.1450;
texcoord2 = tc * 0.08 + millis*vec2(-0.50, 0.50)*0.0805;
texcoord3 = tc * 0.08 + millis*vec2( 0.25, -0.75)*0.0825;
texcoord0 = vtexcoord0 * 0.18;
texcoord1 = vtexcoord0 * 0.08;
@(gdepthpackvert 1)
}
] [
@(gfetchdefs [tex7 tex8 tex9])
uniform float millis;
uniform vec3 camera;
uniform mat4 linearworldmatrix;
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3;
varying vec3 surface;
in vec2 texcoord0, texcoord1;
in vec3 surface;
uniform sampler2D tex0, tex1;
uniform vec4 viewsize;
uniform vec3 watercolor, waterdeepcolor, waterdeepfade;
@ -100,17 +95,17 @@ watershader = [
])
@(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix;
varying vec3 esurface;
in vec3 esurface;
])
@(ginterpfrag 1)
void main(void)
{
vec3 camdir = camera - surface, camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0).rgb;
vec3 bump2 = texture2D(tex1, texcoord1).rgb;
vec3 bump3 = texture2D(tex1, texcoord2).rgb;
vec3 bump4 = texture2D(tex1, texcoord3).rgb;
vec3 bump = texture(tex1, texcoord0 + millis*vec2( 0.25, 0.75)*0.1250).rgb;
vec3 bump2 = texture(tex1, texcoord0 + millis*vec2(-0.75, -0.25)*0.1450).rgb;
vec3 bump3 = texture(tex1, texcoord1 + millis*vec2(-0.50, 0.50)*0.0805).rgb;
vec3 bump4 = texture(tex1, texcoord1 + millis*vec2( 0.25, -0.75)*0.0825).rgb;
bump = normalize(bump + bump2 + bump3 + bump4 - 2.0);
vec2 rtc = bump.xy * waterrefract.w;
@ -131,7 +126,7 @@ watershader = [
@(? (>= (strstr $arg1 "caustics") 0) [
vec2 ctc = vec2(dot(causticsS, rpos.xyz), dot(causticsT, rpos.xyz));
float caustics = causticsblend.x*texture2D(tex2, ctc).r + causticsblend.y*texture2D(tex3, ctc).r + causticsblend.z;
float caustics = causticsblend.x*texture(tex2, ctc).r + causticsblend.y*texture(tex3, ctc).r + causticsblend.z;
rcolor *= caustics;
])
@ -162,7 +157,7 @@ watershader = [
float fresnel = 0.25 + 0.75*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel*edgefade);
]] [if (>= (strstr $arg1 "env") 0) [result [
vec3 reflect = textureCube(tex4, reflectdir).rgb*0.5;
vec3 reflect = texture(tex4, reflectdir).rgb*0.5;
float fresnel = 0.5*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel);
]]])
@ -186,7 +181,7 @@ watershader "underwater"
causticshader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
@ -197,7 +192,7 @@ causticshader = [
uniform vec3 causticsblend;
uniform sampler2D tex0, tex1;
uniform vec4 waterdeepfade;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
@ -206,7 +201,7 @@ causticshader = [
vec4 ctc = causticsmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
ctc.xyz /= ctc.w;
])
float caustics = causticsblend.x*texture2D(tex0, ctc.xy).r + causticsblend.y*texture2D(tex1, ctc.xy).r + causticsblend.z;
float caustics = causticsblend.x*texture(tex0, ctc.xy).r + causticsblend.y*texture(tex1, ctc.xy).r + causticsblend.z;
caustics *= clamp(ctc.z, 0.0, 1.0) * clamp(exp2(ctc.z*waterdeepfade.w), 0.0, 1.0);
fragcolor.rgb = vec3(0.5 + caustics);
}
@ -216,7 +211,7 @@ causticshader caustics
waterfogshader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
@ -229,7 +224,7 @@ waterfogshader = [
uniform vec2 fogdensity;
uniform vec3 waterdeepcolor, waterdeepfade;
uniform float waterheight;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
@ -251,34 +246,33 @@ waterfogshader = [
waterfogshader waterfog
lazyshader 0 "lava" [
attribute vec4 vvertex;
attribute vec3 vnormal;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
uniform vec4 lavatexgen;
varying vec2 texcoord0;
out mat3 world;
out vec2 texcoord0;
@(ginterpvert)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
vec2 tc = vec2(dot(vvertex.xy, tangent.xy), dot(vvertex.yz, bitangent.yz));
texcoord0 = (tc + lavatexgen.zw) * lavatexgen.xy;
@(gdepthpackvert)
}
] [
uniform sampler2D tex0, tex1;
uniform float lavaglow, lavaspec;
varying mat3 world;
varying vec2 texcoord0;
in mat3 world;
in vec2 texcoord0;
@(ginterpfrag)
void main(void)
{
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0-1.0;
vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture(tex1, texcoord0).rgb*2.0-1.0;
vec3 bumpw = normalize(world * bump);
gcolor.rgb = diffuse;
@(gspecpack 0.0 lavaspec)
@ -289,24 +283,23 @@ lazyshader 0 "lava" [
]
lazyshader 0 "waterfallenv" [
attribute vec4 vvertex;
attribute vec3 vnormal;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 camera;
varying vec3 camdir;
varying mat3 world;
uniform vec4 waterfalltexgen;
varying vec2 texcoord0;
out vec3 camdir;
out mat3 world;
out vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
camdir = camera.xyz - vvertex.xyz;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
vec2 tc = vec2(dot(vvertex.xy, tangent.xy), dot(vvertex.yz, bitangent.yz));
texcoord0 = (tc + waterfalltexgen.zw) * waterfalltexgen.xy;
@(gdepthpackvert 1)
}
] [
@ -317,16 +310,16 @@ lazyshader 0 "waterfallenv" [
uniform float waterfallspec;
uniform vec4 waterfallrefract;
uniform float refractdepth;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
in vec3 camdir;
in mat3 world;
in vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 camvec = normalize(camdir);
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w;
@ -335,7 +328,7 @@ lazyshader 0 "waterfallenv" [
vec3 rcolor = gfetch(tex8, rtc).rgb * waterfallrefract.xyz;
float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex3, 2.0*bumpw*invfresnel - camvec).rgb;
vec3 env = texture(tex3, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0);
@ -347,21 +340,20 @@ lazyshader 0 "waterfallenv" [
]
lazyshader 0 "waterfall" [
attribute vec4 vvertex;
attribute vec3 vnormal;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
uniform vec4 waterfalltexgen;
varying vec2 texcoord0;
out mat3 world;
out vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
vec2 tc = vec2(dot(vvertex.xy, tangent.xy), dot(vvertex.yz, bitangent.yz));
texcoord0 = (tc + waterfalltexgen.zw) * waterfalltexgen.xy;
@(gdepthpackvert 1)
}
] [
@ -371,14 +363,14 @@ lazyshader 0 "waterfall" [
uniform float waterfallspec;
uniform vec4 waterfallrefract;
uniform float refractdepth;
varying mat3 world;
varying vec2 texcoord0;
in mat3 world;
in vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 diffuse = texture2D(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w;
@ -395,24 +387,23 @@ lazyshader 0 "waterfall" [
]
lazyshader 0 "glassenv" [
attribute vec4 vvertex;
attribute vec3 vnormal;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 camera;
varying vec3 camdir;
varying mat3 world;
uniform vec2 glasstexgen;
varying vec2 texcoord0;
out vec3 camdir;
out mat3 world;
out vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
camdir = camera.xyz - vvertex.xyz;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
vec2 tc = vec2(dot(vvertex.xy, tangent.xy), dot(vvertex.yz, bitangent.yz));
texcoord0 = tc * glasstexgen;
@(gdepthpackvert 1)
}
] [
@ -422,15 +413,15 @@ lazyshader 0 "glassenv" [
uniform float glassspec;
uniform vec4 glassrefract;
uniform float refractdepth;
varying vec3 camdir;
varying mat3 world;
varying vec2 texcoord0;
in vec3 camdir;
in mat3 world;
in vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w;
@ -440,7 +431,7 @@ lazyshader 0 "glassenv" [
rcolor *= glassrefract.xyz;
float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex0, 2.0*bumpw*invfresnel - camvec).rgb;
vec3 env = texture(tex0, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0);
@ -452,21 +443,20 @@ lazyshader 0 "glassenv" [
]
lazyshader 0 "glass" [
attribute vec4 vvertex;
attribute vec3 vnormal;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying mat3 world;
uniform vec2 glasstexgen;
varying vec2 texcoord0;
out mat3 world;
out vec2 texcoord0;
@(ginterpvert 1)
void main(void)
{
gl_Position = camprojmatrix * vvertex;
texcoord0 = vtexcoord0;
vec3 tangent = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), abs(vnormal.x));
vec3 bitangent = mix(vec3(0.0, 0.0, -1.0), vec3(0.0, 1.0, 0.0), abs(vnormal.z));
world = mat3(tangent, bitangent, vnormal);
vec2 tc = vec2(dot(vvertex.xy, tangent.xy), dot(vvertex.yz, bitangent.yz));
texcoord0 = tc * glasstexgen;
@(gdepthpackvert 1)
}
] [
@ -475,13 +465,13 @@ lazyshader 0 "glass" [
uniform float glassspec;
uniform vec4 glassrefract;
uniform float refractdepth;
varying mat3 world;
varying vec2 texcoord0;
in mat3 world;
in vec2 texcoord0;
@(ginterpfrag 1)
void main(void)
{
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w;

View File

@ -1,11 +1,11 @@
shader 0 "null" [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = vec4(1.0, 0.0, 1.0, 1.0);
@ -19,7 +19,7 @@ shader 0 "null" [
//////////////////////////////////////////////////////////////////////
shader 0 "nocolor" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 camprojmatrix;
void main() { gl_Position = camprojmatrix * vvertex; }
] [
@ -27,7 +27,7 @@ shader 0 "nocolor" [
]
shader 0 "bbquery" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 camprojmatrix;
uniform vec3 bborigin, bbsize;
void main() { gl_Position = camprojmatrix * vec4(bborigin + vvertex.xyz*bbsize, vvertex.w); }
@ -36,9 +36,9 @@ shader 0 "bbquery" [
]
shader 0 "depth" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 camprojmatrix;
@(ginterpdepth)
@(ginterpdepth out)
void main()
{
gl_Position = camprojmatrix * vvertex;
@ -46,9 +46,9 @@ shader 0 "depth" [
}
] [
@(? $gdepthformat [
fragdata(0) vec4 gdepth;
layout(location = 0) out vec4 gdepth;
])
@(ginterpdepth)
@(ginterpdepth in)
void main()
{
@(if (= $gdepthformat 1) [result [
@ -68,12 +68,12 @@ shader 0 "depth" [
//////////////////////////////////////////////////////////////////////
shader 0 "ldr" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -82,29 +82,29 @@ shader 0 "ldr" [
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "ldrnotexture" [
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec4 color;
out vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vec4(ldrscale * vcolor.rgb, vcolor.a);
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;
@ -119,11 +119,11 @@ shader 0 "ldrnotexture" [
shader 0 "fogged" [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
varying vec2 texcoord0;
varying vec4 colorscale;
out vec2 texcoord0;
out vec4 colorscale;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -132,29 +132,29 @@ shader 0 "fogged" [
}
] [
uniform sampler2D tex0;
varying vec2 texcoord0;
varying vec4 colorscale;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
in vec4 colorscale;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "foggednotexture" [
//:fog
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
varying vec4 color;
out vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;
@ -162,16 +162,16 @@ shader 0 "foggednotexture" [
]
shader 0 "fogoverlay" [
attribute vec4 vvertex, vcolor;
varying vec4 color;
in vec4 vvertex, vcolor;
out vec4 color;
void main(void)
{
gl_Position = vvertex;
color = vcolor;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;

View File

@ -20,7 +20,7 @@ qtangentdecode = [
skelanimdefs = [
result [
attribute vec4 vboneweight, vboneindex;
in vec4 vboneweight, vboneindex;
//:uniform animdata
uniform vec4 animdata[@@(min $maxvsuniforms $maxskelanimdata)];
]
@ -72,13 +72,13 @@ shadowmodelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex;
in vec4 vvertex;
@(if (mdlopt "b") [skelanimdefs $arg2])
uniform mat4 modelmatrix;
@(? (mdlopt "a") [
attribute vec2 vtexcoord0;
in vec2 vtexcoord0;
uniform vec2 texscroll;
varying vec2 texcoord0;
out vec2 texcoord0;
])
void main(void)
{
@ -104,12 +104,12 @@ shadowmodelfragmentshader = [
@(? (mdlopt "a") [
uniform sampler2D tex0;
uniform float alphatest;
varying vec2 texcoord0;
in vec2 texcoord0;
])
void main(void)
{
@(? (mdlopt "a") [
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
if(color.a <= alphatest)
discard;
])
@ -139,29 +139,28 @@ shadowmodelshader "alphashadowmodel" "a"
// b -> dual-quat skeletal animation
// c -> disable cullface
// t -> transparent
// u -> dither
modelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex, vtangent;
attribute vec2 vtexcoord0;
in vec4 vvertex, vtangent;
in vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix;
uniform mat3 modelworld;
uniform vec3 modelcamera;
uniform vec2 texscroll;
@(? (mdlopt "n") [
varying mat3 world;
out mat3 world;
] [
varying vec3 nvec;
out vec3 nvec;
])
@(? (mdlopt "e") [
varying vec3 camvec;
out vec3 camvec;
])
@(msaainterpvert)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -202,13 +201,13 @@ modelfragmentshader = [
modeltype = $arg1
result [
@(? (mdlopt "n") [
varying mat3 world;
in mat3 world;
] [
varying vec3 nvec;
in vec3 nvec;
])
@(? (mdlopt "e") [
uniform vec2 envmapscale;
varying vec3 camvec;
in vec3 camvec;
])
uniform vec4 colorscale;
uniform vec2 fullbright;
@ -220,29 +219,22 @@ modelfragmentshader = [
@(? (mdlopt "n") [uniform sampler2D tex3;])
@(? (|| (mdlopt "d") [mdlopt "D"]) [uniform sampler2D tex4;])
@(msaainterpfrag)
varying vec2 texcoord0;
in vec2 texcoord0;
uniform float aamask;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
vec4 diffuse = texture(tex0, texcoord0);
@(if (mdlopt "a") [
? (mdlopt "u") [
vec2 coords = fract((gl_FragCoord.xy - 0.5)*0.5);
float dither = coords.x + 1.5*coords.y - 4.0*coords.x*coords.y + 0.25;
if(diffuse.a <= alphatest * dither)
discard;
] [
if(diffuse.a <= alphatest)
discard;
]
@(? (mdlopt "a") [
if(diffuse.a <= alphatest)
discard;
])
gcolor.rgb = diffuse.rgb*colorscale.rgb;
@(? (|| (mdlopt "d") [mdlopt "D"]) [
vec4 decal = texture2D(tex4, texcoord0);
vec4 decal = texture(tex4, texcoord0);
@(? (mdlopt "D") [
gcolor.rgb = mix(gcolor.rgb, decal.rgb, decal.a);
] [
@ -251,7 +243,7 @@ modelfragmentshader = [
])
@(if (mdlopt "n") [result [
vec3 normal = texture2D(tex3, texcoord0).rgb - 0.5;
vec3 normal = texture(tex3, texcoord0).rgb - 0.5;
@(? (mdlopt "c") [
if(!gl_FrontFacing) normal.z = -normal.z;
])
@ -265,7 +257,7 @@ modelfragmentshader = [
float spec = maskscale.x;
@(if (mdlopt "m") [result [
vec3 masks = texture2D(tex1, texcoord0).rgb;
vec3 masks = texture(tex1, texcoord0).rgb;
spec *= masks.r; // specmap in red channel
@(? (mdlopt "e") [
@ -273,7 +265,7 @@ modelfragmentshader = [
float invfresnel = dot(camn, normal);
vec3 rvec = 2.0*invfresnel*normal - camn;
float rmod = envmapscale.x*clamp(invfresnel, 0.0, 1.0) + envmapscale.y;
vec3 reflect = textureCube(tex2, rvec).rgb;
vec3 reflect = texture(tex2, rvec).rgb;
gcolor.rgb = mix(gcolor.rgb, reflect, rmod*masks.b); // envmap mask in blue channel
])
@ -316,14 +308,14 @@ rsmmodelvertexshader = [
local modeltype
modeltype = $arg1
result [
attribute vec4 vvertex, vtangent;
attribute vec2 vtexcoord0;
in vec4 vvertex, vtangent;
in vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix;
uniform mat3 modelworld;
uniform vec2 texscroll;
varying vec2 texcoord0;
varying vec3 nvec;
out vec2 texcoord0;
out vec3 nvec;
void main(void)
{
@(if (mdlopt "b") [
@ -347,17 +339,17 @@ rsmmodelfragmentshader = [
local modeltype
modeltype = $arg1
result [
varying vec2 texcoord0;
varying vec3 nvec;
in vec2 texcoord0;
in vec3 nvec;
uniform vec4 colorscale;
@(? (mdlopt "a") [uniform float alphatest;])
uniform vec3 rsmdir;
uniform sampler2D tex0;
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
vec4 diffuse = texture(tex0, texcoord0);
@(? (mdlopt "a") [
if(diffuse.a <= alphatest)
discard;

View File

@ -5,9 +5,9 @@
////////////////////////////////////////////////
lazyshader 0 "moviergb" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -15,18 +15,18 @@ lazyshader 0 "moviergb" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
fragcolor = textureRect(tex0, texcoord0);
}
]
lazyshader 0 "movieyuv" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -34,11 +34,11 @@ lazyshader 0 "movieyuv" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb;
vec3 color = textureRect(tex0, texcoord0).rgb;
fragcolor = vec4(dot(color, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color, vec3(-0.148224, -0.290992, 0.439216)) + 0.501961,
dot(color, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
@ -47,9 +47,9 @@ lazyshader 0 "movieyuv" [
]
lazyshader 0 "moviey" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -57,14 +57,14 @@ lazyshader 0 "moviey" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2( -2, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2( -1, 0)).rgb;
vec3 color3 = texture2DRect(tex0, texcoord0).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2( -2, 0)).rgb;
vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2( -1, 0)).rgb;
vec3 color3 = textureRect(tex0, texcoord0).rgb;
vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color2, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color1, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
@ -73,9 +73,9 @@ lazyshader 0 "moviey" [
]
lazyshader 0 "movieu" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -83,14 +83,14 @@ lazyshader 0 "movieu" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color2, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color1, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
@ -99,9 +99,9 @@ lazyshader 0 "movieu" [
]
lazyshader 0 "moviev" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -109,14 +109,14 @@ lazyshader 0 "moviev" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color2, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color1, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,

View File

@ -11,18 +11,18 @@
explosionshader = [
shader 0 $arg1 [
//:fog
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 explosionmatrix;
uniform vec3 center;
uniform float millis;
attribute vec2 vtexcoord0;
in vec2 vtexcoord0;
uniform vec4 texgenS, texgenT;
@(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale;
varying float lineardepth;
out float lineardepth;
])
varying vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2;
out vec4 color;
out vec2 texcoord0, texcoord1, texcoord2;
void main(void)
{
vec4 wobble = vec4(vvertex.xyz*(1.0 + 0.5*abs(fract(dot(vvertex.xyz, center) + millis*2.0) - 0.5)), vvertex.w);
@ -42,17 +42,17 @@ explosionshader = [
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2)
uniform vec3 softparams;
varying float lineardepth;
in float lineardepth;
]])
varying vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2;
in vec4 color;
in vec2 texcoord0, texcoord1, texcoord2;
uniform sampler2D tex0;
uniform vec2 blendparams;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec2 dtc = texcoord0 + texture2D(tex0, texcoord2).xy*0.1; // use color texture as noise to distort texcoords
vec4 diffuse = texture2D(tex0, dtc);
vec2 dtc = texcoord0 + texture(tex0, texcoord2).xy*0.1; // use color texture as noise to distort texcoords
vec4 diffuse = texture(tex0, dtc);
float blend = max(pow(clamp(1.0 - dot(texcoord1, texcoord1), 0.0, 1.0), blendparams.x), blendparams.y);
diffuse *= blend*4.0; // dup alpha into RGB channels + intensify and over saturate
diffuse.b += 0.5 - blend*0.5; // blue tint
@ -74,18 +74,18 @@ explosionshader "explosionsoft"
shader 0 "particlenotexture" [
//:fog
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
out vec4 color;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
color = vcolor * colorscale;
}
] [
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;
@ -94,12 +94,12 @@ shader 0 "particlenotexture" [
shader 0 "particletext" [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform float ldrscale;
varying vec4 color;
varying vec2 texcoord0;
out vec4 color;
out vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -109,12 +109,12 @@ shader 0 "particletext" [
] [
uniform vec4 textparams;
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 color;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
float dist = texture2D(tex0, texcoord0).r;
float dist = texture(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(color.rgb * outline, color.a * border);
@ -124,16 +124,16 @@ shader 0 "particletext" [
particleshader = [
shader 0 $arg1 [
//:fog
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
varying vec2 texcoord0;
out vec4 color;
out vec2 texcoord0;
@(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale;
varying float lineardepth;
varying vec2 surface;
out float lineardepth;
out vec2 surface;
])
void main(void)
{
@ -150,16 +150,16 @@ particleshader = [
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2)
uniform vec3 softparams;
varying float lineardepth;
varying vec2 surface;
in float lineardepth;
in vec2 surface;
]])
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 color;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
vec4 diffuse = texture(tex0, texcoord0);
@(if (>= (strstr $arg1 "soft") 0) [result [
@(gdepthunpack depth [gfetch(tex2, gl_FragCoord.xy)])

View File

@ -5,9 +5,9 @@
////////////////////////////////////////////////
fsvs = [result [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
@arg2
void main(void)
{
@ -19,12 +19,12 @@ fsvs = [result [
fsps = [result [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
@arg2
void main(void)
{
vec4 color = texture2DRect(tex0, texcoord0);
vec4 color = textureRect(tex0, texcoord0);
@arg1
}
]]
@ -37,19 +37,19 @@ fsvs4 = [
texcoord4 = vtexcoord0 + vec2( 1.5, 1.5);
@arg1
] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4;
out vec2 texcoord1, texcoord2, texcoord3, texcoord4;
]
]
fsps4 = [
fsps [
vec4 s00 = texture2DRect(tex0, texcoord1);
vec4 s02 = texture2DRect(tex0, texcoord2);
vec4 s20 = texture2DRect(tex0, texcoord3);
vec4 s22 = texture2DRect(tex0, texcoord4);
vec4 s00 = textureRect(tex0, texcoord1);
vec4 s02 = textureRect(tex0, texcoord2);
vec4 s20 = textureRect(tex0, texcoord3);
vec4 s22 = textureRect(tex0, texcoord4);
@arg1
] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4;
in vec2 texcoord1, texcoord2, texcoord3, texcoord4;
]
]
@ -70,10 +70,10 @@ lazyshader 0 "sobel" (fsvs4) (fsps4 [
// rotoscope
lazyshader 0 "rotoscope" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
uniform vec4 params;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
out vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
void main(void)
{
gl_Position = vvertex;
@ -89,19 +89,19 @@ lazyshader 0 "rotoscope" [
}
] [
uniform sampler2DRect tex0;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
fragdata(0) vec4 fragcolor;
in vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 c00 = texture2DRect(tex0, t00);
vec4 c01 = texture2DRect(tex0, t01);
vec4 c02 = texture2DRect(tex0, t02);
vec4 c10 = texture2DRect(tex0, t10);
vec4 c11 = texture2DRect(tex0, t11);
vec4 c12 = texture2DRect(tex0, t12);
vec4 c20 = texture2DRect(tex0, t20);
vec4 c21 = texture2DRect(tex0, t21);
vec4 c22 = texture2DRect(tex0, t22);
vec4 c00 = textureRect(tex0, t00);
vec4 c01 = textureRect(tex0, t01);
vec4 c02 = textureRect(tex0, t02);
vec4 c10 = textureRect(tex0, t10);
vec4 c11 = textureRect(tex0, t11);
vec4 c12 = textureRect(tex0, t12);
vec4 c20 = textureRect(tex0, t20);
vec4 c21 = textureRect(tex0, t21);
vec4 c22 = textureRect(tex0, t22);
vec4 diag1 = c00 - c22;
vec4 diag2 = c02 - c20;
@ -125,9 +125,9 @@ lazyshader 0 "rotoscope" [
blur3shader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1;
out vec2 texcoord0, texcoord1;
void main(void)
{
gl_Position = vvertex;
@ -136,11 +136,11 @@ blur3shader = [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0, texcoord1;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = 0.5*(texture2DRect(tex0, texcoord0) + texture2DRect(tex0, texcoord1));
fragcolor = 0.5*(textureRect(tex0, texcoord0) + textureRect(tex0, texcoord1));
}
]
]
@ -149,9 +149,9 @@ blur3shader vblur3 0 1
blur5shader = [
lazyshader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2;
out vec2 texcoord0, texcoord1, texcoord2;
void main(void)
{
gl_Position = vvertex;
@ -161,11 +161,11 @@ blur5shader = [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1, texcoord2;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0, texcoord1, texcoord2;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = 0.4*texture2DRect(tex0, texcoord0) + 0.3*(texture2DRect(tex0, texcoord1) + texture2DRect(tex0, texcoord2));
fragcolor = 0.4*textureRect(tex0, texcoord0) + 0.3*(textureRect(tex0, texcoord1) + textureRect(tex0, texcoord2));
}
]
]

View File

@ -5,9 +5,9 @@
//////////////////////////////////////////////////////////////////////
shader 0 "scalelinear" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -16,20 +16,20 @@ shader 0 "scalelinear" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
fragcolor = textureRect(tex0, texcoord0);
}
]
loop i 2 [
lazyshader 0 (? $i "scalecubicy" "scalecubicx") [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -38,8 +38,8 @@ loop i 2 [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
vec4 cubic(float s)
{
@ -57,13 +57,13 @@ loop i 2 [
@(if $i [result [
float offset = fract(texcoord0.y-0.5);
center.y -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(0.0, tap))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(0, tap))
#define texval(tap) textureRect(tex0, center + vec2(0.0, tap))
#define texvaloffset(tap) textureRectOffset(tex0, center, ivec2(0, tap))
]] [result [
float offset = fract(texcoord0.x-0.5);
center.x -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(tap, 0.0))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(tap, 0))
#define texval(tap) textureRect(tex0, center + vec2(tap, 0.0))
#define texvaloffset(tap) textureRectOffset(tex0, center, ivec2(tap, 0))
]])
vec4 weight = cubic(offset);
weight.y += weight.z;
@ -74,9 +74,9 @@ loop i 2 [
]
shader 0 "reorient" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform vec3 reorientx, reorienty;
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -86,12 +86,12 @@ shader 0 "reorient" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = texture2DRect(tex0, texcoord0);
fragcolor = textureRect(tex0, texcoord0);
}
]

View File

@ -8,26 +8,26 @@ ginterpdepth = [
result [
uniform vec2 lineardepthscale;
uniform vec3 gdepthpackparams;
varying float lineardepth;
@arg1 float lineardepth;
]
]
ginterpvert = [
if (|| $gdepthformat $arg1) [ginterpdepth]
if (|| $gdepthformat $arg1) [ginterpdepth out]
]
msaainterpvert = [ginterpvert $msaasamples]
ginterpfrag = [
result [
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
@(? $gdepthformat [
fragdata(2) vec4 gdepth;
fragdata(3) vec4 gglow;
layout(location = 2) out vec4 gdepth;
layout(location = 3) out vec4 gglow;
] [
fragdata(2) vec4 gglow;
layout(location = 2) out vec4 gglow;
])
@(if (|| $gdepthformat $arg1) [ginterpdepth])
@(if (|| $gdepthformat $arg1) [ginterpdepth in])
]
]
msaainterpfrag = [ginterpfrag $msaasamples]
@ -161,9 +161,9 @@ gfetchdefs = [
@(if (! $arg3) [gdepthunpackparams])
]] [result [
uniform sampler2DRect @(prettylist $arg1);
#define @[gfetchprefix](sampler, coords) texture2DRect(sampler, coords)
#define @[gfetchprefix]offset(sampler, coords, offset) texture2DRectOffset(sampler, coords, offset)
#define @[gfetchprefix]proj(sampler, coords) texture2DRectProj(sampler, coords)
#define @[gfetchprefix](sampler, coords) textureRect(sampler, coords)
#define @[gfetchprefix]offset(sampler, coords, offset) textureRectOffset(sampler, coords, offset)
#define @[gfetchprefix]proj(sampler, coords) textureRectProj(sampler, coords)
@(if (! $arg3) [gdepthunpackparams])
]]
]

View File

@ -5,12 +5,12 @@
////////////////////////////////////////////////
shader 0 "skybox" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
out vec4 colorscale;
out vec2 texcoord0;
void main(void)
{
gl_Position = skymatrix * vvertex;
@ -19,23 +19,23 @@ shader 0 "skybox" [
}
] [
uniform sampler2D tex0;
varying vec4 colorscale;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 colorscale;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color;
}
]
shader 0 "skyboxoverbright" [
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
out vec4 colorscale;
out vec2 texcoord0;
void main(void)
{
gl_Position = skymatrix * vvertex;
@ -46,12 +46,12 @@ shader 0 "skyboxoverbright" [
uniform sampler2D tex0;
uniform vec3 overbrightparams;
uniform float ldrscale;
varying vec4 colorscale;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 colorscale;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec4 color = texture2D(tex0, texcoord0);
vec4 color = texture(tex0, texcoord0);
float lum = dot(vec3(@lumweights), color.rgb);
float overbright = mix(overbrightparams.x, overbrightparams.y, clamp(lum - overbrightparams.z, 0.0, 1.0));
color.rgb *= overbright;
@ -60,9 +60,9 @@ shader 0 "skyboxoverbright" [
]
shader 0 "atmosphere" [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 sunmatrix;
varying vec3 camvec;
out vec3 camvec;
void main(void)
{
gl_Position = vvertex;
@ -71,63 +71,81 @@ shader 0 "atmosphere" [
camvec = p.xyz / p.w;
}
] [
uniform vec4 sunlight;
// adapted from http://blog.cloudparty.com/2013/09/25/stunning-procedural-skies-in-webgl-part-2/
uniform vec3 sunlight;
uniform vec3 sundir;
uniform vec3 sunweight;
uniform vec3 sundiskcolor;
uniform vec2 sundiskparams;
uniform vec4 opticaldepthparams;
uniform vec3 mieparams;
uniform vec3 betarayleigh, betamie, betaozone;
uniform vec3 sundiskparams;
uniform vec3 atmoradius;
uniform float gm;
uniform vec3 betar, betam, betarm;
uniform vec2 hdrgamma;
varying vec3 camvec;
fragdata(0) vec4 fragcolor;
uniform float atmoalpha;
in vec3 camvec;
layout(location = 0) out vec4 fragcolor;
vec3 calcextinction(float dist)
{
return exp2(-dist * betarm);
}
vec3 calcscatter(float costheta)
{
float rphase = 1.0 + costheta*costheta;
float mphase = pow(1.0 + gm*(gm - 2.0*costheta), -1.5);
return betar*rphase + betam*mphase;
}
float baseopticaldepth(vec3 ray)
{
float a = atmoradius.x * max(ray.z, min(sundir.z, 0.0));
return sqrt(a*a + atmoradius.z) - a;
}
float opticaldepth(vec3 pos, vec3 ray)
{
pos.z = max(pos.z, 0.0) + atmoradius.x;
float a = dot(pos, ray);
return sqrt(a*a + atmoradius.y - dot(pos, pos)) - a;
}
void main(void)
{
vec3 camdir = normalize(camvec);
float costheta = dot(camdir, sundir);
// sun disk
float edgeoffset = max(1.0 - (1.0 - max(costheta, 0.0)*costheta)*sundiskparams.x, 0.0);
// limb darken with distance to edge
vec3 limbdarken = pow(vec3(edgeoffset), vec3(0.397, 0.503, 0.64));
// lighten edges for corona, but limit it to not interfere with limb darkening
float corona = min(edgeoffset * sundiskparams.y, 1.0);
corona = max(0.1725 / (1.15 - corona * corona) - 0.15, 0.0);
// apply limb darkening and corona to clamped sunlight color
vec3 sundisk = sundiskcolor * limbdarken * corona;
// optical depth along view ray
float offset = camdir.z*opticaldepthparams.w;
vec3 depth = sqrt(offset*offset + opticaldepthparams.xyz) - offset;
vec3 rayleighweight = betarayleigh * depth.x;
vec3 mieweight = betamie * depth.y;
vec3 ozoneweight = betaozone * (depth.z - depth.x);
float raydist = baseopticaldepth(camdir);
// extinction of light along view ray
vec3 viewweight = sunweight - (rayleighweight + mieweight + ozoneweight);
vec3 extinction = (exp2(viewweight) - 1.0) / viewweight;
// calculate in-scattering
float rphase = (1.5 + 0.5*costheta*costheta) * (3.0 / (16.0 * 3.14159265));
float mphase = inversesqrt(mieparams.x + mieparams.y*min(costheta, mieparams.z));
vec3 scatter = rayleighweight * rphase + mieweight * (mphase * mphase * mphase);
vec3 extinction = calcextinction(raydist);
// combine scattering and extinction with sundisk
vec3 inscatter = (sunlight.rgb * scatter + sundisk) * extinction;
// optical depth for incoming light hitting the view ray
float lightraydist = opticaldepth(camdir * (raydist * max(0.15 + 0.75 * sundir.z, 0.0)), sundir);
// cast a ray towards the sun and calculate the incoming extincted light
vec3 incominglight = calcextinction(lightraydist);
// calculate the in-scattering
vec3 scattering = calcscatter(costheta) * (1.0 - extinction);
// combine
vec3 inscatter = incominglight * scattering;
// sun disk
vec3 sundisk = sundiskparams.z * extinction * pow(clamp(costheta*sundiskparams.x + sundiskparams.y, 0.0, 1.0), 8.0);
inscatter += sundisk;
@(hdrgammaencode inscatter)
fragcolor = vec4(inscatter, sunlight.a);
fragcolor = vec4(sunlight * inscatter, atmoalpha);
}
]
shader 0 "skyfog" [
attribute vec4 vvertex, vcolor;
in vec4 vvertex, vcolor;
uniform mat4 skymatrix;
uniform float ldrscale;
varying vec4 color;
out vec4 color;
void main(void)
{
gl_Position = skymatrix * vvertex;
@ -135,8 +153,8 @@ shader 0 "skyfog" [
}
] [
uniform sampler2D tex0;
varying vec4 color;
fragdata(0) vec4 fragcolor;
in vec4 color;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = color;

View File

@ -93,9 +93,9 @@ smaadefs = [
]
shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -105,15 +105,15 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
] [
@smaadefs
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
// Calculate lumas:
float L = SMAA_LUMA(texture2DRect(tex0, texcoord0));
float Lleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)));
float Ltop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -1)));
float L = SMAA_LUMA(textureRect(tex0, texcoord0));
float Lleft = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(-1, 0)));
float Ltop = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, -1)));
// We do the usual threshold:
vec2 delta = abs(L - vec2(Lleft, Ltop));
@ -128,14 +128,14 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
])
{
// Calculate right and bottom deltas:
float Lright = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)));
float Lbottom = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, 1)));
float Lright = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(1, 0)));
float Lbottom = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, 1)));
// Calculate the maximum delta in the direct neighborhood:
vec2 maxDelta = max(delta, abs(L - vec2(Lright, Lbottom)));
// Calculate left-left and top-top deltas:
float Lleftleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0)));
float Ltoptop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -2)));
float Lleftleft = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(-2, 0)));
float Ltoptop = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, -2)));
// Calculate the final maximum delta:
maxDelta = max(maxDelta, abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop)));
@ -157,9 +157,9 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
]
shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -169,15 +169,15 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
] [
@smaadefs
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
// Calculate color deltas:
vec3 C = texture2DRect(tex0, texcoord0).rgb;
vec3 Cleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb);
vec3 Ctop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -1)).rgb);
vec3 C = textureRect(tex0, texcoord0).rgb;
vec3 Cleft = abs(C - textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb);
vec3 Ctop = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, -1)).rgb);
vec2 delta;
delta.x = max(max(Cleft.r, Cleft.g), Cleft.b);
delta.y = max(max(Ctop.r, Ctop.g), Ctop.b);
@ -194,11 +194,11 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
])
{
// Calculate right and bottom deltas:
vec3 Cright = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
vec3 Cbottom = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, 1)).rgb);
vec3 Cright = abs(C - textureRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
vec3 Cbottom = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, 1)).rgb);
// Calculate left-left and top-top deltas:
vec3 Cleftleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0)).rgb);
vec3 Ctoptop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -2)).rgb);
vec3 Cleftleft = abs(C - textureRectOffset(tex0, texcoord0, ivec2(-2, 0)).rgb);
vec3 Ctoptop = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, -2)).rgb);
// Calculate the maximum delta in the direct neighborhood:
vec3 t = max(max(Cright, Cbottom), max(Cleftleft, Ctoptop));
// Calculate the final maximum delta:
@ -214,9 +214,9 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
@smaadefs
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
out vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
void main(void)
{
@ -232,10 +232,10 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
}
] [
@smaadefs
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
in vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
uniform sampler2DRect tex0, tex1, tex2;
uniform vec4 subsamples;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
#if __VERSION__ >= 130 || defined(GL_EXT_gpu_shader4)
#define SMAARound(e) round(e)
@ -257,45 +257,45 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
* These functions allows to perform diagonal pattern searches.
*/
float SMAASearchDiagRightUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rg;
vec2 e = textureRectOffset(tex0, texcoord0, ivec2(1, -1)).rg;
vec2 texcoord = texcoord0 + vec2(1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break;
texcoord += vec2(1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return (texcoord.x - texcoord0.x) - 1.0;
}
float SMAASearchDiagLeftDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rg;
vec2 e = textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).rg;
vec2 texcoord = texcoord0 + vec2(-1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break;
texcoord += vec2(-1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return (texcoord0.x - texcoord.x) - 1.0 + SMAARound(e.y);
}
float SMAASearchDiagLeftUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(-1, -1)).rg;
vec2 e = textureRectOffset(tex0, texcoord5, ivec2(-1, -1)).rg;
vec2 texcoord = texcoord5 + vec2(-1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(-1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return (texcoord5.x - texcoord.x) - 1.0;
}
float SMAASearchDiagRightDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(1, 1)).rg;
vec2 e = textureRectOffset(tex0, texcoord5, ivec2(1, 1)).rg;
vec2 texcoord = texcoord5 + vec2(1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return (texcoord.x - texcoord5.x) - 1.0 + SMAARound(e.y);
}
@ -316,7 +316,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord));
return SMAA_AREA(textureRect(tex1, texcoord));
}
/**
@ -332,8 +332,8 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(0.25 - d.x, d.x, d.y, -0.25 - d.y) + texcoord0.xyxy;
vec4 c;
c.xy = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).rg;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).rg;
c.xy = textureRectOffset(tex0, coords.xy, ivec2(-1, 0)).rg;
c.zw = textureRectOffset(tex0, coords.zw, ivec2( 1, 0)).rg;
c.xz = SMAADecodeDiagBilinearAccess(c.xz);
c = SMAARound(c);
@ -349,9 +349,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(-d.xx, d.yy) + texcoord0.xyxy;
vec4 c;
c.x = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).g;
c.y = texture2DRectOffset(tex0, coords.xy, ivec2( 0, -1)).r;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).gr;
c.x = textureRectOffset(tex0, coords.xy, ivec2(-1, 0)).g;
c.y = textureRectOffset(tex0, coords.xy, ivec2( 0, -1)).r;
c.zw = textureRectOffset(tex0, coords.zw, ivec2( 1, 0)).gr;
vec2 e = 2.0 * c.xz + c.yw;
e *= step(d, vec2(float(SMAA_MAX_SEARCH_STEPS_DIAG) - 0.5));
@ -374,7 +374,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
*/
float SMAASearchLength(vec2 e, float bias, float scale) {
e.r = bias + e.r * scale;
return 255.0 * texture2DRect(tex2, e*vec2(float(SMAA_SEARCHTEX_WIDTH), float(SMAA_SEARCHTEX_HEIGHT))).r;
return 255.0 * textureRect(tex2, e*vec2(float(SMAA_SEARCHTEX_WIDTH), float(SMAA_SEARCHTEX_HEIGHT))).r;
}
/**
@ -388,12 +388,12 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
* Sampling with different offsets in each direction allows to disambiguate
* which edges are active from the four fetched ones.
*/
vec2 e = texture2DRect(tex0, texcoord1).rg;
vec2 e = textureRect(tex0, texcoord1).rg;
vec2 texcoord = texcoord1;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x -= 2.0;
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
// We correct the previous (-0.25, -0.125) offset we applied:
// The searches are bias by 1, so adjust the coords accordingly:
@ -402,34 +402,34 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
}
float SMAASearchXRight(void) {
vec2 e = texture2DRect(tex0, texcoord2).rg;
vec2 e = textureRect(tex0, texcoord2).rg;
vec2 texcoord = texcoord2;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x += 2.0;
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return texcoord.x - (0.25 + 1.0) + SMAASearchLength(e, 0.5, 0.5);
}
float SMAASearchYUp(void) {
vec2 e = texture2DRect(tex0, texcoord3).rg;
vec2 e = textureRect(tex0, texcoord3).rg;
vec2 texcoord = texcoord3;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y -= 2.0;
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return texcoord.y + (0.25 + 1.0) - SMAASearchLength(e.gr, 0.0, 0.5);
}
float SMAASearchYDown(void) {
vec2 e = texture2DRect(tex0, texcoord4).rg;
vec2 e = textureRect(tex0, texcoord4).rg;
vec2 texcoord = texcoord4;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y += 2.0;
e = texture2DRect(tex0, texcoord).rg;
e = textureRect(tex0, texcoord).rg;
}
return texcoord.y - (0.25 + 1.0) + SMAASearchLength(e.gr, 0.5, 0.5);
}
@ -450,7 +450,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord));
return SMAA_AREA(textureRect(tex1, texcoord));
}
//-----------------------------------------------------------------------------
@ -461,16 +461,16 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
vec2 SMAADetectHorizontalCornerPattern(vec3 coords, vec2 d) {
vec2 e;
if(d.x >= d.y) coords.x = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2(0, 1)).r;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(0, -2)).r;
e.r = textureRectOffset(tex0, coords.xy, ivec2(0, 1)).r;
e.g = textureRectOffset(tex0, coords.xy, ivec2(0, -2)).r;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
}
vec2 SMAADetectVerticalCornerPattern(vec3 coords, vec2 d) {
vec2 e;
if(d.x >= d.y) coords.y = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2( 1, 0)).g;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(-2, 0)).g;
e.r = textureRectOffset(tex0, coords.xy, ivec2( 1, 0)).g;
e.g = textureRectOffset(tex0, coords.xy, ivec2(-2, 0)).g;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
}
@ -483,7 +483,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
{
vec4 weights = vec4(0.0);
vec2 e = texture2DRect(tex0, texcoord5).rg;
vec2 e = textureRect(tex0, texcoord5).rg;
if (e.g > 0.5) { // Edge at north
#if SMAA_MAX_SEARCH_STEPS_DIAG > 0
@ -511,9 +511,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// filtering. Sampling at -0.25 (see CROSSING_OFFSET) enables to
// discern what value each edge has:
vec2 e;
e.x = texture2DRect(tex0, coords.xy).r;
e.x = textureRect(tex0, coords.xy).r;
// Fetch the right crossing edges:
e.y = texture2DRectOffset(tex0, coords.zy, ivec2(1, 0)).r;
e.y = textureRectOffset(tex0, coords.zy, ivec2(1, 0)).r;
// Ok, we know how this pattern looks like, now it is time for getting
// the actual area:
@ -544,9 +544,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Fetch the top crossing edges:
vec2 e;
e.x = texture2DRect(tex0, coords.xy).g;
e.x = textureRect(tex0, coords.xy).g;
// Fetch the bottom crossing edges:
e.y = texture2DRectOffset(tex0, coords.xz, ivec2(0, 1)).g;
e.y = textureRectOffset(tex0, coords.xz, ivec2(0, 1)).g;
// Get the area for this direction:
weights.ba = SMAAArea(d, e, subsamples.x);
@ -563,9 +563,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
]
shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
@ -574,10 +574,10 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
}
] [
@smaadefs
varying vec2 texcoord0;
in vec2 texcoord0;
uniform sampler2DRect tex0, tex1;
@(? (smaaopt "s") [uniform sampler2DRect tex2, tex3;])
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
// Neighborhood Blending Pixel Shader (Third Pass)
@ -585,9 +585,9 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
{
// Fetch the blending weights for current pixel:
vec4 a;
a.xz = texture2DRect(tex1, texcoord0).rb;
a.y = texture2DRectOffset(tex1, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex1, texcoord0, ivec2(1, 0)).a;
a.xz = textureRect(tex1, texcoord0).rb;
a.y = textureRectOffset(tex1, texcoord0, ivec2(0, 1)).g;
a.w = textureRectOffset(tex1, texcoord0, ivec2(1, 0)).a;
// Up to 4 lines can be crossing a pixel (one through each edge). We
// favor blending by choosing the line with the maximum weight for each
@ -604,19 +604,19 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
// We exploit bilinear filtering to mix current pixel with the chosen
// neighbor:
fragcolor = texture2DRect(tex0, texcoord0 + offset);
fragcolor = textureRect(tex0, texcoord0 + offset);
@(? (smaaopt "s") [
a.xz = texture2DRect(tex3, texcoord0).rb;
a.y = texture2DRectOffset(tex3, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex3, texcoord0, ivec2(1, 0)).a;
a.xz = textureRect(tex3, texcoord0).rb;
a.y = textureRectOffset(tex3, texcoord0, ivec2(0, 1)).g;
a.w = textureRectOffset(tex3, texcoord0, ivec2(1, 0)).a;
offset.x = a.w > a.z ? a.w : -a.z;
offset.y = a.y > a.x ? a.y : -a.x;
if (abs(offset.x) > abs(offset.y))
offset.y = 0.0;
else
offset.x = 0.0;
fragcolor = 0.5*(fragcolor + texture2DRect(tex2, texcoord0 + offset));
fragcolor = 0.5*(fragcolor + textureRect(tex2, texcoord0 + offset));
])
}
]

View File

@ -1,172 +0,0 @@
// shadow map filters, arg1 enables color sampling
smfiltercolor = [result [
#define filtercolorshadow(tex, tc) texture2DRect(tex, tc.xy @(if $numargs [result [* @arg1]])).rgb
]]
smfilterg5 = [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec2 center = (shadowtc.xy - offset) * shadowatlasscale;
vec4 group1 = shadowgather(center, -2, -2);
vec4 group2 = shadowgather(center, 0, -2);
vec4 group3 = shadowgather(center, 2, -2);
vec4 group4 = shadowgather(center, -2, 0);
vec4 group5 = shadowgather(center, 0, 0);
vec4 group6 = shadowgather(center, 2, 0);
vec4 group7 = shadowgather(center, -2, 2);
vec4 group8 = shadowgather(center, 0, 2);
vec4 group9 = shadowgather(center, 2, 2);
vec4 locols = vec4(group1.ab, group3.ab);
vec4 hicols = vec4(group7.rg, group9.rg);
locols.yz += group2.ab;
hicols.yz += group8.rg;
vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +
vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +
mix(locols, hicols, offset.y);
vec4 cols = group5 + vec4(group2.rg, group8.ab);
cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);
return dot(cols, vec4(1.0/25.0));
}
@(if $arg1 [smfiltercolor 0.5])
]]
smfilterg3 = [result [
@(? (> $usetexgather 1) [
#define shadowgather(center, xoff, yoff) textureGatherOffset(tex4, center, shadowtc.z, ivec2(xoff, yoff))
] [
#define shadowgather(center, xoff, yoff) step(shadowtc.z, textureGatherOffset(tex4, center, ivec2(xoff, yoff)))
])
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec2 center = (shadowtc.xy - offset) * shadowatlasscale;
vec4 group1 = shadowgather(center, -1, -1);
vec4 group2 = shadowgather(center, 1, -1);
vec4 group3 = shadowgather(center, -1, 1);
vec4 group4 = shadowgather(center, 1, 1);
vec4 cols = vec4(group1.rg, group2.rg) + vec4(group3.ab, group4.ab) + mix(vec4(group1.ab, group2.ab), vec4(group3.rg, group4.rg), offset.y);
return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
}
@(if $arg1 [smfiltercolor 0.5])
]]
smfilterb5 = [result [
#define shadowval(xy, xoff, yoff) float(shadow2DRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec4 center = vec4(shadowtc.xy - offset + 0.5, shadowtc.xy - offset*0.5);
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/25.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center.zw, -1.5, -1.5),
shadowval(center.zw, 2.0, -1.5),
shadowval(center.zw, -1.5, 2.0),
shadowval(center.zw, 2.0, 2.0))) +
(2.0/25.0)*dot(size,
vec4(shadowval(center.zy, 2.0, 0.0),
shadowval(center.xw, 0.0, 2.0),
shadowval(center.zy, -1.5, 0.0),
shadowval(center.xw, 0.0, -1.5))) +
(4.0/25.0)*shadowval(center.xy, 0.0, 0.0);
}
@(if $arg1 [smfiltercolor 0.5])
]]
smfilterb3 = [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
vec2 offset = fract(shadowtc.xy - 0.5);
vec3 center = shadowtc;
//center.xy -= offset;
//vec4 size = vec4(offset + 1.0, 2.0 - offset), weight = vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0);
//return (1.0/9.0)*dot(size.zxzx*size.wwyy,
// vec4(shadowval(center, weight.zw),
// shadowval(center, weight.xw),
// shadowval(center, weight.zy),
// shadowval(center, weight.xy)));
center.xy -= offset*0.5;
vec4 size = vec4(offset + 1.0, 2.0 - offset);
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
vec4(shadowval(center, -0.5, -0.5),
shadowval(center, 1.0, -0.5),
shadowval(center, -0.5, 1.0),
shadowval(center, 1.0, 1.0)));
}
@(if $arg1 [smfiltercolor 0.5])
]]
smfilterrg = [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc)
{
return dot(vec4(0.25),
vec4(shadowval(shadowtc, -0.4, 1.0),
shadowval(shadowtc, -1.0, -0.4),
shadowval(shadowtc, 0.4, -1.0),
shadowval(shadowtc, 1.0, 0.4)));
}
@(if $arg1 [smfiltercolor 0.5])
]]
smfilternone = [result [
float filtershadow(vec3 shadowtc)
{
return float(shadow2DRect(tex4, shadowtc));
}
@(if $arg1 [smfiltercolor])
]]
lazyshader 0 "smalphaclear" [
attribute vec4 vvertex;
uniform vec2 shadowatlasscale;
void main(void)
{
gl_Position = vec4(vvertex.xy * shadowatlasscale * 2.0 - 1.0, 0.0, 1.0);
}
] [
fragdata(0) vec4 fragcolor;
void main(void)
{
fragcolor = vec4(1.0);
}
]
loop i 2 [
lazyshader 0 (? $i "smalphablur2d" "smalphablurrect") [
attribute vec4 vvertex;
attribute vec4 vtexcoord0;
uniform vec2 shadowatlasscale;
flat varying vec4 smbounds;
varying vec4 texcoord0;
void main(void)
{
gl_Position = vec4(vvertex.xy * shadowatlasscale * 2.0 - 1.0, 0.0, 1.0);
smbounds = (vtexcoord0 + vec4(0.5, 0.5, -0.5, -0.5)) @(? $i [* shadowatlasscale.xyxy]);
texcoord0 = (vvertex.xyxy + vec4(-1.0, -1.0, 1.0, 1.0)) @(? $i [* shadowatlasscale.xyxy]);
}
] [
@(? $i [
uniform sampler2D tex0;
#define texval(tc) texture2D(tex0, tc)
] [
uniform sampler2DRect tex0;
#define texval(tc) texture2DRect(tex0, tc)
])
flat varying vec4 smbounds;
varying vec4 texcoord0;
fragdata(0) vec4 fragcolor;
void main(void)
{
vec4 tc = vec4(max(texcoord0.xy, smbounds.xy), min(texcoord0.zw, smbounds.zw));
fragcolor = 0.25 * (texval(tc.xy) + texval(tc.zy) + texval(tc.xw) + texval(tc.zw));
}
]
]

View File

@ -18,12 +18,12 @@ stainvariantshader = [
@(? (stainopt "f") [
//:fog
])
attribute vec4 vvertex, vcolor;
attribute vec2 vtexcoord0;
in vec4 vvertex, vcolor;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec4 colorscale;
varying vec4 color;
varying vec2 texcoord0;
out vec4 color;
out vec2 texcoord0;
void main(void)
{
gl_Position = camprojmatrix * vvertex;
@ -32,15 +32,15 @@ stainvariantshader = [
}
]]) [
uniform sampler2D tex0;
varying vec4 color;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec4 color;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
@(? (stainopt "t") [
fragdata(1) vec4 gglow;
layout(location = 1) out vec4 gglow;
])
void main(void)
{
vec4 diffuse = texture2D(tex0, texcoord0);
vec4 diffuse = texture(tex0, texcoord0);
@(if (stainopt "o") [result [
diffuse.rgb = mix(vec3(0.5), diffuse.rgb, color.rgb);
fragcolor.rgb = diffuse.rgb;

View File

@ -5,9 +5,9 @@
////////////////////////////////////////////////
shader 0 "hdrreduce" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -15,18 +15,18 @@ shader 0 "hdrreduce" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor.rgb = texture2DRect(tex0, texcoord0).rgb;
fragcolor.rgb = textureRect(tex0, texcoord0).rgb;
}
]
shader 0 "hdrreduce2w" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -34,18 +34,18 @@ shader 0 "hdrreduce2w" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor.rgb = 0.5*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
fragcolor.rgb = 0.5*(textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb + textureRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
}
]
shader 0 "hdrreduce2" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -53,24 +53,24 @@ shader 0 "hdrreduce2" [
}
] [
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor.rgb = 0.25*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, -1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rgb +
texture2DRectOffset(tex0, texcoord0, ivec2(1, 1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rgb);
fragcolor.rgb = 0.25*(textureRectOffset(tex0, texcoord0, ivec2(-1, -1)).rgb + textureRectOffset(tex0, texcoord0, ivec2(1, -1)).rgb +
textureRectOffset(tex0, texcoord0, ivec2(1, 1)).rgb + textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).rgb);
}
]
lazyshader 0 msaaresolve [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
}
] [
uniform sampler2DMS tex0;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0);
@ -78,7 +78,7 @@ lazyshader 0 msaaresolve [
]
lazyshader 0 msaaresolvedepth [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
@ -88,7 +88,7 @@ lazyshader 0 msaaresolvedepth [
@(if $gdepthformat [result [
@(gdepthunpackparams)
uniform vec2 gdepthinvscale;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
]])
void main(void)
{
@ -104,9 +104,9 @@ lazyshader 0 msaaresolvedepth [
]
lazyshader 0 msaareducew [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 tap0, tap1;
out vec2 tap0, tap1;
void main(void)
{
gl_Position = vvertex;
@ -115,8 +115,8 @@ lazyshader 0 msaareducew [
}
] [
uniform sampler2DMS tex0;
varying vec2 tap0, tap1;
fragdata(0) vec4 fragcolor;
in vec2 tap0, tap1;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = 0.5*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0));
@ -124,9 +124,9 @@ lazyshader 0 msaareducew [
]
lazyshader 0 msaareduce [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 tap0, tap1, tap2, tap3;
out vec2 tap0, tap1, tap2, tap3;
void main(void)
{
gl_Position = vvertex;
@ -137,8 +137,8 @@ lazyshader 0 msaareduce [
}
] [
uniform sampler2DMS tex0;
varying vec2 tap0, tap1, tap2, tap3;
fragdata(0) vec4 fragcolor;
in vec2 tap0, tap1, tap2, tap3;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
fragcolor = 0.25*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0) +
@ -166,9 +166,9 @@ hdrgammaencode = [
]
shader 0 "hdrluminance" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -177,11 +177,11 @@ shader 0 "hdrluminance" [
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights));
float loglum = sqrt(clamp(lum, 0.015625, 4.0)) * (1.0/2.0); // allow values as low as 2^-6, and as high 2^2
@ -190,9 +190,9 @@ shader 0 "hdrluminance" [
]
shader 0 "hdrluminance2w" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -201,12 +201,12 @@ shader 0 "hdrluminance2w" [
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(loopconcat i 2 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, 0" "1, 0"] $i))).rgb*2.0;
vec3 color@[i] = textureRectOffset(tex0, texcoord0, ivec2(@(at ["-1, 0" "1, 0"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
@ -216,9 +216,9 @@ shader 0 "hdrluminance2w" [
]
shader 0 "hdrluminance2" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -227,12 +227,12 @@ shader 0 "hdrluminance2" [
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
@(loopconcat i 4 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, -1" "1, -1" "1, 1" "-1, 1"] $i))).rgb*2.0;
vec3 color@[i] = textureRectOffset(tex0, texcoord0, ivec2(@(at ["-1, -1" "1, -1" "1, 1" "-1, 1"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
@ -242,7 +242,7 @@ shader 0 "hdrluminance2" [
]
shader 0 "hdraccum" [
attribute vec4 vvertex;
in vec4 vvertex;
void main(void)
{
gl_Position = vvertex;
@ -250,43 +250,43 @@ shader 0 "hdraccum" [
] [
uniform sampler2DRect tex0;
uniform float accumscale;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
float lum = texture2DRect(tex0, vec2(0.5, 0.5)).r * 2.0;
float lum = textureRect(tex0, vec2(0.5, 0.5)).r * 2.0;
lum *= lum;
fragcolor = vec4(vec3(lum*0.25), accumscale);
}
]
shader 0 "hdrbloom" [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
@(? (>= $hwvtexunits 4) [
uniform sampler2D tex2;
] [
attribute float vcolor;
in float vcolor;
])
uniform vec4 hdrparams;
varying vec2 texcoord0;
flat varying float lumscale, lumthreshold;
out vec2 texcoord0;
flat out float lumscale, lumthreshold;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, @hdrminexposure, @hdrmaxexposure))/(avglum + 1e-4);
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumthreshold = -log2(1.0 - hdrparams.z);
}
] [
uniform sampler2DRect tex0;
uniform vec2 hdrgamma;
varying vec2 texcoord0;
flat varying float lumscale, lumthreshold;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
flat in float lumscale, lumthreshold;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights));
color *= max(lum*lumscale - lumthreshold, 0.0) / (lum + 1e-4);
@ -297,26 +297,25 @@ shader 0 "hdrbloom" [
hdrtonemapvertexshader = [
result [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
@(screentexcoord 1)
@(? (>= $hwvtexunits 4) [
uniform sampler2D tex2;
] [
attribute float vcolor;
in float vcolor;
])
uniform vec4 hdrparams;
varying vec2 texcoord0, texcoord1;
flat varying float lumscale;
flat varying vec2 lumsaturate;
out vec2 texcoord0, texcoord1;
flat out float lumscale, lumsaturate;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
texcoord1 = vtexcoord1;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, @hdrminexposure, @hdrmaxexposure))/(avglum + 1e-4);
lumsaturate = vec2(1.0, -hdrparams.y) * 2.0 / max(1.0 - hdrparams.y, 1e-4f);
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumsaturate = -log2(1.0 - hdrparams.y) / lumscale;
}
]
]
@ -324,8 +323,9 @@ hdrtonemapvertexshader = [
hdrtonemapfrag = [
result [{
// color = 1.0 - exp2(-color*lumscale);
float lum = dot(@arg1, vec3(@lumweights)), target = 1.0 - exp2(-lum*lumscale), excess = max(target*lumsaturate.x + lumsaturate.y, 0.0);
@arg1 = (@arg1 + excess) * target / (lum + excess + 1e-4);
float lum = dot(@arg1, vec3(@lumweights));
@arg1 = min(@arg1, lumsaturate);
@arg1 *= (1.0 - exp2(-lum*lumscale)) / (dot(@arg1, vec3(@lumweights)) + 1e-4);
}]
]
@ -333,17 +333,16 @@ hdrtonemapdefs = [
result [
uniform vec4 hdrparams;
uniform vec2 hdrgamma;
varying vec2 texcoord0, texcoord1;
flat varying float lumscale;
flat varying vec2 lumsaturate;
in vec2 texcoord0, texcoord1;
flat in float lumscale, lumsaturate;
]
]
hdrtonemapshaders = [
(? $arg1 lazyshader shader) 0 [hdrnop@arg1] [
attribute vec4 vvertex;
in vec4 vvertex;
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
void main(void)
{
gl_Position = vvertex;
@ -352,11 +351,11 @@ hdrtonemapshaders = [
] [
@arg2
uniform sampler2DRect tex0;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 color = texture2DRect(tex0, texcoord0).rgb;
vec3 color = textureRect(tex0, texcoord0).rgb;
fragcolor.rgb = color;
@arg4
@(? $arg3 $arg3 [fragcolor.a = 0.0;])
@ -367,11 +366,11 @@ hdrtonemapshaders = [
@arg2
uniform sampler2DRect tex0, tex1;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0;
vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
color += bloom;
@(hdrgammadecode color)
@(hdrtonemapfrag color)
@ -392,10 +391,10 @@ msaatonemapshaders = [
uniform sampler2DRect tex1;
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texelFetch(tex0, ivec2(texcoord0), gl_SampleID).rgb*2.0;
color += bloom;
@(hdrgammadecode color)
@ -410,10 +409,10 @@ msaatonemapshaders = [
uniform sampler2DRect tex1;
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 resolved = vec3(0.0);
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
{
@ -438,11 +437,11 @@ msaasplitshaders = [
uniform sampler2DMS tex0;
@(hdrtonemapdefs)
@(loopconcat i $msaasamples [result [
fragdata(@i) vec4 fragcolor@i;
layout(location = @i) out vec4 fragcolor@i;
]])
void main(void)
{
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
@arg4
@(loopconcat i $msaasamples [result [
vec3 color@i = texelFetch(tex0, ivec2(texcoord0), @i).rgb*2.0 + bloom;

View File

@ -5,9 +5,9 @@
////////////////////////////////////////////////
lazyshader 0 "modelpreview" [
attribute vec4 vvertex;
attribute vec2 vtexcoord0;
varying vec2 texcoord0;
in vec4 vvertex;
in vec2 vtexcoord0;
out vec2 texcoord0;
void main(void)
{
@ -22,8 +22,8 @@ lazyshader 0 "modelpreview" [
uniform vec3 sunlightdir;
uniform vec3 sunlightcolor;
uniform float cutout;
varying vec2 texcoord0;
fragdata(0) vec4 fragcolor;
in vec2 texcoord0;
layout(location = 0) out vec4 fragcolor;
void main(void)
{

View File

@ -4,10 +4,9 @@ volumetricvariantshader = [
local volumetrictype
volumetrictype = $arg3
maxsteps = $arg4
spotlight = (>= $arg2 2)
colorshadow = (>= (mod (+ $arg2 1) 3) 2)
spotlight = (>= $arg2 1)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex;
in vec4 vvertex;
uniform mat4 lightmatrix;
void main(void)
{
@ -24,13 +23,6 @@ volumetricvariantshader = [
uniform sampler2DRectShadow tex4;
]]
])
@(if $colorshadow [result [
uniform sampler2DRect tex11;
#define filtercolorshadow(tc) texture2DRect(tex11, tc.xy @(? (! (volopt "N")) [* 0.5])).rgb
#define lightshadowtype vec3
]] [result [
#define lightshadowtype float
]])
uniform vec4 lightpos;
uniform vec3 lightcolor;
@(? $spotlight [
@ -51,7 +43,7 @@ volumetricvariantshader = [
uniform float volminstep;
uniform float voldistclamp;
uniform float volprefilter;
fragdata(0) vec4 fragcolor;
layout(location = 0) out vec4 fragcolor;
@(if (volopt "p") [
? $spotlight [
@ -77,12 +69,12 @@ volumetricvariantshader = [
@(if (volopt "p") [
if (|| (volopt "g") (volopt "G")) [
? (> $usetexgather 1) [
#define filtershadow(shadowtc) float(shadow2D(tex4, vec3(shadowtc.xy*shadowatlasscale, shadowtc.z)))
#define filtershadow(shadowtc) float(shadow(tex4, vec3(shadowtc.xy*shadowatlasscale, shadowtc.z)))
] [
#define filtershadow(shadowtc) step(shadowtc.z, float(texture2D(tex4, shadowtc.xy*shadowatlasscale)))
#define filtershadow(shadowtc) step(shadowtc.z, float(texture(tex4, shadowtc.xy*shadowatlasscale)))
]
] [result [
#define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc))
#define filtershadow(shadowtc) float(textureRect(tex4, shadowtc))
]]
])
@ -100,7 +92,7 @@ volumetricvariantshader = [
ray *= invdist;
vec3 camlight = lightpos.xyz - camera * lightpos.w;
float camlight2 = dot(camlight, camlight), v = dot(camlight, ray), d = v*v + 1.0 - camlight2;
lightshadowtype light = lightshadowtype(0.0);
float light = 0.0;
if(d > 0)
{
d = sqrt(d);
@ -144,7 +136,7 @@ volumetricvariantshader = [
vec3 spottc = getspottc(lightdir, spotdist);
lightatten *= filtershadow(spottc);
])
light += lightatten @(? $colorshadow [* filtercolorshadow(spottc)]);
light += lightatten;
}
]] [result [
float lightatten = clamp(1.0 - length(lightdir), 0.0, 1.0);
@ -152,7 +144,7 @@ volumetricvariantshader = [
vec3 shadowtc = getshadowtc(lightdir);
lightatten *= filtershadow(shadowtc);
])
light += lightatten @(? $colorshadow [* filtercolorshadow(shadowtc)]);
light += lightatten;
]])
space -= stepdist;
if(space <= 0) break;
@ -180,15 +172,9 @@ volumetricshader = [
shadername = (concatword "volumetric" $volumetrictype $arg3)
volumetricvariantshader $shadername -1 $arg1 $arg3
volumetricvariantshader $shadername 0 (concatword $arg1 $arg2) $arg3
if (volopt "P") [
volumetricvariantshader $shadername 1 (concatword $arg1 $arg2) $arg3
]
if (volopt "s") [
volumetricvariantshader $shadername 2 $arg1 $arg3
volumetricvariantshader $shadername 3 (concatword $arg1 $arg2) $arg3
if (volopt "P") [
volumetricvariantshader $shadername 4 (concatword $arg1 $arg2) $arg3
]
volumetricvariantshader $shadername 1 $arg1 $arg3
volumetricvariantshader $shadername 2 (concatword $arg1 $arg2) $arg3
]
]
@ -197,10 +183,10 @@ volumetricbilateralvariantshader = [
reduced = $arg3
filterdir = $arg4
shader 0 $arg1 [
attribute vec4 vvertex;
in vec4 vvertex;
@(if $reduced [result [
@(screentexcoord 0)
varying vec2 texcoord0;
out vec2 texcoord0;
]])
void main(void)
{
@ -211,18 +197,18 @@ volumetricbilateralvariantshader = [
@(gfetchdefs tex3)
uniform sampler2DRect tex0;
uniform vec2 bilateralparams;
@(? $reduced [varying vec2 texcoord0;])
fragdata(0) vec4 fragcolor;
@(? $reduced [in vec2 texcoord0;])
layout(location = 0) out vec4 fragcolor;
void main(void)
{
#define tc gl_FragCoord.xy
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i))
#define texval(i) textureRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) textureRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex3, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex3, depthtc, tapvec(ivec2, i))
vec3 color = texture2DRect(tex0, tc).rgb;
vec3 color = textureRect(tex0, tc).rgb;
@(gdepthunpack depth [gfetch(tex3, depthtc)])
float weights = 1.0;
@(loopconcat i (* 2 $numtaps) [

View File

@ -15,7 +15,6 @@
// b -> blendmap
// a -> transparent
// A -> refractive
// m -> alpha-mask
// T -> triplanar
// d -> detail
@ -59,25 +58,25 @@ worldvariantshader = [
srow = 1
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec2 texgenscroll;
varying vec3 nvec;
out vec3 nvec;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [
uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz;
out vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform vec2 detailscale;])
]] [result [
varying vec2 texcoord0;
out vec2 texcoord0;
]])
@(? (wtopt "r") [uniform vec3 camera; varying vec3 camvec;])
@(? (wtopt "G") [uniform float millis; flat varying float pulse;])
@(? (wtopt "r") [uniform vec3 camera; out vec3 camvec;])
@(? (wtopt "G") [uniform float millis; flat out float pulse;])
@(? (wtopt "b") [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
out vec2 texcoord1;
])
void main(void)
@ -111,21 +110,21 @@ worldvariantshader = [
uniform vec4 colorparams;
uniform sampler2D diffusemap;
@(? (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) [uniform float hashid;])
varying vec3 nvec;
in vec3 nvec;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz;
in vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform sampler2D detaildiffusemap;])
]] [result [
varying vec2 texcoord0;
in vec2 texcoord0;
]])
@(? (wtopt "g") [uniform sampler2D glowmap;])
@(? (wtopt "G") [flat varying float pulse;])
@(? (wtopt "r") [uniform samplerCube envmap; varying vec3 camvec;])
@(? (wtopt "G") [flat in float pulse;])
@(? (wtopt "r") [uniform samplerCube envmap; in vec3 camvec;])
@(? (wtopt "b") [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
in vec2 texcoord1;
])
void main(void)
@ -137,12 +136,12 @@ worldvariantshader = [
triblend *= triblend;
triblend /= triblend.x + triblend.y + triblend.z;
vec4 diffusex = texture2D(diffusemap, texcoordx);
vec4 diffusey = texture2D(diffusemap, texcoordy);
vec4 diffusez = texture2D(@(? (wtopt "d") "detaildiffusemap" "diffusemap"), texcoordz);
vec4 diffusex = texture(diffusemap, texcoordx);
vec4 diffusey = texture(diffusemap, texcoordy);
vec4 diffusez = texture(@(? (wtopt "d") "detaildiffusemap" "diffusemap"), texcoordz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
]] [result [
vec4 diffuse = texture2D(diffusemap, texcoord0);
vec4 diffuse = texture(diffusemap, texcoord0);
]])
gcolor.rgb = diffuse.rgb*colorparams.rgb;
@ -151,7 +150,7 @@ worldvariantshader = [
vec3 camvecn = normalize(camvec);
float invfresnel = dot(camvecn, normal);
vec3 rvec = 2.0*normal*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb;
vec3 reflect = texture(envmap, rvec).rgb;
@(? (wtopt "R") [
vec3 rmod = envscale.xyz*diffuse.a;
] [
@ -162,12 +161,12 @@ worldvariantshader = [
@(if (wtopt "g") [result [
@(? (wtopt "T") [
vec3 glowx = texture2D(glowmap, texcoordx).rgb;
vec3 glowy = texture2D(glowmap, texcoordy).rgb;
vec3 glowz = texture2D(glowmap, texcoordz).rgb;
vec3 glowx = texture(glowmap, texcoordx).rgb;
vec3 glowy = texture(glowmap, texcoordy).rgb;
vec3 glowz = texture(glowmap, texcoordz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [
vec3 glow = texture2D(glowmap, texcoord0).rgb;
vec3 glow = texture(glowmap, texcoord0).rgb;
])
glow *= @(? (wtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (wtopt "a") [result [
@ -178,20 +177,12 @@ worldvariantshader = [
]])
@(if (wtopt "a") [
if (wtopt "A") [result [
? (wtopt "A") [
vec3 rlight = gfetch(refractlight, gl_FragCoord.xy).rgb;
@(? (wtopt "m") [
gcolor.rgb *= diffuse.a;
gglow.rgb += rlight * refractparams.xyz * (1.0 - colorparams.a * diffuse.a);
] [
gglow.rgb += rlight * refractparams.xyz * (1.0 - colorparams.a);
])
]] [? (wtopt "m") [
gcolor.rgb *= diffuse.a;
#define packnorm diffuse.a * colorparams.a
gglow.rgb += rlight * refractparams.xyz;
] [
#define packnorm colorparams.a
]]
]
])
@(gnormpackdef normal packnorm)
@ -199,7 +190,7 @@ worldvariantshader = [
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) "" hashid)
@(? (wtopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gnormal.rgb *= blend;
gnormal.a *= blendlayer;
@ -227,17 +218,12 @@ worldshader = [
worldshader "stdworld" ""
forceshader "stdworld"
worldshader "alphaworld" "m"
worldshader "specworld" "s"
worldshader "specmapworld" "sS"
worldshader "glowworld" "g"
worldshader "pulseglowworld" "gG"
worldshader "glowalphaworld" "gm"
worldshader "pulseglowalphaworld" "gGm"
worldshader "envworld" "er"
worldshader "envspecworld" "esr"
worldshader "envspecmapworld" "esSrR"
@ -259,7 +245,6 @@ worldshader "triplanardetailworld" "Td"
// b -> blendmap
// a -> transparent
// A -> refractive
// m -> alpha-mask
// T -> triplanar
// d -> detail
@ -306,30 +291,30 @@ bumpvariantshader = [
srow = 1
]
variantshader $stype $arg1 $srow [
attribute vec4 vvertex, vtangent;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
in vec4 vvertex, vtangent;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 camprojmatrix;
uniform vec2 texgenscroll;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [
uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal;
varying vec3 tangentx, tangenty, tangentz;
out vec2 texcoordx, texcoordy, texcoordz;
out vec3 normal;
out vec3 tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform vec2 detailscale;])
]] [result [
varying vec2 texcoord0;
varying mat3 world;
out vec2 texcoord0;
out mat3 world;
]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [
uniform vec3 camera;
varying vec3 camvec;
out vec3 camvec;
])
@(? (btopt "G") [uniform float millis; flat varying float pulse;])
@(? (btopt "G") [uniform float millis; flat out float pulse;])
@(? (btopt "b") [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
out vec2 texcoord1;
])
void main(void)
@ -376,23 +361,23 @@ bumpvariantshader = [
uniform vec4 colorparams;
uniform sampler2D diffusemap, normalmap;
@(? (|| $msaalight [&& $msaasamples [! (btopt "a")]]) [uniform float hashid;])
varying mat3 world;
in mat3 world;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal, tangentx, tangenty, tangentz;
in vec2 texcoordx, texcoordy, texcoordz;
in vec3 normal, tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform sampler2D detaildiffusemap, detailnormalmap;])
]] [result [
varying vec2 texcoord0;
in vec2 texcoord0;
]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [varying vec3 camvec;])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [in vec3 camvec;])
@(? (btopt "g") [uniform sampler2D glowmap;])
@(? (btopt "G") [flat varying float pulse;])
@(? (btopt "G") [flat in float pulse;])
@(? (btopt "r") [uniform samplerCube envmap;])
@(? (btopt "b") [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
in vec2 texcoord1;
])
void main(void)
@ -411,9 +396,9 @@ bumpvariantshader = [
#define worldz mat3(tangentx, tangenty, normal)
@(if (btopt "p") [result [
float heightx = texture2D(normalmap, texcoordx).a;
float heighty = texture2D(normalmap, texcoordy).a;
float heightz = texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), texcoordz).a;
float heightx = texture(normalmap, texcoordx).a;
float heighty = texture(normalmap, texcoordy).a;
float heightz = texture(@(? (btopt "d") "detailnormalmap" "normalmap"), texcoordz).a;
vec3 camvect = camvecn * mat3(tangentx, tangenty, tangentz);
vec2 dtcx = texcoordx + camvect.yz*(heightx*parallaxscale.x + parallaxscale.y);
@ -425,14 +410,14 @@ bumpvariantshader = [
#define dtcz texcoordz
]])
vec4 diffusex = texture2D(diffusemap, dtcx);
vec4 diffusey = texture2D(diffusemap, dtcy);
vec4 diffusez = texture2D(@(? (btopt "d") "detaildiffusemap" "diffusemap"), dtcz);
vec4 diffusex = texture(diffusemap, dtcx);
vec4 diffusey = texture(diffusemap, dtcy);
vec4 diffusez = texture(@(? (btopt "d") "detaildiffusemap" "diffusemap"), dtcz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
vec3 bumpx = (texture2D(normalmap, dtcx).rgb*2.0 - 1.0)*triblend.x;
vec3 bumpy = (texture2D(normalmap, dtcy).rgb*2.0 - 1.0)*triblend.y;
vec3 bumpz = (texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), dtcz).rgb*2.0 - 1.0)*triblend.z;
vec3 bumpx = (texture(normalmap, dtcx).rgb*2.0 - 1.0)*triblend.x;
vec3 bumpy = (texture(normalmap, dtcy).rgb*2.0 - 1.0)*triblend.y;
vec3 bumpz = (texture(@(? (btopt "d") "detailnormalmap" "normalmap"), dtcz).rgb*2.0 - 1.0)*triblend.z;
vec3 bumpw = normalize(worldx*bumpx + worldy*bumpy + worldz*bumpz);
@(? (btopt "A") [
@ -440,21 +425,15 @@ bumpvariantshader = [
])
]] [result [
@(? (btopt "p") [
float height = texture2D(normalmap, texcoord0).a;
float height = texture(normalmap, texcoord0).a;
vec2 dtc = texcoord0 + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [
#define dtc texcoord0
])
vec4 diffuse = texture2D(diffusemap, dtc);
vec4 diffuse = texture(diffusemap, dtc);
@(? (&& (btopt "a") [btopt "m"]) [
vec4 normal = texture2D(normalmap, dtc);
#define bump normal.rgb
] [
vec3 bump = texture2D(normalmap, dtc).rgb;
])
bump = bump*2.0 - 1.0;
vec3 bump = texture(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump);
]])
@ -463,7 +442,7 @@ bumpvariantshader = [
@(if (btopt "r") [result [
float invfresnel = dot(camvecn, bumpw);
vec3 rvec = 2.0*bumpw*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb;
vec3 reflect = texture(envmap, rvec).rgb;
@(? (btopt "R") [
vec3 rmod = envscale.xyz*diffuse.a;
] [
@ -474,12 +453,12 @@ bumpvariantshader = [
@(if (btopt "g") [result [
@(? (btopt "T") [
vec3 glowx = texture2D(glowmap, dtcx).rgb;
vec3 glowy = texture2D(glowmap, dtcy).rgb;
vec3 glowz = texture2D(glowmap, dtcz).rgb;
vec3 glowx = texture(glowmap, dtcx).rgb;
vec3 glowy = texture(glowmap, dtcy).rgb;
vec3 glowz = texture(glowmap, dtcz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [
vec3 glow = texture2D(glowmap, dtc).rgb;
vec3 glow = texture(glowmap, dtc).rgb;
])
glow *= @(? (btopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (btopt "a") [result [
@ -490,22 +469,14 @@ bumpvariantshader = [
]])
@(if (btopt "a") [
if (btopt "A") [result [
? (btopt "A") [
vec2 rtc = bump.xy*refractparams.w;
float rmask = clamp(refractdepth*(lineardepth - dot(gfetch(refractmask, gl_FragCoord.xy + rtc).rgb, gdepthunpackparams)), 0.0, 1.0);
vec3 rlight = gfetch(refractlight, gl_FragCoord.xy + rtc*rmask).rgb;
@(? (btopt "m") [
gcolor.rgb *= normal.a;
gglow.rgb += rlight * refractparams.xyz * (1.0 - colorparams.a * normal.a);
] [
gglow.rgb += rlight * refractparams.xyz * (1.0 - colorparams.a);
])
]] [? (btopt "m") [
gcolor.rgb *= normal.a;
#define packnorm normal.a * colorparams.a
gglow.rgb += rlight * refractparams.xyz;
] [
#define packnorm colorparams.a
]]
]
])
@(gnormpackdef bumpw packnorm)
@ -513,7 +484,7 @@ bumpvariantshader = [
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]]) "" hashid)
@(? (btopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gnormal.rgb *= blend;
gnormal.a *= blendlayer;
@ -542,10 +513,6 @@ bumpshader "bumpworld" ""
bumpshader "bumpspecworld" "s"
bumpshader "bumpspecmapworld" "sS"
bumpshader "bumpalphaworld" "m"
bumpshader "bumpspecalphaworld" "sm"
bumpshader "bumpspecmapalphaworld" "sSm"
bumpshader "bumpglowworld" "g"
bumpshader "bumpspecglowworld" "sg"
bumpshader "bumpspecmapglowworld" "sSg"
@ -606,8 +573,8 @@ bumpshader "triplanardetailbumpparallaxworld" "Tdp"
bumpshader "triplanardetailbumpspecparallaxworld" "Tdps"
bumpshader "triplanardetailbumpspecmapparallaxworld" "TdpsS"
shader 0 "smworld" [
attribute vec4 vvertex;
shader 0 shadowmapworld [
in vec4 vvertex;
uniform mat4 shadowmatrix;
void main(void)
{
@ -619,102 +586,21 @@ shader 0 "smworld" [
}
]
// shadowmaptype:
// a -> transparent
// m -> alpha-mask
// n -> normalmap
smtopt = [ >= (strstr $shadowmaptype $arg1) 0 ]
shadowmapworldvariantshader = [
local shadowmaptype
shadowmaptype = $arg2
srow = -1
if (smtopt "m") [
srow = 0
]
if (smtopt "n") [
srow = 1
]
variantshader 1 $arg1 $srow [
attribute vec4 vvertex;
attribute vec2 vtexcoord0;
uniform vec2 texgenscroll;
uniform vec4 colorparams;
varying vec2 texcoord0;
uniform mat4 shadowmatrix;
void main(void)
{
gl_Position = shadowmatrix * vvertex;
texcoord0 = vtexcoord0 + texgenscroll;
}
] [
uniform vec4 colorparams;
uniform sampler2D diffusemap;
varying vec2 texcoord0;
@(? (smtopt "n") [
uniform sampler2D normalmap;
])
fragdata(0) vec4 gcolor;
void main(void)
{
vec4 diffuse = texture2D(diffusemap, texcoord0);
@(if (smtopt "a") [result [
float alpha = colorparams.a;
@(if (smtopt "m") [result [
@(? (smtopt "n") [
alpha *= texture2D(normalmap, texcoord0).a;
] [
alpha *= diffuse.a;
])
#define mask alpha
]] [result [
#define mask 0.0
]])
]] [result [
#define alpha 1.0
#define mask 1.0
]])
gcolor.rgb = mix(vec3(1.0), diffuse.rgb*colorparams.rgb, alpha) * (1.0 - mask);
gcolor.a = alpha;
}
]
]
shadowmapshader = [
defershader 1 $arg1 [
shadowmapworldvariantshader @arg1 @arg2
shadowmapworldvariantshader @arg1 @(concatword $arg2 "m")
shadowmapworldvariantshader @arg1 @(concatword $arg2 "mn")
]
]
shadowmapshader "smalphaworld" "a"
defershader 1 "rsmworld" [
loop i 2 [
variantshader 1 "rsmworld" (- $i 1) [
attribute vec4 vvertex;
attribute vec3 vnormal;
attribute vec2 vtexcoord0;
in vec4 vvertex;
in vec3 vnormal;
in vec2 vtexcoord0;
uniform mat4 rsmmatrix;
uniform vec2 texgenscroll;
uniform vec4 colorparams;
uniform vec3 rsmdir;
varying vec4 normal;
varying vec2 texcoord0;
out vec4 normal;
out vec2 texcoord0;
@(? (= $i 1) [
uniform vec4 blendmapparams;
varying vec2 texcoord1;
out vec2 texcoord1;
])
void main(void)
{
@ -728,18 +614,18 @@ defershader 1 "rsmworld" [
] [
uniform vec4 colorparams;
uniform sampler2D diffusemap;
varying vec4 normal;
varying vec2 texcoord0;
in vec4 normal;
in vec2 texcoord0;
@(? (= $i 1) [
uniform float blendlayer;
uniform sampler2D blendmap;
varying vec2 texcoord1;
in vec2 texcoord1;
])
fragdata(0) vec4 gcolor;
fragdata(1) vec4 gnormal;
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
void main(void)
{
vec4 diffuse = texture2D(diffusemap, texcoord0);
vec4 diffuse = texture(diffusemap, texcoord0);
@(if (= $i 2) [result [
#define alpha 1.0
@ -751,7 +637,7 @@ defershader 1 "rsmworld" [
gnormal = vec4(normal.xyz*0.5+0.5, 0.0);
@(if (= $i 1) [result [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer);
float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend;
gcolor.a = blendlayer;
gnormal *= blend;

View File

@ -0,0 +1,82 @@
// basic server configuration script
// note that some commands are commented out with //, and need to be uncommented and set to a value to work
// optional specific IP for server to use
// serverip N.N.N.N
// optional specific port for server to use
// serverport 42000
// maximum number of allowed clients
maxclients 8
// maximum number of bots a master can add - admins are unaffected by this limit
// set to 0 to disallow bots
serverbotlimit 8
// controls whether or not the server is intended for "public" use
// when set to 0, allows "setmaster 1" and locked/private mastermodes (for coop-editing and such)
// when set to 1, can only gain master by "auth" or admin, and doesn't allow locked/private mastermodes
// when set to 2, allows "setmaster 1" but disallows private mastermode (for public coop-editing)
publicserver 0
// description server shows for the server browser
serverdesc ""
// password required to connect to the server
// generally unnecessary unless you really don't want anyone connecting to your server
// using the serverauth option allows people with an appropriate local authkey to connect regardless
// serverpass ""
// password that allows you to gain admin by "setmaster password_here"
// local authkeys are more secure than this and should be used instead if possible
// adminpass ""
// domain to use for local authkeys to the server so people can authenticate by "auth domain_here"
// must be a non-empty string that should be unique to your server to prevent clashes with other servers
// serverauth ""
// controls whether or not the server reports to the masterserver
updatemaster 1
// optional message of the day to send to players on connect
// servermotd "..."
// controls whether admin privs are necessary to record a demo
// when 1 requires admin (default)
// when 0 only requires master
// restrictdemos 1
// maximum number of demos the server will store
// maxdemos 5
// maximum size a demo is allowed to grow to in megabytes
// maxdemosize 16
// controls whether admin privs are necessary to pause a game
// when 1 requires admin (default)
// when 0 only requires master
// restrictpausegame 1
// whether or not to allow players to vote on maps not in the rotation
// when 1 requires master
// when 2 requires admin
// when 0 allows any votes (default)
// lockmaprotation 0
dmmaps = [
complex alphacorp ot turbine reflection
]
ctfmaps = [
alphacorp steelribs test_ctf reflection waterworks
]
tdmmaps = (listunion $dmmaps $ctfmaps)
maprotationreset
maprotation "*" $dmmaps
maprotation "?tdm" $tdmmaps
maprotation "?ctf" $ctfmaps
teamkillkickreset
teamkillkick "*" 7 30

46
config/sound.cfg 100644
View File

@ -0,0 +1,46 @@
defaultsoundpack = [
soundreset
registersound "uphys/jump" 60
registersound "uphys/land" 180
registersound "uphys/splashin" 160
registersound "uphys/splashout" 100
registersound "soundsnap/burn" 210
registersound // itemspawn
registersound "q009/teleport" 255
registersound "uphys/jumppad" 100
registersound "uphys/punch_swing" 190
registersound "uphys/pulse_third" 255
registersound "uphys/pulse_first" 255
registersound "uphys/pulse_burst" 255
registersound "dacker/rail_third" 255
registersound "dacker/rail_first" 255
registersound "uphys/weapon_switch" 50
registersound // noammo
registersound "free/hit" 100
registersound // pain1
registersound // pain2
registersound "uphys/die1" 150
registersound "uphys/die2" 150
registersound "ctf/flagpickup" 100
registersound "ctf/flagdrop" 100
registersound "ctf/flagreturn" 100
registersound "ctf/flagscore" 100
registersound "ctf/flagreturn" 100
registersound "ctf/flagfail" 100
]
loadsoundpack = [
if $soundpack [
if (! (exec [media/sound/game/@soundpack/soundpack.cfg] 0)) [
error [Failed to load soundpack: @soundpack. Using default sounds.]
defaultsoundpack
]
] [
defaultsoundpack
]
]
defsvarp soundpack "" [loadsoundpack]
defaultsoundpack

577
config/ui.cfg 100644
View File

@ -0,0 +1,577 @@
// standard menu definitions
// don't modify, add personal menus to autoexec.cfg instead
exec "config/ui/lib.cfg" // UI library
exec "config/ui/style.cfg" // Styles
exec "config/ui/scoreboard.cfg" // Scoreboard
exec "config/ui/edithud.cfg" // Edit HUD
exec "config/ui/fkey.cfg" // F# Key Menus
exec "config/ui/serverbrowser.cfg" // Server Browser
exec "config/ui/stats.cfg" // Player Stats
exec "config/ui/options.cfg" // Options Menu
reui = [
exec "config/ui.cfg"
]
togglemainmenu = [|| hidetopui [toggleui main]]
bind ESCAPE [togglemainmenu]
///////////////////////////////////////////////////////////////////////////////
// Main //
///////////////////////////////////////////////////////////////////////////////
UImenu "main" [
uieschide (! $mainmenu)
uihlist 0 [
uivlist 0 [
UIbutton "hold2" [uitext "Server Browser" 0.65] 0.2 0.04 [hideui "main" ; showui "server_browser"]
UIbutton "hold2" [uitext "Map Browser" 0.65] 0.2 0.04 [hideui "main" ; showui "map_browser"]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Player Setup" 0.65] 0.2 0.04 [hideui "main" ; showui "player_setup"]
UIbutton "hold2" [uitext "Options" 0.65] 0.2 0.04 [hideui "main" ; showui "options"]
if $mainmenu [
UIbutton "hold2" [uitext "Credits" 0.65] 0.2 0.04 [hideui "main" ; showui "credits"]
]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Quit" 0.65] 0.2 0.04 [quit]
]
if (! $mainmenu) [
uifill 0.02 0.24 [UIbar 0 1]
uivlist 0 [
if (isspectator $getclientnum) [
if $scoreboardmultiplayer [
if (ismaster $getclientnum) [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
] [
if (> $getmastermode 1) [
uifill 0 0.04 [uitext "^f4Play" 0.65]
] [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
]
]
] [
UIbutton "hold2" [uitext "Play" 0.65] 0.2 0.04 [hideui "main" ; spectator 0]
]
] [
UIbutton "hold2" [uitext "Spectate" 0.65] 0.2 0.04 [hideui "main" ; spectator 1]
]
case $getteam [
0] [uifill 0 0.04] [
1] [UIbutton "hold2" [uitext "Join ^f3Rojo" 0.65] 0.2 0.04 [team rojo]] [
2] [UIbutton "hold2" [uitext "Join ^f1Azul" 0.65] 0.2 0.04 [team azul]]
uifill 0.2 0.02 [UIbar 1]
if $scoreboardmultiplayer [
UIbutton "hold2" [uitext "Master" 0.65] 0.2 0.04 [hideui "main" ; showui "master"]
if (ismaster $getclientnum) [
UIbutton "hold2" [uitext "Bots" 0.65] 0.2 0.04 [hideui "main" ; showui "bots"]
] [
uifill 0 0.04
]
] [
uifill 0 0.04
UIbutton "hold2" [uitext "Bots" 0.65] 0.2 0.04 [hideui "main" ; showui "bots"]
]
uifill 0.2 0.02 [UIbar 1]
UIbutton "hold2" [uitext "Disconnect" 0.65] 0.2 0.04 [disconnect]
]
]
]
]
///////////////////////////////////////////////////////////////////////////////
// Player Setup //
///////////////////////////////////////////////////////////////////////////////
UI_pmodel = 0
UI_pteam = 0
UI_pweapon = 1
UImenu "player_setup" [
uihlist 0.01 [
uivlist 0 [
uiplayerpreview $UI_pmodel (case $UI_pteam 0 $playercolor 1 $playercolorazul 2 $playercolorrojo) $UI_pteam $UI_pweapon 0.4 0.5 [
style_generic_default
uiclamp* 1 1 1 1
]
uihlist 0 [
uiclamp 1 1
UIbutton "" [
UIradio [= $UI_pweapon 0] 0.016
uitext "Railgun" 0.6
] 0 0.032 [UI_pweapon = 0] -1
UIbutton "" [
UIradio [= $UI_pweapon 1] 0.016
uitext "Pulse Rifle" 0.6
] 0 0.032 [UI_pweapon = 1] -1
uiclamp* 1 1
]
]
uivlist 0.01 [
uialign -2 -1
uivlist 0.0037 [
uitext "Name" 0.7
uifield name 15 [] 0.7 [uioutline (uifocus? $c_focus $c_line); uiclamp- 1 1 1 1]
]
looplist3 v t l [
"playercolor" 0 9
"playercolorazul" 1 4
"playercolorrojo" 2 4
] [
uivlist 0.0037 [
case $t 1 [
uitext "^f8Azul" 0.7
] 2 [
uitext "^f3Rojo" 0.7
] () [uitext "Solo" 0.7]
uigrid (? (< $t 1) 3 2) 0.005 0.005 [
local color
uihover [UI_pteam = $t]
loop i $l [
color = (getplayercolor $i $t)
uicolor $color 0.0458 0.0458 [
uioutline (? (= $$v $i) $c_fill $color)
uiclamp- 1 1 1 1
uipress [$v $i]
]
]
]
]
]
]
]
] [] [] [] "Player Setup"
///////////////////////////////////////////////////////////////////////////////
// Credits //
///////////////////////////////////////////////////////////////////////////////
UI_creditlist = [
UItitle [
uispace 0.015 0 [
uialign -1 -2
uihlist 0.01 [
uiimage "media/interface/cube.png" 0.03 0.03
uitext [@@@@arg1] 0.7
]
]
] 0 0.032
uispace 0.03 0 [
uifill 0 0 [
uiclamp 1 1
uimodhgradient 0xC0C0C0 0xFFFFFF
uiclamp- 1 1 1 1
uispace 0.02 0.01 [
uialign -1 -2
uivlist 0 [
looplist i $arg2 [
uiwraptext (strreplace (strreplace $i "^"" "^fs^f8^"" "^"^fr") ": " "^f4: ") 0.69 0.6
]
uialign* -1 -2
]
]
]
]
uifill 0 0.02
]
UImenu "credits" [
uihlist 0.01 [
uiscroll 0.8 0.8 [
uifill 0.77
uivlist 0.0008 [
uiclamp 1 1
uialign -2 -1
// Alphabetized by alias
UI_creditlist "Project" [
[Lee "eihrul" Salzman : Code Gatekeeper]
[Shane "Nieb" Nieb : Media Gatekeeper]
]
UI_creditlist "Code" [
[Lee "eihrul" Salzman]
[Benjamin Segovia]
[Kevin "Hirato Kirata" Meyer]
]
UI_creditlist "Art" [
[Shane "Nieb" Nieb : Playermodel, Mapmodels, Textures]
]
UI_creditlist "Sound" [
[Dylan "Dacker" Ackerly]
[Shane "Nieb" Nieb]
[Sławomir "Q009" Błauciak]
[Jannic "Uphys" Böhme]
]
UI_creditlist "Cartography" [
[Dylan "Dacker" Ackerly : complex]
[Shane "Nieb" Nieb : complex, test_ctf]
[Sławomir "Q009" Błauciak : steelribs]
[Jack "Pritchard" Viney : alphacorp]
[Kurt Kessler : waterworks]
[James 'Skur' Rucks : reflection]
[Yannick 'Snowy' Weber : reflection]
]
UI_creditlist "Miscellaneous" [
[Kevin "Hirato Kirata" Meyer : CubeScript Documentation]
[Shane "Nieb" Nieb : UI Design, Tesseract Website]
[Daniel "q66" Kolesa : Build-system Improvements]
["RaZgRiZ" : UI Documentation, UI Design]
]
UI_creditlist "Cube Engine 2" [
[Wouter "Aardappel" van Oortmerssen]
[Lee "eihrul" Salzman]
[Mike "Gilt" Dysart]
[Robert "baby-rabbit" Pointon]
[Quinton "Quin" Reeves]
[John "geartrooper" Siar]
[and others...]
"http://sauerbraten.org/"
]
uiclamp* 1 1
]
]
UIvscroll 0.02 0.8 2.0
]
] [] [] [] "Tesseract Contributors"
///////////////////////////////////////////////////////////////////////////////
// Master //
///////////////////////////////////////////////////////////////////////////////
menu_master = [if $isconnected [if $scoreboardmultiplayer [toggleui "master"]]]
UImenu "master" [
uifill 0 0 [
uivlist 0 [
uihlist 0.01 [
if (ismaster $getclientnum) [
UIbutton "" [uitext "Relinquish Master" 0.65] 0.24 0.06 [setmaster 0]
] [
if (issomeoneelsemaster) [
UIbutton "" [uitext "^f4Claim Master" 0.65] 0.24 0.06 []
] [
UIbutton "" [uitext "Claim Master" 0.65] 0.24 0.06 [setmaster 1]
]
]
if (ismaster $getclientnum) [
uigrid 2 0 0 [
looplist2 n i [
"^f0open ^f4(0)" 0 "^f0veto ^f4(1)" 1
"^f2locked ^f4(2)" 2 "^f3private ^f4(3)" 3
] [
UIbutton "" [
UIradio [= $getmastermode $i] 0.016
uitext $n 0.6
] 0.16 0.03 [mastermode $i] -1
]
]
uivlist 0 [
UIbutton "" [uitext "Clearbans" 0.65] 0.16 0.03 [clearbans]
UIbutton "" [uitext "Bots" 0.65] 0.16 0.03 [hideui "main" ; showui "bots"]
]
] [
uifill 0.49
]
]
uifill 0 0.02 [UIbar 1 ; uiclamp 1 1 1 1]
if (ismaster $getclientnum) [
if (> $getmode 2) [UI_clientlistteam] [UI_clientlistsolo]
] [
if (> $getmode 2) [uifill 1.43 0.312] [uifill 0 0.624]
]
]
]
] [] [] [] "Master"
UI_clientlistsolo = [
uihlist 0 [
uiscroll 0.71 0.624 [
uifill 0.71 0.624 [
uitable 0 0 [
UI_mlc = 0
looplist cn (listclients 1 0) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.362 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99323232 0x99262626) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
uialign* -1 -1
]
]
uifill 0.01
UIvscroll 0.02 0.624 1.56
]
]
UI_clientlistteam = [
uihlist 0 [
uiscroll 1.4 0.312 [
uifill 1.4 0.312 [
uihlist 0 [
uialign 0 -1
uitable 0 0 [
uifill 0.695
UI_mlc = 0
looplist cn (listclients 1 0) [
if (= (getclientteam $cn) 1) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.26 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UItriangle 0xCCCCCC 0.01 0.01 270
uitext "Team" 0.57
] 0.0875 0.026 [setteam @cn @(? (=s (getclientteam $cn) "1") "2" "1")] -1
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99333b40 0x99262b33) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
]
uifill 0.01
uitable 0 0 [
uifill 0.695
UI_mlc = 0
looplist cn (listclients 1 0) [
if (= (getclientteam $cn) 2) [
uitablerow [
uifill 0.078 0.026 [
uicolortext (concatword $cn " : ") (scoreboardstatus $cn) 0.57
uialign- 1
]
uifill 0.26 0.026 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
uialign- -1
]
if (= $cn $getclientnum)[
uifill 0.077 0.026
] [
UIbutton "hold2" [
UItriangle 0 0.01 0.01 270
uitext "Kick" 0.57
] 0.077 0.026 [kick @cn] -1
]
UIbutton "hold2" [
UItriangle 0 0.01 0.01 270
uitext "Team" 0.57
] 0.0875 0.026 [setteam @cn @(? (=s (getclientteam $cn) "1") "2" "1")] -1
UIbutton "hold2" [
UIradio [= (isspectator $cn) 1] 0.016
uitext "Spec" 0.57
] 0.087 0.026 [spectator @(= (isspectator $cn) 0) @cn] -1
UIbutton "hold2" [
UIradio [= (ismaster $cn) 1] 0.016
uitext (concatword (? (isadmin $cn) "Admin" (? (isauth $cn) "Auth" "Master"))) 0.57
] 0.105 0.026 [setmaster (? (ismaster $cn) 0 1) @cn] -1
] [
UI_mlc = (! $UI_mlc)
uicolor (? $UI_mlc 0x99403333 0x99332626) 0 0 [
uiclamp 1 1 1 1
pushif highlight (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
]
]
]
]
]
uialign* 0 -1
]
]
]
uifill 0.01
UIvscroll 0.02 0.312 1.56
]
]
///////////////////////////////////////////////////////////////////////////////
// Bots //
///////////////////////////////////////////////////////////////////////////////
UI_botskill = 87
UI_botaddnum = 9
UImenu "bots" [
uifill 0.65 0.27 [
uivlist 0.01 [
uitext (concatword "Bots: " (numbots)) 0.6
uifill 0 0.01
uihlist 0.01 [
uialign 1 ; uitext "Skill Level" 0.6 ; UIhslider UI_botskill 1 100 1 0.5 0.032 [uitext $UI_botskill 0.6]
]
uihlist 0.01 [
uialign 1 ; uitext "#" 0.6 ; UIhslider UI_botaddnum 2 32 1 0.5 0.032 [uitext $UI_botaddnum 0.6]
]
uifill 0 0.015
uihlist 0.05 [
uivlist 0.01 [
UIbutton "" [uitext "Add Bot" 0.65 ; UI_keyref 1 0.027 0.027 "Ins" "" 0.4] 0.2 0.04 [addbot $UI_botskill]
UIbutton "" [uitext (concatword "Add " $UI_botaddnum " Bots") 0.65] 0.2 0.04 [loop a (UI_botaddnum) [addbot $UI_botskill]]
]
uivlist 0.01 [
UIbutton "" [uitext "Delete Bot" 0.65 ; UI_keyref 1 0.027 0.027 "Del" "" 0.4] 0.2 0.04 [delbot]
UIbutton "" [uitext "Clear Bots" 0.65] 0.2 0.04 [clearbots]
]
]
]
]
] [] [] [] "Bots"
///////////////////////////////////////////////////////////////////////////////
// Display Changes //
///////////////////////////////////////////////////////////////////////////////
UImenu "changes" [
uivlist 0.02 [
uiclamp 1 1
UItitle [uitext "Apply changes for:" 0.6] 0 0.03
uiclamp- 1 1
uivlist 0.01 [
loop i $pendingchanges [
uitext (concatword "^f8" (pendingchanges $i)) 0.6
]
]
uihlist 0 [
UIbutton "hold2" [uitext "Yes" 0.6] 0.18 0.032 [applychanges]
UIbutton "hold2" [uitext "No" 0.6] 0.18 0.032 [hideui "changes"]
]
]
] [if (= $pendingchanges 0) [hideui "changes"]]
///////////////////////////////////////////////////////////////////////////////
// Notepad //
///////////////////////////////////////////////////////////////////////////////
UI_notepadfile = "untitled.txt"
UI_cmc_from = ""
UI_cmc_to = ""
UImenu "notepad" [
uivlist 0.01 [
uihlist 0.01 [
uialign -1 -2
uifield UI_notepadfile -35 [] 0.6 [
uioutline (uifocus? 0xFF0000 $c_line)
uiclamp- 1 1 1 1
]
UIbutton "hold2" [uitext "Load" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textload $UI_notepadfile]
UIbutton "hold2" [uitext "Save" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textsave $UI_notepadfile]
UIbutton "hold2" [uitext "Exec" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textexec]
uispace 0.01 0 [UIbar 0 1]
UIbutton "hold2" [uitext "Copy" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textcopy]
UIbutton "hold2" [uitext "Paste" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textpaste]
UIbutton "hold2" [uitext "Select All" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textselectall]
uispace 0.01 0 [UIbar 0 1]
UIbutton "hold2" [uitext "Clear All" 0.6] 0.04 0.032 [textfocus $UI_notepadfile ; textclear]
]
uitexteditor $UI_notepadfile -80 20 1 "" 0 [
uioutline (uifocus? 0xFF0000 $c_line)
uiclamp- 1 1 1 1
]
textinit $UI_notepadfile $UI_notepadfile
]
] [] [] [] "Notepad"
notepad = [
if $numargs [UI_notepadfile = $arg1]
showui "notepad"
]
mapnotepad = [
UI_notepadfile = (concatword "media/map/" (? $numargs $arg1 $mapname) ".cfg")
showui "notepad"
]
copymapcfg = [
if $numargs [
UI_cmc_from = $arg1
UI_cmc_to = (? (= $numargs 2) $arg2 $mapname)
if (findfile (concatword "media/map/" $UI_cmc_from ".cfg")) [
if (findfile (concatword "media/map/" $UI_cmc_to ".cfg")) [showui "cmc_confirm"] [
textfocus "#copymapcfg"
textload (concatword "media/map/" $UI_cmc_from ".cfg")
textsave (concatword "media/map/" $UI_cmc_to ".cfg")
]
] [
echo (concatword "^f7Map config "^f8^" $UI_cmc_from "^f7^" does not exist!")
UI_cmc_from = "" ; UI_cmc_to = ""
]
]
]
UImenu "cmc_confirm" [
uivlist 0.02 [
uiclamp 1 1
UItitle [uitext "Copy map config:" 0.6] 0 0.03
uiclamp- 1 1
uivlist 0.01 [
uitext (concatword "^f2" $UI_cmc_from) 0.6
UItriangle 0 0.01 0.01 180
uitext (concatword "^f2" $UI_cmc_to) 0.6
]
uihlist 0 [
UIbutton "hold2" [uitext "Proceed" 0.6] 0.18 0.032 [
textfocus "#copymapcfg"
textload (concatword "media/map/" $UI_cmc_from ".cfg")
textsave (concatword "media/map/" $UI_cmc_to ".cfg")
hideui "cmc_confirm"
]
UIbutton "hold2" [uitext "Cancel" 0.6] 0.18 0.032 [hideui "cmc_confirm"]
]
]
] [
if (|| [=s $UI_cmc_from ""] [=s $UI_cmc_to ""]) [hideui "cmc_confirm"]
] [UI_cmc_from = "" ; UI_cmc_to = ""]

View File

@ -57,7 +57,7 @@ newui "varicons" [
uialign 1 1
uispace 0.01 0.1 [
uivlist 0 [
looplist i (concatword "allfaces entselsnap entediting fullbright showmat") [
looplist i (concatword "allfaces entselsnap entediting fullbright showmat " (? $scoreboardmultiplayer "nompedit")) [
uifont "default_outline" [
uialign 1
if $$i [

View File

@ -495,7 +495,7 @@ UImenu "map_browser" [
custommaps = " "
loopfiles m "media/map" "ogz" [
if (< (indexof $editmaps $m) 0) [
custommaps = (concat $custommaps (escape $m))
custommaps = (concat $custommaps $m)
]
]
]

View File

@ -0,0 +1,222 @@
///////////////////////////////////////////////////////////////////////////////
// Scoreboard //
///////////////////////////////////////////////////////////////////////////////
newui "scoreboard" [
if $mainmenu [hideui "scoreboard"]
uiallowinput 0
refreshscoreboard
uicolor (? $sbtransparent $c_menu_a $c_menu) 0 0 [
uivlist 0 [
UI_sbheader
uifill 0 0.005
if (> $getmode 2) UI_playertableteam UI_playertablesolo
UI_spectatorlist
]
]
] [if $mainmenu [hideui "scoreboard"]]
///////////////////////////////////////////////////////////////////////////////
UI_sbwsolo = 0.68
UI_sbwteam = 1.18
UI_sbheader = [
uifill 0 0.005
uifill (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) 0.05 [
uifill (-f (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) (? (= $showip 1) 0.18 0)) 0 [
uialign -1
uiclip (-f (? (> $getmode 2) $UI_sbwteam $UI_sbwsolo) (? (= $showip 1) 0.18 0)) 0 [
uialign -1
uispace 0.01 0 [
uivlist 0 [
if $scoreboardservinfo [
uitext $scoreboardservinfo 0.65
] [
uitext "^f4Tesseract" 0.65
]
uihlist 0.015 [
uifill
uihlist 0.003 [
uitext "^fs[" 0.52
uitext (concatword (at ["^f0" "^f0" "^f2" "^f3"] $getmastermode) (getmastermodename $getmastermode)) 0.52
uitext "^fS]" 0.52
]
UItriangle 0x606060 0.01 0.01 270
uitext (getmodeprettyname $getmode) 0.52
UItriangle 0x606060 0.01 0.01 270
uitext $scoreboardmap 0.52
if (m_timed $getmode) [
UItriangle 0x606060 0.01 0.01 270
uitext (concatword (? (|| $intermission $paused) "^f3" "^f8") $scoreboardtime) 0.52
]
]
uialign* -1
]
]
]
]
if $scoreboardmultiplayer [
if $showip [
uifill 0.18 0 [
uialign 1
UIbar 0 1; uialign- -1
uiclip 0.18 0 [
uialign 1
uispace 0.01 0 [
uivlist 0.004 [
uicolortext $connectedip 0xA0A0A0 0.52
uicolortext $connectedport 0xA0A0A0 0.52
uialign* 1
]
]
uialign- 1
]
]
]
]
]
]
//-------------------------------------------------------------------------------------------------
UI_cw_s = 0.042
UI_cw_k = 0.054
UI_cw_d = 0.054
UI_cw_pj = 0.050
UI_cw_p = 0.050
UI_cw_cn = 0.040
UI_cw_n = [-f (? (> $getmode 2) (*f $UI_sbwteam 0.5) $UI_sbwsolo) (? (> $getmode 2) (? $showscore $UI_cw_s)) (? $showkills $UI_cw_k) (? $showdeaths $UI_cw_d) (? $scoreboardmultiplayer (? $showpj $UI_cw_pj)) (? $scoreboardmultiplayer (? $showping $UI_cw_p)) (? $scoreboardmultiplayer (? $showclientnum $UI_cw_cn)) 0.03]
// ^ blarg
UI_playertablesolo = [
uifill 0 0 [
uitable 0 0 [
uitableheader [
uifill 0.015
uifill (UI_cw_n) 0.022
if $showkills [uifill $UI_cw_k 0.022 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- 1 1]]
if $showdeaths [uifill $UI_cw_d 0.022 [uicolortext "D" 0xE56767 0.45 ; uialign- 1 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.022 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showping [uifill $UI_cw_p 0.022 [uicolortext "P" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showclientnum [uifill $UI_cw_cn 0.022 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- 1 1]]
]
uifill 0.015
] [uicolor 0x88161616 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 0 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- -1]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- 1]]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- 1]]
]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99323232 0x99262626) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f $UI_sbwsolo 0.002) 0.024]
]
]
]
]
]
UI_playertableteam = [
uifill 0 0 [
uihlist 0 [
uitable 0 0 [
uialign 0 -1
uitableheader [
uifill 0.015
if $scoreboardmultiplayer [
if $showclientnum [uifill $UI_cw_cn 0.042 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- -1 1]]
if $showping [uifill $UI_cw_p 0.042 [uicolortext "P" 0x77A1D9 0.45 ; uialign- -1 1]]
if $showpj [uifill $UI_cw_pj 0.042 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- -1 1]]
]
if $showdeaths [uifill $UI_cw_d 0.042 [uicolortext "D" 0xE56767 0.45 ; uialign- -1 1]]
if $showkills [uifill $UI_cw_k 0.042 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- -1 1]]
if $showscore [uifill $UI_cw_s 0.042 [uicolortext "Score" 0x62B370 0.45 ; uialign- -1 1]]
uifill (UI_cw_n) 0.042 [uicolortext (getteamscore 1) 0x4060D0 1 ; uialign- 1]
uifill 0.015
] [uicolor 0x99202860 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 1 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
if $scoreboardmultiplayer [
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- -1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- -1]]
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- -1]]
]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- -1]]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- -1]]
if $showscore [uifill $UI_cw_s 0.026 [uicolortext (getclientflags $cn) 0x62B370 0.52 ; uialign- -1]]
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- 1]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99333b40 0x99262b33) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f (*f $UI_sbwteam 0.5) 0.002) 0.024]
]
]
]
uitable 0 0 [
uialign 0 -1
uitableheader [
uifill 0.015
uifill (UI_cw_n) 0.042 [uicolortext (getteamscore 2) 0xD04040 1 ; uialign- -1]
if $showscore [uifill $UI_cw_s 0.042 [uicolortext "Score" 0x62B370 0.45 ; uialign- 1 1]]
if $showkills [uifill $UI_cw_k 0.042 [uicolortext "K" 0xBBCC8B 0.45 ; uialign- 1 1]]
if $showdeaths [uifill $UI_cw_d 0.042 [uicolortext "D" 0xE56767 0.45 ; uialign- 1 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.042 [uicolortext "PJ" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showping [uifill $UI_cw_p 0.042 [uicolortext "P" 0x77A1D9 0.45 ; uialign- 1 1]]
if $showclientnum [uifill $UI_cw_cn 0.042 [uicolortext "#" 0xA0A0A0 0.45 ; uialign- 1 1]]
]
uifill 0.015
] [uicolor 0x99602020 0 0 [uiclamp 1 1 1 1]]
UI_sbtc = 0
loopscoreboard cn 2 [
UI_sbtc = (! $UI_sbtc)
uitablerow [
uifill 0.015
uifill (UI_cw_n) 0.026 [uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57 ; uialign- -1]
if $showscore [uifill $UI_cw_s 0.026 [uicolortext (getclientflags $cn) 0x62B370 0.52 ; uialign- 1]]
if $showkills [uifill $UI_cw_k 0.026 [uicolortext (getclientfrags $cn) 0xBBCC8B 0.52 ; uialign- 1]]
if $showdeaths [uifill $UI_cw_d 0.026 [uicolortext (getclientdeaths $cn) 0xE56767 0.52 ; uialign- 1]]
if $scoreboardmultiplayer [
if $showpj [uifill $UI_cw_pj 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardpj $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showping [uifill $UI_cw_p 0.026 [uicolortext (? (isai $cn) "^f4-" (scoreboardping $cn)) 0x77A1D9 0.52 ; uialign- 1]]
if $showclientnum [uifill $UI_cw_cn 0.026 [uicolortext (? (isai $cn) "^f4-" $cn) 0xA0A0A0 0.52 ; uialign- 1]]
]
uifill 0.015
] [
uicolor (? $UI_sbtc 0x99403333 0x99332626) 0 0 [uiclamp 1 1 1 1]
pushif highlight (scoreboardhighlight $cn) [uioutline 0xA0A0A0 (-f (*f $UI_sbwteam 0.5) 0.002) 0.024]
]
]
]
]
]
]
//-------------------------------------------------------------------------------------------------
UI_spectatorlist = [
uicolor 0x88161616 0 0.022 [
uiclamp 1 1 1 1
if $showspectators [
uigrid (? (> $getmode 2) 3 2) 0 0 [
loopscoreboard cn -1 [
uispace 0.01 0.01 [
pushif sbhigh (scoreboardhighlight $cn) [
uioutline 0xA0A0A0 ; uiclamp- 1 1 1 1
]
uihlist 0.01 [
uicolortext (getclientcolorname $cn) (scoreboardstatus $cn) 0.57
if $scoreboardmultiplayer [if $showclientnum [uitext $cn 0.57]]
]
]
]
]
]
]
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 599 B

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 KiB

After

Width:  |  Height:  |  Size: 550 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,13 +1,9 @@
project('octacore', ['cpp'],
version: '0.0.1',
default_options: [
'buildtype=debugoptimized', 'cpp_std=c++17', 'warning_level=1'
],
default_options: ['buildtype=debugoptimized', 'cpp_std=c++17'],
meson_version: '>=0.46'
)
bin_path = join_paths(meson.source_root(), 'bin_unix')
cxx = meson.get_compiler('cpp')
subdir('src')

65
octacore_unix 100755
View File

@ -0,0 +1,65 @@
#!/bin/sh
# TESS_DATA should refer to the directory in which OF data files are placed.
#TESS_DATA=~/octacore
#TESS_DATA=/usr/local/octacore
TESS_DATA=.
# TESS_BIN should refer to the directory in which OF executable files are placed.
TESS_BIN=${TESS_DATA}/bin_unix
# TESS_OPTIONS contains any command line options you would like to start OF with.
#TESS_OPTIONS=""
TESS_OPTIONS="-u${HOME}/.octaforge"
# SYSTEM_NAME should be set to the name of your operating system.
#SYSTEM_NAME=Linux
SYSTEM_NAME=`uname -s`
# MACHINE_NAME should be set to the name of your processor.
#MACHINE_NAME=i686
MACHINE_NAME=`uname -m`
case ${SYSTEM_NAME} in
Linux)
SYSTEM_NAME=linux_
;;
*)
SYSTEM_NAME=unknown_
;;
esac
case ${MACHINE_NAME} in
i486|i586|i686)
MACHINE_NAME=
;;
x86_64|amd64)
MACHINE_NAME=64_
;;
*)
if [ ${SYSTEM_NAME} != native_ ]
then
SYSTEM_NAME=native_
fi
MACHINE_NAME=
;;
esac
if [ -x ${TESS_BIN}/native_client ]
then
SYSTEM_NAME=native_
MACHINE_NAME=
fi
if [ -x ${TESS_BIN}/${SYSTEM_NAME}${MACHINE_NAME}client ]
then
cd ${TESS_DATA}
exec ${TESS_BIN}/${SYSTEM_NAME}${MACHINE_NAME}client ${TESS_OPTIONS} "$@"
else
echo "Your platform does not have a pre-compiled OctaForge client."
echo "Please follow the following steps to build a native client:"
echo "1) Ensure you have the SDL2, SDL2-image, SDL2-mixer, and OpenGL libraries installed."
echo "2) Type \"make -C src install\"."
echo "3) If the build succeeds, run this script again."
exit 1
fi

View File

@ -1,15 +1,14 @@
client_src = [
'../sauerlib/tools.cc',
'../sauerlib/encoding.cc',
'../sauerlib/stream.cc',
'../shared/crypto.cc',
'../shared/geom.cc',
'../shared/glemu.cc',
'../shared/gzstream.cc',
'../shared/stream.cc',
'../shared/tools.cc',
'../shared/zip.cc',
'../engine/aa.cc',
'../engine/bih.cc',
'../engine/blend.cc',
'../engine/client.cc',
'../engine/command.cc',
'../engine/console.cc',
'../engine/dynlight.cc',
@ -17,6 +16,7 @@ client_src = [
'../engine/light.cc',
'../engine/main.cc',
'../engine/material.cc',
'../engine/menus.cc',
'../engine/movie.cc',
'../engine/normal.cc',
'../engine/octa.cc',
@ -31,27 +31,41 @@ client_src = [
'../engine/rendersky.cc',
'../engine/rendertext.cc',
'../engine/renderva.cc',
'../engine/server.cc',
'../engine/serverbrowser.cc',
'../engine/shader.cc',
'../engine/sound.cc',
'../engine/stain.cc',
'../engine/texture.cc',
'../engine/ui.cc',
'../engine/water.cc',
'../engine/world.cc',
'../engine/worldio.cc',
'../game/ai.cc',
'../game/client.cc',
'../game/entities.cc',
'../game/game.cc',
'../game/render.cc',
'../game/scoreboard.cc',
'../game/server.cc',
'../game/waypoint.cc',
'../game/weapon.cc'
]
threads_dep = dependency('threads')
sdl2_dep = dependency('sdl2')
sdl2_image_dep = dependency('SDL2_image')
sdl2_mixer_dep = dependency('SDL2_mixer')
zlib_dep = dependency('zlib')
gl_dep = dependency('gl')
rt_dep = cxx.find_library('rt', required: false)
executable('native_client',
client_src,
dependencies: [
threads_dep, sdl2_dep, sdl2_image_dep,
zlib_dep, gl_dep, rt_dep
threads_dep, libenet, sdl2_dep, sdl2_image_dep,
sdl2_mixer_dep, zlib_dep, gl_dep
],
include_directories: octacore_includes
include_directories: octacore_includes,
install: true,
install_dir: join_paths(meson.source_root(), 'bin_unix')
)

View File

@ -0,0 +1,150 @@
callbacks.lo: callbacks.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h include/enet/enet.h \
/usr/include/stdlib.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
include/enet/enet.h:
/usr/include/stdlib.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,159 @@
compress.lo: compress.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h /usr/include/string.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
include/enet/enet.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/string.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/stdlib.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,159 @@
host.lo: host.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h /usr/include/string.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
include/enet/enet.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/string.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/stdlib.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,150 @@
list.lo: list.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h include/enet/enet.h \
/usr/include/stdlib.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
include/enet/enet.h:
/usr/include/stdlib.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,159 @@
packet.lo: packet.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h /usr/include/string.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
include/enet/enet.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/string.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/stdlib.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,159 @@
peer.lo: peer.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h /usr/include/string.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
include/enet/enet.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/string.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/stdlib.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,185 @@
protocol.lo: protocol.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h /usr/include/stdio.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
/usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/string.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
include/enet/utility.h include/enet/time.h include/enet/enet.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
/usr/include/x86_64-linux-gnu/sys/time.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h /usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/stdio.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/libio.h:
/usr/include/_G_config.h:
/usr/include/wchar.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/string.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/stdlib.h:
include/enet/utility.h:
include/enet/time.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:

View File

@ -0,0 +1,228 @@
unix.lo: unix.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h \
/usr/include/x86_64-linux-gnu/sys/types.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/sys/uio.h \
/usr/include/x86_64-linux-gnu/bits/uio.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h \
/usr/include/x86_64-linux-gnu/sys/ioctl.h \
/usr/include/x86_64-linux-gnu/bits/ioctls.h \
/usr/include/x86_64-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/x86_64-linux-gnu/asm/ioctl.h \
/usr/include/asm-generic/ioctl.h \
/usr/include/x86_64-linux-gnu/bits/ioctl-types.h \
/usr/include/x86_64-linux-gnu/sys/ttydefaults.h \
/usr/include/x86_64-linux-gnu/sys/time.h /usr/include/arpa/inet.h \
/usr/include/netinet/in.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h /usr/include/stdint.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/netdb.h \
/usr/include/rpc/netdb.h /usr/include/x86_64-linux-gnu/bits/netdb.h \
/usr/include/unistd.h /usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
/usr/include/string.h /usr/include/xlocale.h \
/usr/include/x86_64-linux-gnu/bits/string.h \
/usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/stdlib.h \
/usr/include/errno.h /usr/include/x86_64-linux-gnu/bits/errno.h \
/usr/include/linux/errno.h /usr/include/x86_64-linux-gnu/asm/errno.h \
/usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
include/enet/enet.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h include/enet/unix.h \
include/enet/types.h include/enet/protocol.h include/enet/list.h \
include/enet/callbacks.h /usr/include/fcntl.h \
/usr/include/x86_64-linux-gnu/bits/fcntl.h \
/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h \
/usr/include/x86_64-linux-gnu/bits/stat.h \
/usr/include/x86_64-linux-gnu/sys/poll.h \
/usr/include/x86_64-linux-gnu/bits/poll.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/time.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/sigset.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/sys/uio.h:
/usr/include/x86_64-linux-gnu/bits/uio.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/x86_64-linux-gnu/sys/ioctl.h:
/usr/include/x86_64-linux-gnu/bits/ioctls.h:
/usr/include/x86_64-linux-gnu/asm/ioctls.h:
/usr/include/asm-generic/ioctls.h:
/usr/include/linux/ioctl.h:
/usr/include/x86_64-linux-gnu/asm/ioctl.h:
/usr/include/asm-generic/ioctl.h:
/usr/include/x86_64-linux-gnu/bits/ioctl-types.h:
/usr/include/x86_64-linux-gnu/sys/ttydefaults.h:
/usr/include/x86_64-linux-gnu/sys/time.h:
/usr/include/arpa/inet.h:
/usr/include/netinet/in.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdint.h:
/usr/include/stdint.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/netdb.h:
/usr/include/rpc/netdb.h:
/usr/include/x86_64-linux-gnu/bits/netdb.h:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
/usr/include/string.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/string.h:
/usr/include/x86_64-linux-gnu/bits/string2.h:
/usr/include/stdlib.h:
/usr/include/errno.h:
/usr/include/x86_64-linux-gnu/bits/errno.h:
/usr/include/linux/errno.h:
/usr/include/x86_64-linux-gnu/asm/errno.h:
/usr/include/asm-generic/errno.h:
/usr/include/asm-generic/errno-base.h:
include/enet/enet.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
include/enet/unix.h:
include/enet/types.h:
include/enet/protocol.h:
include/enet/list.h:
include/enet/callbacks.h:
/usr/include/fcntl.h:
/usr/include/x86_64-linux-gnu/bits/fcntl.h:
/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h:
/usr/include/x86_64-linux-gnu/bits/stat.h:
/usr/include/x86_64-linux-gnu/sys/poll.h:
/usr/include/x86_64-linux-gnu/bits/poll.h:

View File

@ -0,0 +1,6 @@
win32.lo: win32.c /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:

Binary file not shown.

View File

@ -0,0 +1 @@
../libenet.la

View File

@ -0,0 +1,41 @@
# libenet.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1.3
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname=''
# Names of this library.
library_names=''
# The name of the static archive.
old_library='libenet.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=''
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libenet.
current=6
age=4
revision=0
# Is this an already installed library?
installed=yes
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'

179
src/enet/ChangeLog 100644
View File

@ -0,0 +1,179 @@
* use getaddrinfo and getnameinfo where available
ENet 1.3.13 (April 30, 2015):
* miscellaneous bug fixes
* added premake and cmake support
* miscellaneous documentation cleanups
ENet 1.3.12 (April 24, 2014):
* added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of
data waiting to be delivered on a peer (beware that the default maximumPacketSize is
32MB and should be set higher if desired as should maximumWaitingData)
ENet 1.3.11 (December 26, 2013):
* allow an ENetHost to connect to itself
* fixed possible bug with disconnect notifications during connect attempts
* fixed some preprocessor definition bugs
ENet 1.3.10 (October 23, 2013);
* doubled maximum reliable window size
* fixed RCVTIMEO/SNDTIMEO socket options and also added NODELAY
ENet 1.3.9 (August 19, 2013):
* added duplicatePeers option to ENetHost which can limit the number of peers from duplicate IPs
* added enet_socket_get_option() and ENET_SOCKOPT_ERROR
* added enet_host_random_seed() platform stub
ENet 1.3.8 (June 2, 2013):
* added enet_linked_version() for checking the linked version
* added enet_socket_get_address() for querying the local address of a socket
* silenced some debugging prints unless ENET_DEBUG is defined during compilation
* handle EINTR in enet_socket_wait() so that enet_host_service() doesn't propagate errors from signals
* optimized enet_host_bandwidth_throttle() to be less expensive for large numbers of peers
ENet 1.3.7 (March 6, 2013):
* added ENET_PACKET_FLAG_SENT to indicate that a packet is being freed because it has been sent
* added userData field to ENetPacket
* changed how random seed is generated on Windows to avoid import warnings
* fixed case where disconnects could be generated with no preceding connect event
ENet 1.3.6 (December 11, 2012):
* added support for intercept callback in ENetHost that can be used to process raw packets before ENet
* added enet_socket_shutdown() for issuing shutdown on a socket
* fixed enet_socket_connect() to not error on non-blocking connects
* fixed bug in MTU negotiation during connections
ENet 1.3.5 (July 31, 2012):
* fixed bug in unreliable packet fragment queuing
ENet 1.3.4 (May 29, 2012):
* added enet_peer_ping_interval() for configuring per-peer ping intervals
* added enet_peer_timeout() for configuring per-peer timeouts
* added protocol packet size limits
ENet 1.3.3 (June 28, 2011):
* fixed bug with simultaneous disconnects not dispatching events
ENet 1.3.2 (May 31, 2011):
* added support for unreliable packet fragmenting via the packet flag
ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT
* fixed regression in unreliable packet queuing
* added check against received port to limit some forms of IP-spoofing
ENet 1.3.1 (February 10, 2011):
* fixed bug in tracking of reliable data in transit
* reliable data window size now scales with the throttle
* fixed bug in fragment length calculation when checksums are used
ENet 1.3.0 (June 5, 2010):
* enet_host_create() now requires the channel limit to be specified as
a parameter
* enet_host_connect() now accepts a data parameter which is supplied
to the receiving receiving host in the event data field for a connect event
* added an adaptive order-2 PPM range coder as a built-in compressor option
which can be set with enet_host_compress_with_range_coder()
* added support for packet compression configurable with a callback
* improved session number handling to not rely on the packet checksum
field, saving 4 bytes per packet unless the checksum option is used
* removed the dependence on the rand callback for session number handling
Caveats: This version is not protocol compatible with the 1.2 series or
earlier. The enet_host_connect and enet_host_create API functions require
supplying additional parameters.
ENet 1.2.5 (June 28, 2011):
* fixed bug with simultaneous disconnects not dispatching events
ENet 1.2.4 (May 31, 2011):
* fixed regression in unreliable packet queuing
* added check against received port to limit some forms of IP-spoofing
ENet 1.2.3 (February 10, 2011):
* fixed bug in tracking reliable data in transit
ENet 1.2.2 (June 5, 2010):
* checksum functionality is now enabled by setting a checksum callback
inside ENetHost instead of being a configure script option
* added totalSentData, totalSentPackets, totalReceivedData, and
totalReceivedPackets counters inside ENetHost for getting usage
statistics
* added enet_host_channel_limit() for limiting the maximum number of
channels allowed by connected peers
* now uses dispatch queues for event dispatch rather than potentially
unscalable array walking
* added no_memory callback that is called when a malloc attempt fails,
such that if no_memory returns rather than aborts (the default behavior),
then the error is propagated to the return value of the API calls
* now uses packed attribute for protocol structures on platforms with
strange alignment rules
* improved autoconf build system contributed by Nathan Brink allowing
for easier building as a shared library
Caveats: If you were using the compile-time option that enabled checksums,
make sure to set the checksum callback inside ENetHost to enet_crc32 to
regain the old behavior. The ENetCallbacks structure has added new fields,
so make sure to clear the structure to zero before use if
using enet_initialize_with_callbacks().
ENet 1.2.1 (November 12, 2009):
* fixed bug that could cause disconnect events to be dropped
* added thin wrapper around select() for portable usage
* added ENET_SOCKOPT_REUSEADDR socket option
* factored enet_socket_bind()/enet_socket_listen() out of enet_socket_create()
* added contributed Code::Blocks build file
ENet 1.2 (February 12, 2008):
* fixed bug in VERIFY_CONNECT acknowledgement that could cause connect
attempts to occasionally timeout
* fixed acknowledgements to check both the outgoing and sent queues
when removing acknowledged packets
* fixed accidental bit rot in the MSVC project file
* revised sequence number overflow handling to address some possible
disconnect bugs
* added enet_host_check_events() for getting only local queued events
* factored out socket option setting into enet_socket_set_option() so
that socket options are now set separately from enet_socket_create()
Caveats: While this release is superficially protocol compatible with 1.1,
differences in the sequence number overflow handling can potentially cause
random disconnects.
ENet 1.1 (June 6, 2007):
* optional CRC32 just in case someone needs a stronger checksum than UDP
provides (--enable-crc32 configure option)
* the size of packet headers are half the size they used to be (so less
overhead when sending small packets)
* enet_peer_disconnect_later() that waits till all queued outgoing
packets get sent before issuing an actual disconnect
* freeCallback field in individual packets for notification of when a
packet is about to be freed
* ENET_PACKET_FLAG_NO_ALLOCATE for supplying pre-allocated data to a
packet (can be used in concert with freeCallback to support some custom
allocation schemes that the normal memory allocation callbacks would
normally not allow)
* enet_address_get_host_ip() for printing address numbers
* promoted the enet_socket_*() functions to be part of the API now
* a few stability/crash fixes

7
src/enet/LICENSE 100644
View File

@ -0,0 +1,7 @@
Copyright (c) 2002-2015 Lee Salzman
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.

15
src/enet/README 100644
View File

@ -0,0 +1,15 @@
Please visit the ENet homepage at http://enet.bespin.org for installation
and usage instructions.
If you obtained this package from github, the quick description on how to build
is:
# Generate the build system.
autoreconf -vfi
# Compile and install the library.
./configure && make && make install

View File

@ -0,0 +1,53 @@
/**
@file callbacks.c
@brief ENet callback functions
*/
#define ENET_BUILDING_LIB 1
#include "enet/enet.h"
static ENetCallbacks callbacks = { malloc, free, abort };
int
enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits)
{
if (version < ENET_VERSION_CREATE (1, 3, 0))
return -1;
if (inits -> malloc != NULL || inits -> free != NULL)
{
if (inits -> malloc == NULL || inits -> free == NULL)
return -1;
callbacks.malloc = inits -> malloc;
callbacks.free = inits -> free;
}
if (inits -> no_memory != NULL)
callbacks.no_memory = inits -> no_memory;
return enet_initialize ();
}
ENetVersion
enet_linked_version (void)
{
return ENET_VERSION;
}
void *
enet_malloc (size_t size)
{
void * memory = callbacks.malloc (size);
if (memory == NULL)
callbacks.no_memory ();
return memory;
}
void
enet_free (void * memory)
{
callbacks.free (memory);
}

654
src/enet/compress.c 100644
View File

@ -0,0 +1,654 @@
/**
@file compress.c
@brief An adaptive order-2 PPM range coder
*/
#define ENET_BUILDING_LIB 1
#include <string.h>
#include "enet/enet.h"
typedef struct _ENetSymbol
{
/* binary indexed tree of symbols */
enet_uint8 value;
enet_uint8 count;
enet_uint16 under;
enet_uint16 left, right;
/* context defined by this symbol */
enet_uint16 symbols;
enet_uint16 escapes;
enet_uint16 total;
enet_uint16 parent;
} ENetSymbol;
/* adaptation constants tuned aggressively for small packet sizes rather than large file compression */
enum
{
ENET_RANGE_CODER_TOP = 1<<24,
ENET_RANGE_CODER_BOTTOM = 1<<16,
ENET_CONTEXT_SYMBOL_DELTA = 3,
ENET_CONTEXT_SYMBOL_MINIMUM = 1,
ENET_CONTEXT_ESCAPE_MINIMUM = 1,
ENET_SUBCONTEXT_ORDER = 2,
ENET_SUBCONTEXT_SYMBOL_DELTA = 2,
ENET_SUBCONTEXT_ESCAPE_DELTA = 5
};
/* context exclusion roughly halves compression speed, so disable for now */
#undef ENET_CONTEXT_EXCLUSION
typedef struct _ENetRangeCoder
{
/* only allocate enough symbols for reasonable MTUs, would need to be larger for large file compression */
ENetSymbol symbols[4096];
} ENetRangeCoder;
void *
enet_range_coder_create (void)
{
ENetRangeCoder * rangeCoder = (ENetRangeCoder *) enet_malloc (sizeof (ENetRangeCoder));
if (rangeCoder == NULL)
return NULL;
return rangeCoder;
}
void
enet_range_coder_destroy (void * context)
{
ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context;
if (rangeCoder == NULL)
return;
enet_free (rangeCoder);
}
#define ENET_SYMBOL_CREATE(symbol, value_, count_) \
{ \
symbol = & rangeCoder -> symbols [nextSymbol ++]; \
symbol -> value = value_; \
symbol -> count = count_; \
symbol -> under = count_; \
symbol -> left = 0; \
symbol -> right = 0; \
symbol -> symbols = 0; \
symbol -> escapes = 0; \
symbol -> total = 0; \
symbol -> parent = 0; \
}
#define ENET_CONTEXT_CREATE(context, escapes_, minimum) \
{ \
ENET_SYMBOL_CREATE (context, 0, 0); \
(context) -> escapes = escapes_; \
(context) -> total = escapes_ + 256*minimum; \
(context) -> symbols = 0; \
}
static enet_uint16
enet_symbol_rescale (ENetSymbol * symbol)
{
enet_uint16 total = 0;
for (;;)
{
symbol -> count -= symbol->count >> 1;
symbol -> under = symbol -> count;
if (symbol -> left)
symbol -> under += enet_symbol_rescale (symbol + symbol -> left);
total += symbol -> under;
if (! symbol -> right) break;
symbol += symbol -> right;
}
return total;
}
#define ENET_CONTEXT_RESCALE(context, minimum) \
{ \
(context) -> total = (context) -> symbols ? enet_symbol_rescale ((context) + (context) -> symbols) : 0; \
(context) -> escapes -= (context) -> escapes >> 1; \
(context) -> total += (context) -> escapes + 256*minimum; \
}
#define ENET_RANGE_CODER_OUTPUT(value) \
{ \
if (outData >= outEnd) \
return 0; \
* outData ++ = value; \
}
#define ENET_RANGE_CODER_ENCODE(under, count, total) \
{ \
encodeRange /= (total); \
encodeLow += (under) * encodeRange; \
encodeRange *= (count); \
for (;;) \
{ \
if((encodeLow ^ (encodeLow + encodeRange)) >= ENET_RANGE_CODER_TOP) \
{ \
if(encodeRange >= ENET_RANGE_CODER_BOTTOM) break; \
encodeRange = -encodeLow & (ENET_RANGE_CODER_BOTTOM - 1); \
} \
ENET_RANGE_CODER_OUTPUT (encodeLow >> 24); \
encodeRange <<= 8; \
encodeLow <<= 8; \
} \
}
#define ENET_RANGE_CODER_FLUSH \
{ \
while (encodeLow) \
{ \
ENET_RANGE_CODER_OUTPUT (encodeLow >> 24); \
encodeLow <<= 8; \
} \
}
#define ENET_RANGE_CODER_FREE_SYMBOLS \
{ \
if (nextSymbol >= sizeof (rangeCoder -> symbols) / sizeof (ENetSymbol) - ENET_SUBCONTEXT_ORDER ) \
{ \
nextSymbol = 0; \
ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM); \
predicted = 0; \
order = 0; \
} \
}
#define ENET_CONTEXT_ENCODE(context, symbol_, value_, under_, count_, update, minimum) \
{ \
under_ = value*minimum; \
count_ = minimum; \
if (! (context) -> symbols) \
{ \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
(context) -> symbols = symbol_ - (context); \
} \
else \
{ \
ENetSymbol * node = (context) + (context) -> symbols; \
for (;;) \
{ \
if (value_ < node -> value) \
{ \
node -> under += update; \
if (node -> left) { node += node -> left; continue; } \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
node -> left = symbol_ - node; \
} \
else \
if (value_ > node -> value) \
{ \
under_ += node -> under; \
if (node -> right) { node += node -> right; continue; } \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
node -> right = symbol_ - node; \
} \
else \
{ \
count_ += node -> count; \
under_ += node -> under - node -> count; \
node -> under += update; \
node -> count += update; \
symbol_ = node; \
} \
break; \
} \
} \
}
#ifdef ENET_CONTEXT_EXCLUSION
static const ENetSymbol emptyContext = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#define ENET_CONTEXT_WALK(context, body) \
{ \
const ENetSymbol * node = (context) + (context) -> symbols; \
const ENetSymbol * stack [256]; \
size_t stackSize = 0; \
while (node -> left) \
{ \
stack [stackSize ++] = node; \
node += node -> left; \
} \
for (;;) \
{ \
body; \
if (node -> right) \
{ \
node += node -> right; \
while (node -> left) \
{ \
stack [stackSize ++] = node; \
node += node -> left; \
} \
} \
else \
if (stackSize <= 0) \
break; \
else \
node = stack [-- stackSize]; \
} \
}
#define ENET_CONTEXT_ENCODE_EXCLUDE(context, value_, under, total, minimum) \
ENET_CONTEXT_WALK(context, { \
if (node -> value != value_) \
{ \
enet_uint16 parentCount = rangeCoder -> symbols [node -> parent].count + minimum; \
if (node -> value < value_) \
under -= parentCount; \
total -= parentCount; \
} \
})
#endif
size_t
enet_range_coder_compress (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit)
{
ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context;
enet_uint8 * outStart = outData, * outEnd = & outData [outLimit];
const enet_uint8 * inData, * inEnd;
enet_uint32 encodeLow = 0, encodeRange = ~0;
ENetSymbol * root;
enet_uint16 predicted = 0;
size_t order = 0, nextSymbol = 0;
if (rangeCoder == NULL || inBufferCount <= 0 || inLimit <= 0)
return 0;
inData = (const enet_uint8 *) inBuffers -> data;
inEnd = & inData [inBuffers -> dataLength];
inBuffers ++;
inBufferCount --;
ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM);
for (;;)
{
ENetSymbol * subcontext, * symbol;
#ifdef ENET_CONTEXT_EXCLUSION
const ENetSymbol * childContext = & emptyContext;
#endif
enet_uint8 value;
enet_uint16 count, under, * parent = & predicted, total;
if (inData >= inEnd)
{
if (inBufferCount <= 0)
break;
inData = (const enet_uint8 *) inBuffers -> data;
inEnd = & inData [inBuffers -> dataLength];
inBuffers ++;
inBufferCount --;
}
value = * inData ++;
for (subcontext = & rangeCoder -> symbols [predicted];
subcontext != root;
#ifdef ENET_CONTEXT_EXCLUSION
childContext = subcontext,
#endif
subcontext = & rangeCoder -> symbols [subcontext -> parent])
{
ENET_CONTEXT_ENCODE (subcontext, symbol, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0);
* parent = symbol - rangeCoder -> symbols;
parent = & symbol -> parent;
total = subcontext -> total;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > ENET_SUBCONTEXT_SYMBOL_DELTA + ENET_SUBCONTEXT_ESCAPE_DELTA)
ENET_CONTEXT_ENCODE_EXCLUDE (childContext, value, under, total, 0);
#endif
if (count > 0)
{
ENET_RANGE_CODER_ENCODE (subcontext -> escapes + under, count, total);
}
else
{
if (subcontext -> escapes > 0 && subcontext -> escapes < total)
ENET_RANGE_CODER_ENCODE (0, subcontext -> escapes, total);
subcontext -> escapes += ENET_SUBCONTEXT_ESCAPE_DELTA;
subcontext -> total += ENET_SUBCONTEXT_ESCAPE_DELTA;
}
subcontext -> total += ENET_SUBCONTEXT_SYMBOL_DELTA;
if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || subcontext -> total > ENET_RANGE_CODER_BOTTOM - 0x100)
ENET_CONTEXT_RESCALE (subcontext, 0);
if (count > 0) goto nextInput;
}
ENET_CONTEXT_ENCODE (root, symbol, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM);
* parent = symbol - rangeCoder -> symbols;
parent = & symbol -> parent;
total = root -> total;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > ENET_SUBCONTEXT_SYMBOL_DELTA + ENET_SUBCONTEXT_ESCAPE_DELTA)
ENET_CONTEXT_ENCODE_EXCLUDE (childContext, value, under, total, ENET_CONTEXT_SYMBOL_MINIMUM);
#endif
ENET_RANGE_CODER_ENCODE (root -> escapes + under, count, total);
root -> total += ENET_CONTEXT_SYMBOL_DELTA;
if (count > 0xFF - 2*ENET_CONTEXT_SYMBOL_DELTA + ENET_CONTEXT_SYMBOL_MINIMUM || root -> total > ENET_RANGE_CODER_BOTTOM - 0x100)
ENET_CONTEXT_RESCALE (root, ENET_CONTEXT_SYMBOL_MINIMUM);
nextInput:
if (order >= ENET_SUBCONTEXT_ORDER)
predicted = rangeCoder -> symbols [predicted].parent;
else
order ++;
ENET_RANGE_CODER_FREE_SYMBOLS;
}
ENET_RANGE_CODER_FLUSH;
return (size_t) (outData - outStart);
}
#define ENET_RANGE_CODER_SEED \
{ \
if (inData < inEnd) decodeCode |= * inData ++ << 24; \
if (inData < inEnd) decodeCode |= * inData ++ << 16; \
if (inData < inEnd) decodeCode |= * inData ++ << 8; \
if (inData < inEnd) decodeCode |= * inData ++; \
}
#define ENET_RANGE_CODER_READ(total) ((decodeCode - decodeLow) / (decodeRange /= (total)))
#define ENET_RANGE_CODER_DECODE(under, count, total) \
{ \
decodeLow += (under) * decodeRange; \
decodeRange *= (count); \
for (;;) \
{ \
if((decodeLow ^ (decodeLow + decodeRange)) >= ENET_RANGE_CODER_TOP) \
{ \
if(decodeRange >= ENET_RANGE_CODER_BOTTOM) break; \
decodeRange = -decodeLow & (ENET_RANGE_CODER_BOTTOM - 1); \
} \
decodeCode <<= 8; \
if (inData < inEnd) \
decodeCode |= * inData ++; \
decodeRange <<= 8; \
decodeLow <<= 8; \
} \
}
#define ENET_CONTEXT_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, createRoot, visitNode, createRight, createLeft) \
{ \
under_ = 0; \
count_ = minimum; \
if (! (context) -> symbols) \
{ \
createRoot; \
} \
else \
{ \
ENetSymbol * node = (context) + (context) -> symbols; \
for (;;) \
{ \
enet_uint16 after = under_ + node -> under + (node -> value + 1)*minimum, before = node -> count + minimum; \
visitNode; \
if (code >= after) \
{ \
under_ += node -> under; \
if (node -> right) { node += node -> right; continue; } \
createRight; \
} \
else \
if (code < after - before) \
{ \
node -> under += update; \
if (node -> left) { node += node -> left; continue; } \
createLeft; \
} \
else \
{ \
value_ = node -> value; \
count_ += node -> count; \
under_ = after - before; \
node -> under += update; \
node -> count += update; \
symbol_ = node; \
} \
break; \
} \
} \
}
#define ENET_CONTEXT_TRY_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, exclude) \
ENET_CONTEXT_DECODE (context, symbol_, code, value_, under_, count_, update, minimum, return 0, exclude (node -> value, after, before), return 0, return 0)
#define ENET_CONTEXT_ROOT_DECODE(context, symbol_, code, value_, under_, count_, update, minimum, exclude) \
ENET_CONTEXT_DECODE (context, symbol_, code, value_, under_, count_, update, minimum, \
{ \
value_ = code / minimum; \
under_ = code - code%minimum; \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
(context) -> symbols = symbol_ - (context); \
}, \
exclude (node -> value, after, before), \
{ \
value_ = node->value + 1 + (code - after)/minimum; \
under_ = code - (code - after)%minimum; \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
node -> right = symbol_ - node; \
}, \
{ \
value_ = node->value - 1 - (after - before - code - 1)/minimum; \
under_ = code - (after - before - code - 1)%minimum; \
ENET_SYMBOL_CREATE (symbol_, value_, update); \
node -> left = symbol_ - node; \
}) \
#ifdef ENET_CONTEXT_EXCLUSION
typedef struct _ENetExclude
{
enet_uint8 value;
enet_uint16 under;
} ENetExclude;
#define ENET_CONTEXT_DECODE_EXCLUDE(context, total, minimum) \
{ \
enet_uint16 under = 0; \
nextExclude = excludes; \
ENET_CONTEXT_WALK (context, { \
under += rangeCoder -> symbols [node -> parent].count + minimum; \
nextExclude -> value = node -> value; \
nextExclude -> under = under; \
nextExclude ++; \
}); \
total -= under; \
}
#define ENET_CONTEXT_EXCLUDED(value_, after, before) \
{ \
size_t low = 0, high = nextExclude - excludes; \
for(;;) \
{ \
size_t mid = (low + high) >> 1; \
const ENetExclude * exclude = & excludes [mid]; \
if (value_ < exclude -> value) \
{ \
if (low + 1 < high) \
{ \
high = mid; \
continue; \
} \
if (exclude > excludes) \
after -= exclude [-1].under; \
} \
else \
{ \
if (value_ > exclude -> value) \
{ \
if (low + 1 < high) \
{ \
low = mid; \
continue; \
} \
} \
else \
before = 0; \
after -= exclude -> under; \
} \
break; \
} \
}
#endif
#define ENET_CONTEXT_NOT_EXCLUDED(value_, after, before)
size_t
enet_range_coder_decompress (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit)
{
ENetRangeCoder * rangeCoder = (ENetRangeCoder *) context;
enet_uint8 * outStart = outData, * outEnd = & outData [outLimit];
const enet_uint8 * inEnd = & inData [inLimit];
enet_uint32 decodeLow = 0, decodeCode = 0, decodeRange = ~0;
ENetSymbol * root;
enet_uint16 predicted = 0;
size_t order = 0, nextSymbol = 0;
#ifdef ENET_CONTEXT_EXCLUSION
ENetExclude excludes [256];
ENetExclude * nextExclude = excludes;
#endif
if (rangeCoder == NULL || inLimit <= 0)
return 0;
ENET_CONTEXT_CREATE (root, ENET_CONTEXT_ESCAPE_MINIMUM, ENET_CONTEXT_SYMBOL_MINIMUM);
ENET_RANGE_CODER_SEED;
for (;;)
{
ENetSymbol * subcontext, * symbol, * patch;
#ifdef ENET_CONTEXT_EXCLUSION
const ENetSymbol * childContext = & emptyContext;
#endif
enet_uint8 value = 0;
enet_uint16 code, under, count, bottom, * parent = & predicted, total;
for (subcontext = & rangeCoder -> symbols [predicted];
subcontext != root;
#ifdef ENET_CONTEXT_EXCLUSION
childContext = subcontext,
#endif
subcontext = & rangeCoder -> symbols [subcontext -> parent])
{
if (subcontext -> escapes <= 0)
continue;
total = subcontext -> total;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > 0)
ENET_CONTEXT_DECODE_EXCLUDE (childContext, total, 0);
#endif
if (subcontext -> escapes >= total)
continue;
code = ENET_RANGE_CODER_READ (total);
if (code < subcontext -> escapes)
{
ENET_RANGE_CODER_DECODE (0, subcontext -> escapes, total);
continue;
}
code -= subcontext -> escapes;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > 0)
{
ENET_CONTEXT_TRY_DECODE (subcontext, symbol, code, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0, ENET_CONTEXT_EXCLUDED);
}
else
#endif
{
ENET_CONTEXT_TRY_DECODE (subcontext, symbol, code, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0, ENET_CONTEXT_NOT_EXCLUDED);
}
bottom = symbol - rangeCoder -> symbols;
ENET_RANGE_CODER_DECODE (subcontext -> escapes + under, count, total);
subcontext -> total += ENET_SUBCONTEXT_SYMBOL_DELTA;
if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || subcontext -> total > ENET_RANGE_CODER_BOTTOM - 0x100)
ENET_CONTEXT_RESCALE (subcontext, 0);
goto patchContexts;
}
total = root -> total;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > 0)
ENET_CONTEXT_DECODE_EXCLUDE (childContext, total, ENET_CONTEXT_SYMBOL_MINIMUM);
#endif
code = ENET_RANGE_CODER_READ (total);
if (code < root -> escapes)
{
ENET_RANGE_CODER_DECODE (0, root -> escapes, total);
break;
}
code -= root -> escapes;
#ifdef ENET_CONTEXT_EXCLUSION
if (childContext -> total > 0)
{
ENET_CONTEXT_ROOT_DECODE (root, symbol, code, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM, ENET_CONTEXT_EXCLUDED);
}
else
#endif
{
ENET_CONTEXT_ROOT_DECODE (root, symbol, code, value, under, count, ENET_CONTEXT_SYMBOL_DELTA, ENET_CONTEXT_SYMBOL_MINIMUM, ENET_CONTEXT_NOT_EXCLUDED);
}
bottom = symbol - rangeCoder -> symbols;
ENET_RANGE_CODER_DECODE (root -> escapes + under, count, total);
root -> total += ENET_CONTEXT_SYMBOL_DELTA;
if (count > 0xFF - 2*ENET_CONTEXT_SYMBOL_DELTA + ENET_CONTEXT_SYMBOL_MINIMUM || root -> total > ENET_RANGE_CODER_BOTTOM - 0x100)
ENET_CONTEXT_RESCALE (root, ENET_CONTEXT_SYMBOL_MINIMUM);
patchContexts:
for (patch = & rangeCoder -> symbols [predicted];
patch != subcontext;
patch = & rangeCoder -> symbols [patch -> parent])
{
ENET_CONTEXT_ENCODE (patch, symbol, value, under, count, ENET_SUBCONTEXT_SYMBOL_DELTA, 0);
* parent = symbol - rangeCoder -> symbols;
parent = & symbol -> parent;
if (count <= 0)
{
patch -> escapes += ENET_SUBCONTEXT_ESCAPE_DELTA;
patch -> total += ENET_SUBCONTEXT_ESCAPE_DELTA;
}
patch -> total += ENET_SUBCONTEXT_SYMBOL_DELTA;
if (count > 0xFF - 2*ENET_SUBCONTEXT_SYMBOL_DELTA || patch -> total > ENET_RANGE_CODER_BOTTOM - 0x100)
ENET_CONTEXT_RESCALE (patch, 0);
}
* parent = bottom;
ENET_RANGE_CODER_OUTPUT (value);
if (order >= ENET_SUBCONTEXT_ORDER)
predicted = rangeCoder -> symbols [predicted].parent;
else
order ++;
ENET_RANGE_CODER_FREE_SYMBOLS;
}
return (size_t) (outData - outStart);
}
/** @defgroup host ENet host functions
@{
*/
/** Sets the packet compressor the host should use to the default range coder.
@param host host to enable the range coder for
@returns 0 on success, < 0 on failure
*/
int
enet_host_compress_with_range_coder (ENetHost * host)
{
ENetCompressor compressor;
memset (& compressor, 0, sizeof (compressor));
compressor.context = enet_range_coder_create();
if (compressor.context == NULL)
return -1;
compressor.compress = enet_range_coder_compress;
compressor.decompress = enet_range_coder_decompress;
compressor.destroy = enet_range_coder_destroy;
enet_host_compress (host, & compressor);
return 0;
}
/** @} */

492
src/enet/host.c 100644
View File

@ -0,0 +1,492 @@
/**
@file host.c
@brief ENet host management functions
*/
#define ENET_BUILDING_LIB 1
#include <string.h>
#include "enet/enet.h"
/** @defgroup host ENet host functions
@{
*/
/** Creates a host for communicating to peers.
@param address the address at which other peers may connect to this host. If NULL, then no peers may connect to the host.
@param peerCount the maximum number of peers that should be allocated for the host.
@param channelLimit the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT
@param incomingBandwidth downstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth.
@param outgoingBandwidth upstream bandwidth of the host in bytes/second; if 0, ENet will assume unlimited bandwidth.
@returns the host on success and NULL on failure
@remarks ENet will strategically drop packets on specific sides of a connection between hosts
to ensure the host's bandwidth is not overwhelmed. The bandwidth parameters also determine
the window size of a connection which limits the amount of reliable packets that may be in transit
at any given time.
*/
ENetHost *
enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelLimit, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth)
{
ENetHost * host;
ENetPeer * currentPeer;
if (peerCount > ENET_PROTOCOL_MAXIMUM_PEER_ID)
return NULL;
host = (ENetHost *) enet_malloc (sizeof (ENetHost));
if (host == NULL)
return NULL;
memset (host, 0, sizeof (ENetHost));
host -> peers = (ENetPeer *) enet_malloc (peerCount * sizeof (ENetPeer));
if (host -> peers == NULL)
{
enet_free (host);
return NULL;
}
memset (host -> peers, 0, peerCount * sizeof (ENetPeer));
host -> socket = enet_socket_create (ENET_SOCKET_TYPE_DATAGRAM);
if (host -> socket == ENET_SOCKET_NULL || (address != NULL && enet_socket_bind (host -> socket, address) < 0))
{
if (host -> socket != ENET_SOCKET_NULL)
enet_socket_destroy (host -> socket);
enet_free (host -> peers);
enet_free (host);
return NULL;
}
enet_socket_set_option (host -> socket, ENET_SOCKOPT_NONBLOCK, 1);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_BROADCAST, 1);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_RCVBUF, ENET_HOST_RECEIVE_BUFFER_SIZE);
enet_socket_set_option (host -> socket, ENET_SOCKOPT_SNDBUF, ENET_HOST_SEND_BUFFER_SIZE);
if (address != NULL && enet_socket_get_address (host -> socket, & host -> address) < 0)
host -> address = * address;
if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT;
else
if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT)
channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
host -> randomSeed = (enet_uint32) (size_t) host;
host -> randomSeed += enet_host_random_seed ();
host -> randomSeed = (host -> randomSeed << 16) | (host -> randomSeed >> 16);
host -> channelLimit = channelLimit;
host -> incomingBandwidth = incomingBandwidth;
host -> outgoingBandwidth = outgoingBandwidth;
host -> bandwidthThrottleEpoch = 0;
host -> recalculateBandwidthLimits = 0;
host -> mtu = ENET_HOST_DEFAULT_MTU;
host -> peerCount = peerCount;
host -> commandCount = 0;
host -> bufferCount = 0;
host -> checksum = NULL;
host -> receivedAddress.host = ENET_HOST_ANY;
host -> receivedAddress.port = 0;
host -> receivedData = NULL;
host -> receivedDataLength = 0;
host -> totalSentData = 0;
host -> totalSentPackets = 0;
host -> totalReceivedData = 0;
host -> totalReceivedPackets = 0;
host -> connectedPeers = 0;
host -> bandwidthLimitedPeers = 0;
host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
host -> maximumPacketSize = ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE;
host -> maximumWaitingData = ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA;
host -> compressor.context = NULL;
host -> compressor.compress = NULL;
host -> compressor.decompress = NULL;
host -> compressor.destroy = NULL;
host -> intercept = NULL;
enet_list_clear (& host -> dispatchQueue);
for (currentPeer = host -> peers;
currentPeer < & host -> peers [host -> peerCount];
++ currentPeer)
{
currentPeer -> host = host;
currentPeer -> incomingPeerID = currentPeer - host -> peers;
currentPeer -> outgoingSessionID = currentPeer -> incomingSessionID = 0xFF;
currentPeer -> data = NULL;
enet_list_clear (& currentPeer -> acknowledgements);
enet_list_clear (& currentPeer -> sentReliableCommands);
enet_list_clear (& currentPeer -> sentUnreliableCommands);
enet_list_clear (& currentPeer -> outgoingReliableCommands);
enet_list_clear (& currentPeer -> outgoingUnreliableCommands);
enet_list_clear (& currentPeer -> dispatchedCommands);
enet_peer_reset (currentPeer);
}
return host;
}
/** Destroys the host and all resources associated with it.
@param host pointer to the host to destroy
*/
void
enet_host_destroy (ENetHost * host)
{
ENetPeer * currentPeer;
if (host == NULL)
return;
enet_socket_destroy (host -> socket);
for (currentPeer = host -> peers;
currentPeer < & host -> peers [host -> peerCount];
++ currentPeer)
{
enet_peer_reset (currentPeer);
}
if (host -> compressor.context != NULL && host -> compressor.destroy)
(* host -> compressor.destroy) (host -> compressor.context);
enet_free (host -> peers);
enet_free (host);
}
/** Initiates a connection to a foreign host.
@param host host seeking the connection
@param address destination for the connection
@param channelCount number of channels to allocate
@param data user data supplied to the receiving host
@returns a peer representing the foreign host on success, NULL on failure
@remarks The peer returned will have not completed the connection until enet_host_service()
notifies of an ENET_EVENT_TYPE_CONNECT event for the peer.
*/
ENetPeer *
enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelCount, enet_uint32 data)
{
ENetPeer * currentPeer;
ENetChannel * channel;
ENetProtocol command;
if (channelCount < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT)
channelCount = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
else
if (channelCount > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
channelCount = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT;
for (currentPeer = host -> peers;
currentPeer < & host -> peers [host -> peerCount];
++ currentPeer)
{
if (currentPeer -> state == ENET_PEER_STATE_DISCONNECTED)
break;
}
if (currentPeer >= & host -> peers [host -> peerCount])
return NULL;
currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel));
if (currentPeer -> channels == NULL)
return NULL;
currentPeer -> channelCount = channelCount;
currentPeer -> state = ENET_PEER_STATE_CONNECTING;
currentPeer -> address = * address;
currentPeer -> connectID = ++ host -> randomSeed;
if (host -> outgoingBandwidth == 0)
currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
else
currentPeer -> windowSize = (host -> outgoingBandwidth /
ENET_PEER_WINDOW_SIZE_SCALE) *
ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
if (currentPeer -> windowSize < ENET_PROTOCOL_MINIMUM_WINDOW_SIZE)
currentPeer -> windowSize = ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
else
if (currentPeer -> windowSize > ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE)
currentPeer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
for (channel = currentPeer -> channels;
channel < & currentPeer -> channels [channelCount];
++ channel)
{
channel -> outgoingReliableSequenceNumber = 0;
channel -> outgoingUnreliableSequenceNumber = 0;
channel -> incomingReliableSequenceNumber = 0;
channel -> incomingUnreliableSequenceNumber = 0;
enet_list_clear (& channel -> incomingReliableCommands);
enet_list_clear (& channel -> incomingUnreliableCommands);
channel -> usedReliableWindows = 0;
memset (channel -> reliableWindows, 0, sizeof (channel -> reliableWindows));
}
command.header.command = ENET_PROTOCOL_COMMAND_CONNECT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE;
command.header.channelID = 0xFF;
command.connect.outgoingPeerID = ENET_HOST_TO_NET_16 (currentPeer -> incomingPeerID);
command.connect.incomingSessionID = currentPeer -> incomingSessionID;
command.connect.outgoingSessionID = currentPeer -> outgoingSessionID;
command.connect.mtu = ENET_HOST_TO_NET_32 (currentPeer -> mtu);
command.connect.windowSize = ENET_HOST_TO_NET_32 (currentPeer -> windowSize);
command.connect.channelCount = ENET_HOST_TO_NET_32 (channelCount);
command.connect.incomingBandwidth = ENET_HOST_TO_NET_32 (host -> incomingBandwidth);
command.connect.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth);
command.connect.packetThrottleInterval = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleInterval);
command.connect.packetThrottleAcceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleAcceleration);
command.connect.packetThrottleDeceleration = ENET_HOST_TO_NET_32 (currentPeer -> packetThrottleDeceleration);
command.connect.connectID = currentPeer -> connectID;
command.connect.data = ENET_HOST_TO_NET_32 (data);
enet_peer_queue_outgoing_command (currentPeer, & command, NULL, 0, 0);
return currentPeer;
}
/** Queues a packet to be sent to all peers associated with the host.
@param host host on which to broadcast the packet
@param channelID channel on which to broadcast
@param packet packet to broadcast
*/
void
enet_host_broadcast (ENetHost * host, enet_uint8 channelID, ENetPacket * packet)
{
ENetPeer * currentPeer;
for (currentPeer = host -> peers;
currentPeer < & host -> peers [host -> peerCount];
++ currentPeer)
{
if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
continue;
enet_peer_send (currentPeer, channelID, packet);
}
if (packet -> referenceCount == 0)
enet_packet_destroy (packet);
}
/** Sets the packet compressor the host should use to compress and decompress packets.
@param host host to enable or disable compression for
@param compressor callbacks for for the packet compressor; if NULL, then compression is disabled
*/
void
enet_host_compress (ENetHost * host, const ENetCompressor * compressor)
{
if (host -> compressor.context != NULL && host -> compressor.destroy)
(* host -> compressor.destroy) (host -> compressor.context);
if (compressor)
host -> compressor = * compressor;
else
host -> compressor.context = NULL;
}
/** Limits the maximum allowed channels of future incoming connections.
@param host host to limit
@param channelLimit the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT
*/
void
enet_host_channel_limit (ENetHost * host, size_t channelLimit)
{
if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT;
else
if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT)
channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
host -> channelLimit = channelLimit;
}
/** Adjusts the bandwidth limits of a host.
@param host host to adjust
@param incomingBandwidth new incoming bandwidth
@param outgoingBandwidth new outgoing bandwidth
@remarks the incoming and outgoing bandwidth parameters are identical in function to those
specified in enet_host_create().
*/
void
enet_host_bandwidth_limit (ENetHost * host, enet_uint32 incomingBandwidth, enet_uint32 outgoingBandwidth)
{
host -> incomingBandwidth = incomingBandwidth;
host -> outgoingBandwidth = outgoingBandwidth;
host -> recalculateBandwidthLimits = 1;
}
void
enet_host_bandwidth_throttle (ENetHost * host)
{
enet_uint32 timeCurrent = enet_time_get (),
elapsedTime = timeCurrent - host -> bandwidthThrottleEpoch,
peersRemaining = (enet_uint32) host -> connectedPeers,
dataTotal = ~0,
bandwidth = ~0,
throttle = 0,
bandwidthLimit = 0;
int needsAdjustment = host -> bandwidthLimitedPeers > 0 ? 1 : 0;
ENetPeer * peer;
ENetProtocol command;
if (elapsedTime < ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL)
return;
host -> bandwidthThrottleEpoch = timeCurrent;
if (peersRemaining == 0)
return;
if (host -> outgoingBandwidth != 0)
{
dataTotal = 0;
bandwidth = (host -> outgoingBandwidth * elapsedTime) / 1000;
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
continue;
dataTotal += peer -> outgoingDataTotal;
}
}
while (peersRemaining > 0 && needsAdjustment != 0)
{
needsAdjustment = 0;
if (dataTotal <= bandwidth)
throttle = ENET_PEER_PACKET_THROTTLE_SCALE;
else
throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal;
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
enet_uint32 peerBandwidth;
if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) ||
peer -> incomingBandwidth == 0 ||
peer -> outgoingBandwidthThrottleEpoch == timeCurrent)
continue;
peerBandwidth = (peer -> incomingBandwidth * elapsedTime) / 1000;
if ((throttle * peer -> outgoingDataTotal) / ENET_PEER_PACKET_THROTTLE_SCALE <= peerBandwidth)
continue;
peer -> packetThrottleLimit = (peerBandwidth *
ENET_PEER_PACKET_THROTTLE_SCALE) / peer -> outgoingDataTotal;
if (peer -> packetThrottleLimit == 0)
peer -> packetThrottleLimit = 1;
if (peer -> packetThrottle > peer -> packetThrottleLimit)
peer -> packetThrottle = peer -> packetThrottleLimit;
peer -> outgoingBandwidthThrottleEpoch = timeCurrent;
peer -> incomingDataTotal = 0;
peer -> outgoingDataTotal = 0;
needsAdjustment = 1;
-- peersRemaining;
bandwidth -= peerBandwidth;
dataTotal -= peerBandwidth;
}
}
if (peersRemaining > 0)
{
if (dataTotal <= bandwidth)
throttle = ENET_PEER_PACKET_THROTTLE_SCALE;
else
throttle = (bandwidth * ENET_PEER_PACKET_THROTTLE_SCALE) / dataTotal;
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) ||
peer -> outgoingBandwidthThrottleEpoch == timeCurrent)
continue;
peer -> packetThrottleLimit = throttle;
if (peer -> packetThrottle > peer -> packetThrottleLimit)
peer -> packetThrottle = peer -> packetThrottleLimit;
peer -> incomingDataTotal = 0;
peer -> outgoingDataTotal = 0;
}
}
if (host -> recalculateBandwidthLimits)
{
host -> recalculateBandwidthLimits = 0;
peersRemaining = (enet_uint32) host -> connectedPeers;
bandwidth = host -> incomingBandwidth;
needsAdjustment = 1;
if (bandwidth == 0)
bandwidthLimit = 0;
else
while (peersRemaining > 0 && needsAdjustment != 0)
{
needsAdjustment = 0;
bandwidthLimit = bandwidth / peersRemaining;
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if ((peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER) ||
peer -> incomingBandwidthThrottleEpoch == timeCurrent)
continue;
if (peer -> outgoingBandwidth > 0 &&
peer -> outgoingBandwidth >= bandwidthLimit)
continue;
peer -> incomingBandwidthThrottleEpoch = timeCurrent;
needsAdjustment = 1;
-- peersRemaining;
bandwidth -= peer -> outgoingBandwidth;
}
}
for (peer = host -> peers;
peer < & host -> peers [host -> peerCount];
++ peer)
{
if (peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER)
continue;
command.header.command = ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE;
command.header.channelID = 0xFF;
command.bandwidthLimit.outgoingBandwidth = ENET_HOST_TO_NET_32 (host -> outgoingBandwidth);
if (peer -> incomingBandwidthThrottleEpoch == timeCurrent)
command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (peer -> outgoingBandwidth);
else
command.bandwidthLimit.incomingBandwidth = ENET_HOST_TO_NET_32 (bandwidthLimit);
enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);
}
}
}
/** @} */

View File

@ -0,0 +1,27 @@
/**
@file callbacks.h
@brief ENet callbacks
*/
#ifndef __ENET_CALLBACKS_H__
#define __ENET_CALLBACKS_H__
#include <stdlib.h>
typedef struct _ENetCallbacks
{
void * (ENET_CALLBACK * malloc) (size_t size);
void (ENET_CALLBACK * free) (void * memory);
void (ENET_CALLBACK * no_memory) (void);
} ENetCallbacks;
/** @defgroup callbacks ENet internal callbacks
@{
@ingroup private
*/
extern void * enet_malloc (size_t);
extern void enet_free (void *);
/** @} */
#endif /* __ENET_CALLBACKS_H__ */

View File

@ -0,0 +1,592 @@
/**
@file enet.h
@brief ENet public header file
*/
#ifndef __ENET_ENET_H__
#define __ENET_ENET_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdlib.h>
#ifdef _WIN32
#include "enet/win32.h"
#else
#include "enet/unix.h"
#endif
#include "enet/types.h"
#include "enet/protocol.h"
#include "enet/list.h"
#include "enet/callbacks.h"
#define ENET_VERSION_MAJOR 1
#define ENET_VERSION_MINOR 3
#define ENET_VERSION_PATCH 13
#define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
#define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
#define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
#define ENET_VERSION_GET_PATCH(version) ((version)&0xFF)
#define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH)
typedef enet_uint32 ENetVersion;
struct _ENetHost;
struct _ENetEvent;
struct _ENetPacket;
typedef enum _ENetSocketType
{
ENET_SOCKET_TYPE_STREAM = 1,
ENET_SOCKET_TYPE_DATAGRAM = 2
} ENetSocketType;
typedef enum _ENetSocketWait
{
ENET_SOCKET_WAIT_NONE = 0,
ENET_SOCKET_WAIT_SEND = (1 << 0),
ENET_SOCKET_WAIT_RECEIVE = (1 << 1),
ENET_SOCKET_WAIT_INTERRUPT = (1 << 2)
} ENetSocketWait;
typedef enum _ENetSocketOption
{
ENET_SOCKOPT_NONBLOCK = 1,
ENET_SOCKOPT_BROADCAST = 2,
ENET_SOCKOPT_RCVBUF = 3,
ENET_SOCKOPT_SNDBUF = 4,
ENET_SOCKOPT_REUSEADDR = 5,
ENET_SOCKOPT_RCVTIMEO = 6,
ENET_SOCKOPT_SNDTIMEO = 7,
ENET_SOCKOPT_ERROR = 8,
ENET_SOCKOPT_NODELAY = 9
} ENetSocketOption;
typedef enum _ENetSocketShutdown
{
ENET_SOCKET_SHUTDOWN_READ = 0,
ENET_SOCKET_SHUTDOWN_WRITE = 1,
ENET_SOCKET_SHUTDOWN_READ_WRITE = 2
} ENetSocketShutdown;
#define ENET_HOST_ANY 0
#define ENET_HOST_BROADCAST 0xFFFFFFFFU
#define ENET_PORT_ANY 0
/**
* Portable internet address structure.
*
* The host must be specified in network byte-order, and the port must be in host
* byte-order. The constant ENET_HOST_ANY may be used to specify the default
* server host. The constant ENET_HOST_BROADCAST may be used to specify the
* broadcast address (255.255.255.255). This makes sense for enet_host_connect,
* but not for enet_host_create. Once a server responds to a broadcast, the
* address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
*/
typedef struct _ENetAddress
{
enet_uint32 host;
enet_uint16 port;
} ENetAddress;
/**
* Packet flag bit constants.
*
* The host must be specified in network byte-order, and the port must be in
* host byte-order. The constant ENET_HOST_ANY may be used to specify the
* default server host.
@sa ENetPacket
*/
typedef enum _ENetPacketFlag
{
/** packet must be received by the target peer and resend attempts should be
* made until the packet is delivered */
ENET_PACKET_FLAG_RELIABLE = (1 << 0),
/** packet will not be sequenced with other packets
* not supported for reliable packets
*/
ENET_PACKET_FLAG_UNSEQUENCED = (1 << 1),
/** packet will not allocate data, and user must supply it instead */
ENET_PACKET_FLAG_NO_ALLOCATE = (1 << 2),
/** packet will be fragmented using unreliable (instead of reliable) sends
* if it exceeds the MTU */
ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = (1 << 3),
/** whether the packet has been sent from all queues it has been entered into */
ENET_PACKET_FLAG_SENT = (1<<8)
} ENetPacketFlag;
typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
/**
* ENet packet structure.
*
* An ENet data packet that may be sent to or received from a peer. The shown
* fields should only be read and never modified. The data field contains the
* allocated data for the packet. The dataLength fields specifies the length
* of the allocated data. The flags field is either 0 (specifying no flags),
* or a bitwise-or of any combination of the following flags:
*
* ENET_PACKET_FLAG_RELIABLE - packet must be received by the target peer
* and resend attempts should be made until the packet is delivered
*
* ENET_PACKET_FLAG_UNSEQUENCED - packet will not be sequenced with other packets
* (not supported for reliable packets)
*
* ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
@sa ENetPacketFlag
*/
typedef struct _ENetPacket
{
size_t referenceCount; /**< internal use only */
enet_uint32 flags; /**< bitwise-or of ENetPacketFlag constants */
enet_uint8 * data; /**< allocated data for packet */
size_t dataLength; /**< length of data */
ENetPacketFreeCallback freeCallback; /**< function to be called when the packet is no longer in use */
void * userData; /**< application private data, may be freely modified */
} ENetPacket;
typedef struct _ENetAcknowledgement
{
ENetListNode acknowledgementList;
enet_uint32 sentTime;
ENetProtocol command;
} ENetAcknowledgement;
typedef struct _ENetOutgoingCommand
{
ENetListNode outgoingCommandList;
enet_uint16 reliableSequenceNumber;
enet_uint16 unreliableSequenceNumber;
enet_uint32 sentTime;
enet_uint32 roundTripTimeout;
enet_uint32 roundTripTimeoutLimit;
enet_uint32 fragmentOffset;
enet_uint16 fragmentLength;
enet_uint16 sendAttempts;
ENetProtocol command;
ENetPacket * packet;
} ENetOutgoingCommand;
typedef struct _ENetIncomingCommand
{
ENetListNode incomingCommandList;
enet_uint16 reliableSequenceNumber;
enet_uint16 unreliableSequenceNumber;
ENetProtocol command;
enet_uint32 fragmentCount;
enet_uint32 fragmentsRemaining;
enet_uint32 * fragments;
ENetPacket * packet;
} ENetIncomingCommand;
typedef enum _ENetPeerState
{
ENET_PEER_STATE_DISCONNECTED = 0,
ENET_PEER_STATE_CONNECTING = 1,
ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
ENET_PEER_STATE_CONNECTION_PENDING = 3,
ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4,
ENET_PEER_STATE_CONNECTED = 5,
ENET_PEER_STATE_DISCONNECT_LATER = 6,
ENET_PEER_STATE_DISCONNECTING = 7,
ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8,
ENET_PEER_STATE_ZOMBIE = 9
} ENetPeerState;
#ifndef ENET_BUFFER_MAXIMUM
#define ENET_BUFFER_MAXIMUM (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)
#endif
enum
{
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024,
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024,
ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000,
ENET_HOST_DEFAULT_MTU = 1400,
ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE = 32 * 1024 * 1024,
ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500,
ENET_PEER_DEFAULT_PACKET_THROTTLE = 32,
ENET_PEER_PACKET_THROTTLE_SCALE = 32,
ENET_PEER_PACKET_THROTTLE_COUNTER = 7,
ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2,
ENET_PEER_PACKET_THROTTLE_DECELERATION = 2,
ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000,
ENET_PEER_PACKET_LOSS_SCALE = (1 << 16),
ENET_PEER_PACKET_LOSS_INTERVAL = 10000,
ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024,
ENET_PEER_TIMEOUT_LIMIT = 32,
ENET_PEER_TIMEOUT_MINIMUM = 5000,
ENET_PEER_TIMEOUT_MAXIMUM = 30000,
ENET_PEER_PING_INTERVAL = 500,
ENET_PEER_UNSEQUENCED_WINDOWS = 64,
ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024,
ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32,
ENET_PEER_RELIABLE_WINDOWS = 16,
ENET_PEER_RELIABLE_WINDOW_SIZE = 0x1000,
ENET_PEER_FREE_RELIABLE_WINDOWS = 8
};
typedef struct _ENetChannel
{
enet_uint16 outgoingReliableSequenceNumber;
enet_uint16 outgoingUnreliableSequenceNumber;
enet_uint16 usedReliableWindows;
enet_uint16 reliableWindows [ENET_PEER_RELIABLE_WINDOWS];
enet_uint16 incomingReliableSequenceNumber;
enet_uint16 incomingUnreliableSequenceNumber;
ENetList incomingReliableCommands;
ENetList incomingUnreliableCommands;
} ENetChannel;
/**
* An ENet peer which data packets may be sent or received from.
*
* No fields should be modified unless otherwise specified.
*/
typedef struct _ENetPeer
{
ENetListNode dispatchList;
struct _ENetHost * host;
enet_uint16 outgoingPeerID;
enet_uint16 incomingPeerID;
enet_uint32 connectID;
enet_uint8 outgoingSessionID;
enet_uint8 incomingSessionID;
ENetAddress address; /**< Internet address of the peer */
void * data; /**< Application private data, may be freely modified */
ENetPeerState state;
ENetChannel * channels;
size_t channelCount; /**< Number of channels allocated for communication with peer */
enet_uint32 incomingBandwidth; /**< Downstream bandwidth of the client in bytes/second */
enet_uint32 outgoingBandwidth; /**< Upstream bandwidth of the client in bytes/second */
enet_uint32 incomingBandwidthThrottleEpoch;
enet_uint32 outgoingBandwidthThrottleEpoch;
enet_uint32 incomingDataTotal;
enet_uint32 outgoingDataTotal;
enet_uint32 lastSendTime;
enet_uint32 lastReceiveTime;
enet_uint32 nextTimeout;
enet_uint32 earliestTimeout;
enet_uint32 packetLossEpoch;
enet_uint32 packetsSent;
enet_uint32 packetsLost;
enet_uint32 packetLoss; /**< mean packet loss of reliable packets as a ratio with respect to the constant ENET_PEER_PACKET_LOSS_SCALE */
enet_uint32 packetLossVariance;
enet_uint32 packetThrottle;
enet_uint32 packetThrottleLimit;
enet_uint32 packetThrottleCounter;
enet_uint32 packetThrottleEpoch;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
enet_uint32 packetThrottleInterval;
enet_uint32 pingInterval;
enet_uint32 timeoutLimit;
enet_uint32 timeoutMinimum;
enet_uint32 timeoutMaximum;
enet_uint32 lastRoundTripTime;
enet_uint32 lowestRoundTripTime;
enet_uint32 lastRoundTripTimeVariance;
enet_uint32 highestRoundTripTimeVariance;
enet_uint32 roundTripTime; /**< mean round trip time (RTT), in milliseconds, between sending a reliable packet and receiving its acknowledgement */
enet_uint32 roundTripTimeVariance;
enet_uint32 mtu;
enet_uint32 windowSize;
enet_uint32 reliableDataInTransit;
enet_uint16 outgoingReliableSequenceNumber;
ENetList acknowledgements;
ENetList sentReliableCommands;
ENetList sentUnreliableCommands;
ENetList outgoingReliableCommands;
ENetList outgoingUnreliableCommands;
ENetList dispatchedCommands;
int needsDispatch;
enet_uint16 incomingUnsequencedGroup;
enet_uint16 outgoingUnsequencedGroup;
enet_uint32 unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32];
enet_uint32 eventData;
size_t totalWaitingData;
} ENetPeer;
/** An ENet packet compressor for compressing UDP packets before socket sends or receives.
*/
typedef struct _ENetCompressor
{
/** Context data for the compressor. Must be non-NULL. */
void * context;
/** Compresses from inBuffers[0:inBufferCount-1], containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
size_t (ENET_CALLBACK * compress) (void * context, const ENetBuffer * inBuffers, size_t inBufferCount, size_t inLimit, enet_uint8 * outData, size_t outLimit);
/** Decompresses from inData, containing inLimit bytes, to outData, outputting at most outLimit bytes. Should return 0 on failure. */
size_t (ENET_CALLBACK * decompress) (void * context, const enet_uint8 * inData, size_t inLimit, enet_uint8 * outData, size_t outLimit);
/** Destroys the context when compression is disabled or the host is destroyed. May be NULL. */
void (ENET_CALLBACK * destroy) (void * context);
} ENetCompressor;
/** Callback that computes the checksum of the data held in buffers[0:bufferCount-1] */
typedef enet_uint32 (ENET_CALLBACK * ENetChecksumCallback) (const ENetBuffer * buffers, size_t bufferCount);
/** Callback for intercepting received raw UDP packets. Should return 1 to intercept, 0 to ignore, or -1 to propagate an error. */
typedef int (ENET_CALLBACK * ENetInterceptCallback) (struct _ENetHost * host, struct _ENetEvent * event);
/** An ENet host for communicating with peers.
*
* No fields should be modified unless otherwise stated.
@sa enet_host_create()
@sa enet_host_destroy()
@sa enet_host_connect()
@sa enet_host_service()
@sa enet_host_flush()
@sa enet_host_broadcast()
@sa enet_host_compress()
@sa enet_host_compress_with_range_coder()
@sa enet_host_channel_limit()
@sa enet_host_bandwidth_limit()
@sa enet_host_bandwidth_throttle()
*/
typedef struct _ENetHost
{
ENetSocket socket;
ENetAddress address; /**< Internet address of the host */
enet_uint32 incomingBandwidth; /**< downstream bandwidth of the host */
enet_uint32 outgoingBandwidth; /**< upstream bandwidth of the host */
enet_uint32 bandwidthThrottleEpoch;
enet_uint32 mtu;
enet_uint32 randomSeed;
int recalculateBandwidthLimits;
ENetPeer * peers; /**< array of peers allocated for this host */
size_t peerCount; /**< number of peers allocated for this host */
size_t channelLimit; /**< maximum number of channels allowed for connected peers */
enet_uint32 serviceTime;
ENetList dispatchQueue;
int continueSending;
size_t packetSize;
enet_uint16 headerFlags;
ENetProtocol commands [ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS];
size_t commandCount;
ENetBuffer buffers [ENET_BUFFER_MAXIMUM];
size_t bufferCount;
ENetChecksumCallback checksum; /**< callback the user can set to enable packet checksums for this host */
ENetCompressor compressor;
enet_uint8 packetData [2][ENET_PROTOCOL_MAXIMUM_MTU];
ENetAddress receivedAddress;
enet_uint8 * receivedData;
size_t receivedDataLength;
enet_uint32 totalSentData; /**< total data sent, user should reset to 0 as needed to prevent overflow */
enet_uint32 totalSentPackets; /**< total UDP packets sent, user should reset to 0 as needed to prevent overflow */
enet_uint32 totalReceivedData; /**< total data received, user should reset to 0 as needed to prevent overflow */
enet_uint32 totalReceivedPackets; /**< total UDP packets received, user should reset to 0 as needed to prevent overflow */
ENetInterceptCallback intercept; /**< callback the user can set to intercept received raw UDP packets */
size_t connectedPeers;
size_t bandwidthLimitedPeers;
size_t duplicatePeers; /**< optional number of allowed peers from duplicate IPs, defaults to ENET_PROTOCOL_MAXIMUM_PEER_ID */
size_t maximumPacketSize; /**< the maximum allowable packet size that may be sent or received on a peer */
size_t maximumWaitingData; /**< the maximum aggregate amount of buffer space a peer may use waiting for packets to be delivered */
} ENetHost;
/**
* An ENet event type, as specified in @ref ENetEvent.
*/
typedef enum _ENetEventType
{
/** no event occurred within the specified time limit */
ENET_EVENT_TYPE_NONE = 0,
/** a connection request initiated by enet_host_connect has completed.
* The peer field contains the peer which successfully connected.
*/
ENET_EVENT_TYPE_CONNECT = 1,
/** a peer has disconnected. This event is generated on a successful
* completion of a disconnect initiated by enet_pper_disconnect, if
* a peer has timed out, or if a connection request intialized by
* enet_host_connect has timed out. The peer field contains the peer
* which disconnected. The data field contains user supplied data
* describing the disconnection, or 0, if none is available.
*/
ENET_EVENT_TYPE_DISCONNECT = 2,
/** a packet has been received from a peer. The peer field specifies the
* peer which sent the packet. The channelID field specifies the channel
* number upon which the packet was received. The packet field contains
* the packet that was received; this packet must be destroyed with
* enet_packet_destroy after use.
*/
ENET_EVENT_TYPE_RECEIVE = 3
} ENetEventType;
/**
* An ENet event as returned by enet_host_service().
@sa enet_host_service
*/
typedef struct _ENetEvent
{
ENetEventType type; /**< type of the event */
ENetPeer * peer; /**< peer that generated a connect, disconnect or receive event */
enet_uint8 channelID; /**< channel on the peer that generated the event, if appropriate */
enet_uint32 data; /**< data associated with the event, if appropriate */
ENetPacket * packet; /**< packet associated with the event, if appropriate */
} ENetEvent;
/** @defgroup global ENet global functions
@{
*/
/**
Initializes ENet globally. Must be called prior to using any functions in
ENet.
@returns 0 on success, < 0 on failure
*/
ENET_API int enet_initialize (void);
/**
Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.
@param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use
@param inits user-overridden callbacks where any NULL callbacks will use ENet's defaults
@returns 0 on success, < 0 on failure
*/
ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);
/**
Shuts down ENet globally. Should be called when a program that has
initialized ENet exits.
*/
ENET_API void enet_deinitialize (void);
/**
Gives the linked version of the ENet library.
@returns the version number
*/
ENET_API ENetVersion enet_linked_version (void);
/** @} */
/** @defgroup private ENet private implementation functions */
/**
Returns the wall-time in milliseconds. Its initial value is unspecified
unless otherwise set.
*/
ENET_API enet_uint32 enet_time_get (void);
/**
Sets the current wall-time in milliseconds.
*/
ENET_API void enet_time_set (enet_uint32);
/** @defgroup socket ENet socket functions
@{
*/
ENET_API ENetSocket enet_socket_create (ENetSocketType);
ENET_API int enet_socket_bind (ENetSocket, const ENetAddress *);
ENET_API int enet_socket_get_address (ENetSocket, ENetAddress *);
ENET_API int enet_socket_listen (ENetSocket, int);
ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *);
ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *);
ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t);
ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t);
ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);
ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int);
ENET_API int enet_socket_get_option (ENetSocket, ENetSocketOption, int *);
ENET_API int enet_socket_shutdown (ENetSocket, ENetSocketShutdown);
ENET_API void enet_socket_destroy (ENetSocket);
ENET_API int enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSocketSet *, enet_uint32);
/** @} */
/** @defgroup Address ENet address functions
@{
*/
/** Attempts to resolve the host named by the parameter hostName and sets
the host field in the address parameter if successful.
@param address destination to store resolved address
@param hostName host name to lookup
@retval 0 on success
@retval < 0 on failure
@returns the address of the given hostName in address on success
*/
ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
/** Gives the printable form of the IP address specified in the address parameter.
@param address address printed
@param hostName destination for name, must not be NULL
@param nameLength maximum length of hostName.
@returns the null-terminated name of the host in hostName on success
@retval 0 on success
@retval < 0 on failure
*/
ENET_API int enet_address_get_host_ip (const ENetAddress * address, char * hostName, size_t nameLength);
/** Attempts to do a reverse lookup of the host field in the address parameter.
@param address address used for reverse lookup
@param hostName destination for name, must not be NULL
@param nameLength maximum length of hostName.
@returns the null-terminated name of the host in hostName on success
@retval 0 on success
@retval < 0 on failure
*/
ENET_API int enet_address_get_host (const ENetAddress * address, char * hostName, size_t nameLength);
/** @} */
ENET_API ENetPacket * enet_packet_create (const void *, size_t, enet_uint32);
ENET_API void enet_packet_destroy (ENetPacket *);
ENET_API int enet_packet_resize (ENetPacket *, size_t);
ENET_API enet_uint32 enet_crc32 (const ENetBuffer *, size_t);
ENET_API ENetHost * enet_host_create (const ENetAddress *, size_t, size_t, enet_uint32, enet_uint32);
ENET_API void enet_host_destroy (ENetHost *);
ENET_API ENetPeer * enet_host_connect (ENetHost *, const ENetAddress *, size_t, enet_uint32);
ENET_API int enet_host_check_events (ENetHost *, ENetEvent *);
ENET_API int enet_host_service (ENetHost *, ENetEvent *, enet_uint32);
ENET_API void enet_host_flush (ENetHost *);
ENET_API void enet_host_broadcast (ENetHost *, enet_uint8, ENetPacket *);
ENET_API void enet_host_compress (ENetHost *, const ENetCompressor *);
ENET_API int enet_host_compress_with_range_coder (ENetHost * host);
ENET_API void enet_host_channel_limit (ENetHost *, size_t);
ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
extern void enet_host_bandwidth_throttle (ENetHost *);
extern enet_uint32 enet_host_random_seed (void);
ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
ENET_API void enet_peer_ping (ENetPeer *);
ENET_API void enet_peer_ping_interval (ENetPeer *, enet_uint32);
ENET_API void enet_peer_timeout (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
ENET_API void enet_peer_reset (ENetPeer *);
ENET_API void enet_peer_disconnect (ENetPeer *, enet_uint32);
ENET_API void enet_peer_disconnect_now (ENetPeer *, enet_uint32);
ENET_API void enet_peer_disconnect_later (ENetPeer *, enet_uint32);
ENET_API void enet_peer_throttle_configure (ENetPeer *, enet_uint32, enet_uint32, enet_uint32);
extern int enet_peer_throttle (ENetPeer *, enet_uint32);
extern void enet_peer_reset_queues (ENetPeer *);
extern void enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, const void *, size_t, enet_uint32, enet_uint32);
extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
extern void enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
extern void enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
extern void enet_peer_on_connect (ENetPeer *);
extern void enet_peer_on_disconnect (ENetPeer *);
ENET_API void * enet_range_coder_create (void);
ENET_API void enet_range_coder_destroy (void *);
ENET_API size_t enet_range_coder_compress (void *, const ENetBuffer *, size_t, size_t, enet_uint8 *, size_t);
ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, enet_uint8 *, size_t);
extern size_t enet_protocol_command_size (enet_uint8);
#ifdef __cplusplus
}
#endif
#endif /* __ENET_ENET_H__ */

View File

@ -0,0 +1,43 @@
/**
@file list.h
@brief ENet list management
*/
#ifndef __ENET_LIST_H__
#define __ENET_LIST_H__
#include <stdlib.h>
typedef struct _ENetListNode
{
struct _ENetListNode * next;
struct _ENetListNode * previous;
} ENetListNode;
typedef ENetListNode * ENetListIterator;
typedef struct _ENetList
{
ENetListNode sentinel;
} ENetList;
extern void enet_list_clear (ENetList *);
extern ENetListIterator enet_list_insert (ENetListIterator, void *);
extern void * enet_list_remove (ENetListIterator);
extern ENetListIterator enet_list_move (ENetListIterator, void *, void *);
extern size_t enet_list_size (ENetList *);
#define enet_list_begin(list) ((list) -> sentinel.next)
#define enet_list_end(list) (& (list) -> sentinel)
#define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list))
#define enet_list_next(iterator) ((iterator) -> next)
#define enet_list_previous(iterator) ((iterator) -> previous)
#define enet_list_front(list) ((void *) (list) -> sentinel.next)
#define enet_list_back(list) ((void *) (list) -> sentinel.previous)
#endif /* __ENET_LIST_H__ */

View File

@ -0,0 +1,198 @@
/**
@file protocol.h
@brief ENet protocol
*/
#ifndef __ENET_PROTOCOL_H__
#define __ENET_PROTOCOL_H__
#include "enet/types.h"
enum
{
ENET_PROTOCOL_MINIMUM_MTU = 576,
ENET_PROTOCOL_MAXIMUM_MTU = 4096,
ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32,
ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096,
ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536,
ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1,
ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255,
ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF,
ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024
};
typedef enum _ENetProtocolCommand
{
ENET_PROTOCOL_COMMAND_NONE = 0,
ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
ENET_PROTOCOL_COMMAND_CONNECT = 2,
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
ENET_PROTOCOL_COMMAND_DISCONNECT = 4,
ENET_PROTOCOL_COMMAND_PING = 5,
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
ENET_PROTOCOL_COMMAND_COUNT = 13,
ENET_PROTOCOL_COMMAND_MASK = 0x0F
} ENetProtocolCommand;
typedef enum _ENetProtocolFlag
{
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7),
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6),
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14),
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15),
ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME,
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12),
ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12
} ENetProtocolFlag;
#ifdef _MSC_VER
#pragma pack(push, 1)
#define ENET_PACKED
#elif defined(__GNUC__) || defined(__clang__)
#define ENET_PACKED __attribute__ ((packed))
#else
#define ENET_PACKED
#endif
typedef struct _ENetProtocolHeader
{
enet_uint16 peerID;
enet_uint16 sentTime;
} ENET_PACKED ENetProtocolHeader;
typedef struct _ENetProtocolCommandHeader
{
enet_uint8 command;
enet_uint8 channelID;
enet_uint16 reliableSequenceNumber;
} ENET_PACKED ENetProtocolCommandHeader;
typedef struct _ENetProtocolAcknowledge
{
ENetProtocolCommandHeader header;
enet_uint16 receivedReliableSequenceNumber;
enet_uint16 receivedSentTime;
} ENET_PACKED ENetProtocolAcknowledge;
typedef struct _ENetProtocolConnect
{
ENetProtocolCommandHeader header;
enet_uint16 outgoingPeerID;
enet_uint8 incomingSessionID;
enet_uint8 outgoingSessionID;
enet_uint32 mtu;
enet_uint32 windowSize;
enet_uint32 channelCount;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
enet_uint32 connectID;
enet_uint32 data;
} ENET_PACKED ENetProtocolConnect;
typedef struct _ENetProtocolVerifyConnect
{
ENetProtocolCommandHeader header;
enet_uint16 outgoingPeerID;
enet_uint8 incomingSessionID;
enet_uint8 outgoingSessionID;
enet_uint32 mtu;
enet_uint32 windowSize;
enet_uint32 channelCount;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
enet_uint32 connectID;
} ENET_PACKED ENetProtocolVerifyConnect;
typedef struct _ENetProtocolBandwidthLimit
{
ENetProtocolCommandHeader header;
enet_uint32 incomingBandwidth;
enet_uint32 outgoingBandwidth;
} ENET_PACKED ENetProtocolBandwidthLimit;
typedef struct _ENetProtocolThrottleConfigure
{
ENetProtocolCommandHeader header;
enet_uint32 packetThrottleInterval;
enet_uint32 packetThrottleAcceleration;
enet_uint32 packetThrottleDeceleration;
} ENET_PACKED ENetProtocolThrottleConfigure;
typedef struct _ENetProtocolDisconnect
{
ENetProtocolCommandHeader header;
enet_uint32 data;
} ENET_PACKED ENetProtocolDisconnect;
typedef struct _ENetProtocolPing
{
ENetProtocolCommandHeader header;
} ENET_PACKED ENetProtocolPing;
typedef struct _ENetProtocolSendReliable
{
ENetProtocolCommandHeader header;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendReliable;
typedef struct _ENetProtocolSendUnreliable
{
ENetProtocolCommandHeader header;
enet_uint16 unreliableSequenceNumber;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendUnreliable;
typedef struct _ENetProtocolSendUnsequenced
{
ENetProtocolCommandHeader header;
enet_uint16 unsequencedGroup;
enet_uint16 dataLength;
} ENET_PACKED ENetProtocolSendUnsequenced;
typedef struct _ENetProtocolSendFragment
{
ENetProtocolCommandHeader header;
enet_uint16 startSequenceNumber;
enet_uint16 dataLength;
enet_uint32 fragmentCount;
enet_uint32 fragmentNumber;
enet_uint32 totalLength;
enet_uint32 fragmentOffset;
} ENET_PACKED ENetProtocolSendFragment;
typedef union _ENetProtocol
{
ENetProtocolCommandHeader header;
ENetProtocolAcknowledge acknowledge;
ENetProtocolConnect connect;
ENetProtocolVerifyConnect verifyConnect;
ENetProtocolDisconnect disconnect;
ENetProtocolPing ping;
ENetProtocolSendReliable sendReliable;
ENetProtocolSendUnreliable sendUnreliable;
ENetProtocolSendUnsequenced sendUnsequenced;
ENetProtocolSendFragment sendFragment;
ENetProtocolBandwidthLimit bandwidthLimit;
ENetProtocolThrottleConfigure throttleConfigure;
} ENET_PACKED ENetProtocol;
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#endif /* __ENET_PROTOCOL_H__ */

View File

@ -0,0 +1,18 @@
/**
@file time.h
@brief ENet time constants and macros
*/
#ifndef __ENET_TIME_H__
#define __ENET_TIME_H__
#define ENET_TIME_OVERFLOW 86400000
#define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW)
#define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW)
#define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b))
#define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b))
#define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b))
#endif /* __ENET_TIME_H__ */

View File

@ -0,0 +1,13 @@
/**
@file types.h
@brief type definitions for ENet
*/
#ifndef __ENET_TYPES_H__
#define __ENET_TYPES_H__
typedef unsigned char enet_uint8; /**< unsigned 8-bit type */
typedef unsigned short enet_uint16; /**< unsigned 16-bit type */
typedef unsigned int enet_uint32; /**< unsigned 32-bit type */
#endif /* __ENET_TYPES_H__ */

View File

@ -0,0 +1,47 @@
/**
@file unix.h
@brief ENet Unix header
*/
#ifndef __ENET_UNIX_H__
#define __ENET_UNIX_H__
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#ifdef MSG_MAXIOVLEN
#define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN
#endif
typedef int ENetSocket;
#define ENET_SOCKET_NULL -1
#define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */
#define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */
#define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
#define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
typedef struct
{
void * data;
size_t dataLength;
} ENetBuffer;
#define ENET_CALLBACK
#define ENET_API extern
typedef fd_set ENetSocketSet;
#define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
#define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset))
#define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
#endif /* __ENET_UNIX_H__ */

View File

@ -0,0 +1,12 @@
/**
@file utility.h
@brief ENet utility header
*/
#ifndef __ENET_UTILITY_H__
#define __ENET_UTILITY_H__
#define ENET_MAX(x, y) ((x) > (y) ? (x) : (y))
#define ENET_MIN(x, y) ((x) < (y) ? (x) : (y))
#endif /* __ENET_UTILITY_H__ */

View File

@ -0,0 +1,57 @@
/**
@file win32.h
@brief ENet Win32 header
*/
#ifndef __ENET_WIN32_H__
#define __ENET_WIN32_H__
#ifdef _MSC_VER
#ifdef ENET_BUILDING_LIB
#pragma warning (disable: 4267) // size_t to int conversion
#pragma warning (disable: 4244) // 64bit to 32bit int
#pragma warning (disable: 4018) // signed/unsigned mismatch
#pragma warning (disable: 4146) // unary minus operator applied to unsigned type
#endif
#endif
#include <stdlib.h>
#include <winsock2.h>
typedef SOCKET ENetSocket;
#define ENET_SOCKET_NULL INVALID_SOCKET
#define ENET_HOST_TO_NET_16(value) (htons (value))
#define ENET_HOST_TO_NET_32(value) (htonl (value))
#define ENET_NET_TO_HOST_16(value) (ntohs (value))
#define ENET_NET_TO_HOST_32(value) (ntohl (value))
typedef struct
{
size_t dataLength;
void * data;
} ENetBuffer;
#define ENET_CALLBACK __cdecl
#ifdef ENET_DLL
#ifdef ENET_BUILDING_LIB
#define ENET_API __declspec( dllexport )
#else
#define ENET_API __declspec( dllimport )
#endif /* ENET_BUILDING_LIB */
#else /* !ENET_DLL */
#define ENET_API extern
#endif /* ENET_DLL */
typedef fd_set ENetSocketSet;
#define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
#define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset))
#define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
#endif /* __ENET_WIN32_H__ */

View File

@ -0,0 +1,10 @@
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libenet
Description: Low-latency UDP networking library supporting optional reliability
Version: 1.3.9
Cflags: -I${includedir}
Libs: -L${libdir} -lenet

75
src/enet/list.c 100644
View File

@ -0,0 +1,75 @@
/**
@file list.c
@brief ENet linked list functions
*/
#define ENET_BUILDING_LIB 1
#include "enet/enet.h"
/**
@defgroup list ENet linked list utility functions
@ingroup private
@{
*/
void
enet_list_clear (ENetList * list)
{
list -> sentinel.next = & list -> sentinel;
list -> sentinel.previous = & list -> sentinel;
}
ENetListIterator
enet_list_insert (ENetListIterator position, void * data)
{
ENetListIterator result = (ENetListIterator) data;
result -> previous = position -> previous;
result -> next = position;
result -> previous -> next = result;
position -> previous = result;
return result;
}
void *
enet_list_remove (ENetListIterator position)
{
position -> previous -> next = position -> next;
position -> next -> previous = position -> previous;
return position;
}
ENetListIterator
enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast)
{
ENetListIterator first = (ENetListIterator) dataFirst,
last = (ENetListIterator) dataLast;
first -> previous -> next = last -> next;
last -> next -> previous = first -> previous;
first -> previous = position -> previous;
last -> next = position;
first -> previous -> next = first;
position -> previous = last;
return first;
}
size_t
enet_list_size (ENetList * list)
{
size_t size = 0;
ENetListIterator position;
for (position = enet_list_begin (list);
position != enet_list_end (list);
position = enet_list_next (position))
++ size;
return size;
}
/** @} */

View File

@ -0,0 +1,62 @@
add_languages('c')
libenet_src = [
'callbacks.c',
'compress.c',
'host.c',
'list.c',
'packet.c',
'peer.c',
'protocol.c',
'unix.c',
'win32.c'
]
cc = meson.get_compiler('c')
libenet_cflags = []
if target_machine.system() != 'windows'
if cc.has_function('getaddrinfo', prefix: '#include <netdb.h>')
libenet_cflags += ['-DHAS_GETADDRINFO']
endif
if cc.has_function('getnameinfo', prefix: '#include <netdb.h>')
libenet_cflags += ['-DHAS_GETNAMEINFO']
endif
if cc.has_function('gethostbyaddr_r', prefix: '#include <netdb.h>')
libenet_cflags += ['-DHAS_GETHOSTBYADDR_R']
endif
if cc.has_function('gethostbyname_r', prefix: '#include <netdb.h>')
libenet_cflags += ['-DHAS_GETHOSTBYNAME_R']
endif
if cc.has_function('poll', prefix: '#include <poll.h>')
libenet_cflags += ['-DHAS_POLL']
endif
if cc.has_function('fcntl', prefix: '#include <fcntl.h>')
libenet_cflags += ['-DHAS_FCNTL']
endif
if cc.has_function('inet_pton', prefix: '#include <arpa/inet.h>')
libenet_cflags += ['-DHAS_INET_PTON']
endif
if cc.has_function('inet_ntop', prefix: '#include <arpa/inet.h>')
libenet_cflags += ['-DHAS_INET_NTOP']
endif
if cc.has_member('struct msghdr', 'msg_flags', prefix: '#include <sys/socket.h>')
libenet_cflags += ['-DHAS_MSGHDR_FLAGS']
endif
if cc.has_type('socklen_t', prefix: '#include <sys/socket.h>')
libenet_cflags += ['-DHAS_SOCKLEN_T']
endif
endif
libenet_lib = static_library('enet',
libenet_src,
include_directories: include_directories('include'),
c_args: libenet_cflags,
install: false
)
libenet = declare_dependency(
include_directories: include_directories('include'),
link_with: libenet_lib
)

Some files were not shown because too many files have changed in this diff Show More