Compare commits
10 Commits
82fcbb6fed
...
e43391caa3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e43391caa3 | ||
![]() |
eb17923448 | ||
![]() |
9cd4aee87a | ||
![]() |
310889bd2c | ||
![]() |
0629b042ad | ||
![]() |
3c780c7290 | ||
![]() |
943a8cd1d9 | ||
![]() |
2c1ee84791 | ||
![]() |
8990e415d3 | ||
![]() |
85d5f4f019 |
@ -13,7 +13,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
- run: mkdir build build/k3 bin bin/assets
|
- run: mkdir build build/k3 build/k3/compr bin bin/assets
|
||||||
- run: CC="i686-w64-mingw32-gcc" CFLAGS="-I/usr/i686-w64-mingw32/include -I/usr/i686-w64-mingw32/include/lua5.3 -L/usr/i686-w64-mingw32/lib -Wno-error" make -B
|
- run: CC="i686-w64-mingw32-gcc" CFLAGS="-I/usr/i686-w64-mingw32/include -I/usr/i686-w64-mingw32/include/lua5.3 -L/usr/i686-w64-mingw32/lib -Wno-error" make -B
|
||||||
- run: CC="i686-linux-gnu-gcc" CFLAGS="-I/usr/i686-linux-gnu/include -I/usr/i686-linux-gnu/include/lua5.3 -L/usr/i686-linux-gnu/lib -Wno-error" make -B
|
- run: CC="i686-linux-gnu-gcc" CFLAGS="-I/usr/i686-linux-gnu/include -I/usr/i686-linux-gnu/include/lua5.3 -L/usr/i686-linux-gnu/lib -Wno-error" make -B
|
||||||
- run: cp /usr/lib/gcc/i686-w64-mingw32/10-win32/libgcc_s_dw2-1.dll /usr/lib/gcc/i686-w64-mingw32/10-win32/libstdc++-6.dll /usr/i686-w64-mingw32/lib/libportaudio-2.dll /usr/i686-w64-mingw32/lib/libwinpthread-1.dll bin/
|
- run: cp /usr/lib/gcc/i686-w64-mingw32/10-win32/libgcc_s_dw2-1.dll /usr/lib/gcc/i686-w64-mingw32/10-win32/libstdc++-6.dll /usr/i686-w64-mingw32/lib/libportaudio-2.dll /usr/i686-w64-mingw32/lib/libwinpthread-1.dll bin/
|
||||||
|
18
Makefile
18
Makefile
@ -1,24 +1,26 @@
|
|||||||
k4_SRCS := $(wildcard src/*.c)
|
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
||||||
k4_HDRS := $(wildcard src/*.h)
|
|
||||||
|
k4_SRCS := $(call rwildcard,src,*.c)
|
||||||
|
k4_HDRS := $(call rwildcard,src,*.h)
|
||||||
k4_OBJS := $(patsubst src/%.c, build/%.o, $(k4_SRCS))
|
k4_OBJS := $(patsubst src/%.c, build/%.o, $(k4_SRCS))
|
||||||
k4_DEPS := $(patsubst src/%.c, build/%.d, $(k4_SRCS))
|
k4_DEPS := $(patsubst src/%.c, build/%.d, $(k4_SRCS))
|
||||||
|
|
||||||
k3_SRCS = $(wildcard k3/src/*.c)
|
k3_SRCS := $(call rwildcard,k3/src,*.c)
|
||||||
k3_HDRS = $(wildcard k3/src/*.h)
|
k3_HDRS := $(call rwildcard,k3/src,*.h)
|
||||||
k3_OBJS := $(patsubst k3/src/%.c, build/k3/%.o, $(k3_SRCS))
|
k3_OBJS := $(patsubst k3/src/%.c, build/k3/%.o, $(k3_SRCS))
|
||||||
k3_DEPS := $(patsubst k3/src/%.c, build/k3/%.d, $(k3_SRCS))
|
k3_DEPS := $(patsubst k3/src/%.c, build/k3/%.d, $(k3_SRCS))
|
||||||
|
|
||||||
CFLAGS := $(CFLAGS) -Ik3/src
|
CFLAGS := $(CFLAGS) -Ik3/src -O2 -fopenmp
|
||||||
|
|
||||||
ifneq (,$(findstring mingw,$(CC)))
|
ifneq (,$(findstring mingw,$(CC)))
|
||||||
CFLAGS := -static-libgcc -static-libstdc++ -std=gnu99 -march=pentium4 -D_WIN32_WINNT=0x600 -DENET_FEATURE_ADDRESS_MAPPING -fno-pic -no-pie -fms-extensions -fno-pie -O0 -g -gdwarf-2 -Isrc $(CFLAGS)
|
CFLAGS := -static-libgcc -static-libstdc++ -std=gnu99 -march=pentium4 -D_WIN32_WINNT=0x600 -DENET_FEATURE_ADDRESS_MAPPING -fno-pic -no-pie -fms-extensions -fno-pie -Isrc $(CFLAGS)
|
||||||
LIBS := -l:libglfw3.a -lopengl32 -pthread -lm -l:libode.a -l:libvorbisfile.a -l:libvorbis.a -l:libogg.a -lportaudio -lgdi32 -lws2_32 -lwinmm -lstdc++ -lole32 -lsetupapi -lhid -l:liblua5.3.a $(LIBS)
|
LIBS := -l:libglfw3.a -lopengl32 -pthread -lm -l:libode.a -l:libvorbisfile.a -l:libvorbis.a -l:libogg.a -lportaudio -lgdi32 -lws2_32 -lwinmm -lstdc++ -lole32 -lsetupapi -lhid -l:liblua5.3.a $(LIBS)
|
||||||
else
|
else
|
||||||
CFLAGS := -march=opteron $(SAN) -std=gnu99 -DENET_FEATURE_ADDRESS_MAPPING -fms-extensions -fno-pic -no-pie -fno-pie -O0 -g -Isrc $(CFLAGS)
|
CFLAGS := -march=opteron $(SAN) -std=gnu99 -DENET_FEATURE_ADDRESS_MAPPING -fms-extensions -fno-pic -no-pie -fno-pie -Isrc $(CFLAGS)
|
||||||
LIBS := -lglfw3 -pthread -ldl -lm -lode -lstdc++ -llua5.3 -lvorbis -lvorbisfile -lportaudio $(LIBS)
|
LIBS := -lglfw3 -pthread -ldl -lm -lode -lstdc++ -llua5.3 -lvorbis -lvorbisfile -lportaudio $(LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := $(CFLAGS) -DLOCALHOST_ONLY -Dk3_IRREGULAR_SHADOWS
|
CFLAGS := $(CFLAGS) -DLOCALHOST_ONLY
|
||||||
|
|
||||||
build/k3/%.o: k3/src/%.c
|
build/k3/%.o: k3/src/%.c
|
||||||
$(CC) $(CFLAGS) -MMD -o $@ -c $<
|
$(CC) $(CFLAGS) -MMD -o $@ -c $<
|
||||||
|
@ -216,7 +216,7 @@ for input_filename in sys.argv[1:]:
|
|||||||
|
|
||||||
k3result["meshes"].append(mehs)
|
k3result["meshes"].append(mehs)
|
||||||
|
|
||||||
if len(skin.joints) > 255:
|
if skin and len(skin.joints) > 255:
|
||||||
err("Bone maximum is 255")
|
err("Bone maximum is 255")
|
||||||
|
|
||||||
err_barrier()
|
err_barrier()
|
||||||
|
48
src/game.c
48
src/game.c
@ -150,13 +150,25 @@ static void contact_callback(void *data, dGeomID g1, dGeomID g2) {
|
|||||||
int triggerType = activate_pair(g1, g2);
|
int triggerType = activate_pair(g1, g2);
|
||||||
|
|
||||||
if(e1 != ENT_ID_INVALID) {
|
if(e1 != ENT_ID_INVALID) {
|
||||||
if(game_getcomponent(e1, physics)->dynamics & CPHYSICS_GHOST) {
|
struct CPhysics *cp = game_getcomponent(e1, physics);
|
||||||
|
if(!cp) {
|
||||||
|
// Entity being killed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cp->dynamics & CPHYSICS_GHOST) {
|
||||||
ghost = 1;
|
ghost = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e2 != ENT_ID_INVALID) {
|
if(e2 != ENT_ID_INVALID) {
|
||||||
if(game_getcomponent(e2, physics)->dynamics & CPHYSICS_GHOST) {
|
struct CPhysics *cp = game_getcomponent(e2, physics);
|
||||||
|
if(!cp) {
|
||||||
|
// Entity being killed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cp->dynamics & CPHYSICS_GHOST) {
|
||||||
ghost = 1;
|
ghost = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -896,3 +908,35 @@ void game_cleanup() {
|
|||||||
|
|
||||||
Game.contactgroup = dJointGroupCreate(0);
|
Game.contactgroup = dJointGroupCreate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void game_killentity(uint16_t eid) {
|
||||||
|
// XXX: Go over ALL component types!
|
||||||
|
|
||||||
|
struct CPhysics *cp = game_getcomponent(eid, physics);
|
||||||
|
if(cp) {
|
||||||
|
dBodyID bid = dGeomGetBody(cp->geom);
|
||||||
|
|
||||||
|
dGeomDestroy(cp->geom);
|
||||||
|
|
||||||
|
if(bid) {
|
||||||
|
dBodyDestroy(bid);
|
||||||
|
}
|
||||||
|
|
||||||
|
game_killcomponent_ptr(cp, physics);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CRender *cr = game_getcomponent(eid, render);
|
||||||
|
if(cr) {
|
||||||
|
if(cr->cache) {
|
||||||
|
if(resman_rev(cr->cache)) {
|
||||||
|
resman_unref(RESMAN_MODEL, cr->cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
game_killcomponent_ptr(cr, render);
|
||||||
|
}
|
||||||
|
|
||||||
|
game_killcomponent(eid, movement);
|
||||||
|
game_killcomponent(eid, playerctrl);
|
||||||
|
game_killcomponent(eid, boned);
|
||||||
|
}
|
||||||
|
15
src/game.h
15
src/game.h
@ -248,7 +248,22 @@ static inline void *game_ensurecomponent_(uint16_t eid, void *array, size_t comp
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define game_killcomponent_ptr(c, arr) do { \
|
||||||
|
size_t idx = c - Game.entities.arr; \
|
||||||
|
memmove(c, c + 1, sizeof(*c) * (Game.entities.arr##Count - idx - 1)); \
|
||||||
|
Game.entities.arr##Count--; \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
|
#define game_killcomponent(eid, arr) do { \
|
||||||
|
typeof(&Game.entities.arr[0]) c = game_getcomponent(eid, arr); \
|
||||||
|
if(c) { \
|
||||||
|
game_killcomponent_ptr(c, arr); \
|
||||||
|
} \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
// An artifact of using a third-party physics engine
|
// An artifact of using a third-party physics engine
|
||||||
void game_synccphysics();
|
void game_synccphysics();
|
||||||
|
|
||||||
void game_cleanup();
|
void game_cleanup();
|
||||||
|
|
||||||
|
void game_killentity(uint16_t eid);
|
||||||
|
84
src/gl.h
84
src/gl.h
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* Loader generated by glad 2.0.8 on Sun Nov 17 08:36:10 2024
|
* Loader generated by glad 2.0.8 on Fri May 9 09:20:04 2025
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||||
*
|
*
|
||||||
* Generator: C/C++
|
* Generator: C/C++
|
||||||
* Specification: gl
|
* Specification: gl
|
||||||
* Extensions: 31
|
* Extensions: 37
|
||||||
*
|
*
|
||||||
* APIs:
|
* APIs:
|
||||||
* - gl:compatibility=4.6
|
* - gl:compatibility=4.6
|
||||||
@ -19,10 +19,10 @@
|
|||||||
* - ON_DEMAND = False
|
* - ON_DEMAND = False
|
||||||
*
|
*
|
||||||
* Commandline:
|
* Commandline:
|
||||||
* --api='gl:compatibility=4.6' --extensions='GL_ARB_compatibility,GL_ARB_debug_output,GL_ARB_fragment_program,GL_ARB_fragment_shader,GL_ARB_framebuffer_sRGB,GL_ARB_shader_image_load_store,GL_ARB_shader_image_size,GL_ARB_shader_objects,GL_ARB_shader_storage_buffer_object,GL_ARB_shading_language_100,GL_ARB_texture_float,GL_ARB_texture_rg,GL_ARB_texture_rgb10_a2ui,GL_ARB_vertex_buffer_object,GL_ARB_vertex_program,GL_ARB_vertex_shader,GL_ARB_vertex_type_2_10_10_10_rev,GL_EXT_direct_state_access,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_object,GL_EXT_framebuffer_sRGB,GL_EXT_geometry_shader4,GL_EXT_gpu_shader4,GL_EXT_shader_image_load_store,GL_EXT_texture_array,GL_EXT_texture_compression_s3tc,GL_EXT_texture_integer,GL_EXT_texture_sRGB,GL_EXT_transform_feedback,GL_INTEL_conservative_rasterization,GL_NV_conservative_raster' c --header-only
|
* --api='gl:compatibility=4.6' --extensions='GL_ARB_compatibility,GL_ARB_debug_output,GL_ARB_fragment_program,GL_ARB_fragment_shader,GL_ARB_framebuffer_sRGB,GL_ARB_shader_image_load_store,GL_ARB_shader_image_size,GL_ARB_shader_objects,GL_ARB_shader_storage_buffer_object,GL_ARB_shading_language_100,GL_ARB_texture_compression_bptc,GL_ARB_texture_float,GL_ARB_texture_rg,GL_ARB_texture_rgb10_a2ui,GL_ARB_vertex_buffer_object,GL_ARB_vertex_program,GL_ARB_vertex_shader,GL_ARB_vertex_type_2_10_10_10_rev,GL_EXT_direct_state_access,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_multisample_blit_scaled,GL_EXT_framebuffer_object,GL_EXT_framebuffer_sRGB,GL_EXT_geometry_shader4,GL_EXT_gpu_shader4,GL_EXT_shader_image_load_store,GL_EXT_texture_array,GL_EXT_texture_compression_rgtc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_integer,GL_EXT_texture_sRGB,GL_EXT_transform_feedback,GL_INTEL_conservative_rasterization,GL_KHR_texture_compression_astc_ldr,GL_NV_conservative_raster' c --header-only
|
||||||
*
|
*
|
||||||
* Online:
|
* Online:
|
||||||
* http://glad.sh/#api=gl%3Acompatibility%3D4.6&extensions=GL_ARB_compatibility%2CGL_ARB_debug_output%2CGL_ARB_fragment_program%2CGL_ARB_fragment_shader%2CGL_ARB_framebuffer_sRGB%2CGL_ARB_shader_image_load_store%2CGL_ARB_shader_image_size%2CGL_ARB_shader_objects%2CGL_ARB_shader_storage_buffer_object%2CGL_ARB_shading_language_100%2CGL_ARB_texture_float%2CGL_ARB_texture_rg%2CGL_ARB_texture_rgb10_a2ui%2CGL_ARB_vertex_buffer_object%2CGL_ARB_vertex_program%2CGL_ARB_vertex_shader%2CGL_ARB_vertex_type_2_10_10_10_rev%2CGL_EXT_direct_state_access%2CGL_EXT_framebuffer_blit%2CGL_EXT_framebuffer_object%2CGL_EXT_framebuffer_sRGB%2CGL_EXT_geometry_shader4%2CGL_EXT_gpu_shader4%2CGL_EXT_shader_image_load_store%2CGL_EXT_texture_array%2CGL_EXT_texture_compression_s3tc%2CGL_EXT_texture_integer%2CGL_EXT_texture_sRGB%2CGL_EXT_transform_feedback%2CGL_INTEL_conservative_rasterization%2CGL_NV_conservative_raster&generator=c&options=HEADER_ONLY
|
* http://glad.sh/#api=gl%3Acompatibility%3D4.6&extensions=GL_ARB_compatibility%2CGL_ARB_debug_output%2CGL_ARB_fragment_program%2CGL_ARB_fragment_shader%2CGL_ARB_framebuffer_sRGB%2CGL_ARB_shader_image_load_store%2CGL_ARB_shader_image_size%2CGL_ARB_shader_objects%2CGL_ARB_shader_storage_buffer_object%2CGL_ARB_shading_language_100%2CGL_ARB_texture_compression_bptc%2CGL_ARB_texture_float%2CGL_ARB_texture_rg%2CGL_ARB_texture_rgb10_a2ui%2CGL_ARB_vertex_buffer_object%2CGL_ARB_vertex_program%2CGL_ARB_vertex_shader%2CGL_ARB_vertex_type_2_10_10_10_rev%2CGL_EXT_direct_state_access%2CGL_EXT_framebuffer_blit%2CGL_EXT_framebuffer_multisample%2CGL_EXT_framebuffer_multisample_blit_scaled%2CGL_EXT_framebuffer_object%2CGL_EXT_framebuffer_sRGB%2CGL_EXT_geometry_shader4%2CGL_EXT_gpu_shader4%2CGL_EXT_shader_image_load_store%2CGL_EXT_texture_array%2CGL_EXT_texture_compression_rgtc%2CGL_EXT_texture_compression_s3tc%2CGL_EXT_texture_filter_anisotropic%2CGL_EXT_texture_integer%2CGL_EXT_texture_sRGB%2CGL_EXT_transform_feedback%2CGL_INTEL_conservative_rasterization%2CGL_KHR_texture_compression_astc_ldr%2CGL_NV_conservative_raster&generator=c&options=HEADER_ONLY
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -465,7 +465,9 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
|
#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
|
||||||
#define GL_COMPRESSED_R11_EAC 0x9270
|
#define GL_COMPRESSED_R11_EAC 0x9270
|
||||||
#define GL_COMPRESSED_RED 0x8225
|
#define GL_COMPRESSED_RED 0x8225
|
||||||
|
#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
|
||||||
#define GL_COMPRESSED_RED_RGTC1 0x8DBB
|
#define GL_COMPRESSED_RED_RGTC1 0x8DBB
|
||||||
|
#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
|
||||||
#define GL_COMPRESSED_RG 0x8226
|
#define GL_COMPRESSED_RG 0x8226
|
||||||
#define GL_COMPRESSED_RG11_EAC 0x9272
|
#define GL_COMPRESSED_RG11_EAC 0x9272
|
||||||
#define GL_COMPRESSED_RGB 0x84ED
|
#define GL_COMPRESSED_RGB 0x84ED
|
||||||
@ -473,16 +475,35 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
|
#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
|
||||||
#define GL_COMPRESSED_RGBA 0x84EE
|
#define GL_COMPRESSED_RGBA 0x84EE
|
||||||
#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
|
#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
|
||||||
|
#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
|
||||||
#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C
|
#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C
|
||||||
|
#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
|
||||||
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||||
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
|
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
|
||||||
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
||||||
#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
|
#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
|
||||||
|
#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
|
||||||
#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
|
#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
|
||||||
|
#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
|
||||||
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
|
||||||
#define GL_COMPRESSED_RG_RGTC2 0x8DBD
|
#define GL_COMPRESSED_RG_RGTC2 0x8DBD
|
||||||
#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
|
#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
|
||||||
|
#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
|
||||||
#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
|
#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
|
||||||
|
#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
|
||||||
#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
|
#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
|
||||||
#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
|
#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
|
||||||
#define GL_COMPRESSED_SLUMINANCE 0x8C4A
|
#define GL_COMPRESSED_SLUMINANCE 0x8C4A
|
||||||
@ -490,11 +511,26 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
|
#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
|
||||||
#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
|
#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
|
||||||
#define GL_COMPRESSED_SRGB 0x8C48
|
#define GL_COMPRESSED_SRGB 0x8C48
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
|
||||||
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
|
||||||
#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
|
#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
|
||||||
#define GL_COMPRESSED_SRGB8_ETC2 0x9275
|
#define GL_COMPRESSED_SRGB8_ETC2 0x9275
|
||||||
#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
|
#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
|
||||||
#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
|
#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
|
||||||
#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D
|
#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D
|
||||||
|
#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
|
||||||
#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
|
#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
|
||||||
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
|
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
|
||||||
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
|
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
|
||||||
@ -833,6 +869,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
|
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
|
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
|
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
|
||||||
|
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
|
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
|
||||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
|
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
|
||||||
#define GL_FRAMEBUFFER_RENDERABLE 0x8289
|
#define GL_FRAMEBUFFER_RENDERABLE 0x8289
|
||||||
@ -1335,6 +1372,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
|
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
|
||||||
#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
|
#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
|
||||||
#define GL_MAX_SAMPLES 0x8D57
|
#define GL_MAX_SAMPLES 0x8D57
|
||||||
|
#define GL_MAX_SAMPLES_EXT 0x8D57
|
||||||
#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
|
#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
|
||||||
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
|
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
|
||||||
#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
|
#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
|
||||||
@ -1370,6 +1408,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
|
#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
|
||||||
#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
|
#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
|
||||||
#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
|
#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF
|
||||||
|
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||||
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
||||||
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
|
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
|
||||||
#define GL_MAX_TEXTURE_UNITS 0x84E2
|
#define GL_MAX_TEXTURE_UNITS 0x84E2
|
||||||
@ -1730,6 +1769,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
|
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
|
||||||
#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
|
#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
|
||||||
#define GL_RENDERBUFFER_SAMPLES 0x8CAB
|
#define GL_RENDERBUFFER_SAMPLES 0x8CAB
|
||||||
|
#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
|
||||||
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
|
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
|
||||||
#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
|
#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
|
||||||
#define GL_RENDERBUFFER_WIDTH 0x8D42
|
#define GL_RENDERBUFFER_WIDTH 0x8D42
|
||||||
@ -1864,6 +1904,8 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_SAMPLE_MASK_VALUE 0x8E52
|
#define GL_SAMPLE_MASK_VALUE 0x8E52
|
||||||
#define GL_SAMPLE_POSITION 0x8E50
|
#define GL_SAMPLE_POSITION 0x8E50
|
||||||
#define GL_SAMPLE_SHADING 0x8C36
|
#define GL_SAMPLE_SHADING 0x8C36
|
||||||
|
#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
|
||||||
|
#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB
|
||||||
#define GL_SCISSOR_BIT 0x00080000
|
#define GL_SCISSOR_BIT 0x00080000
|
||||||
#define GL_SCISSOR_BOX 0x0C10
|
#define GL_SCISSOR_BOX 0x0C10
|
||||||
#define GL_SCISSOR_TEST 0x0C11
|
#define GL_SCISSOR_TEST 0x0C11
|
||||||
@ -2174,6 +2216,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
|||||||
#define GL_TEXTURE_MAG_FILTER 0x2800
|
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||||
#define GL_TEXTURE_MATRIX 0x0BA8
|
#define GL_TEXTURE_MATRIX 0x0BA8
|
||||||
#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
|
#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE
|
||||||
|
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||||
#define GL_TEXTURE_MAX_LEVEL 0x813D
|
#define GL_TEXTURE_MAX_LEVEL 0x813D
|
||||||
#define GL_TEXTURE_MAX_LOD 0x813B
|
#define GL_TEXTURE_MAX_LOD 0x813B
|
||||||
#define GL_TEXTURE_MIN_FILTER 0x2801
|
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||||
@ -2889,6 +2932,8 @@ GLAD_API_CALL int GLAD_GL_ARB_shader_objects;
|
|||||||
GLAD_API_CALL int GLAD_GL_ARB_shader_storage_buffer_object;
|
GLAD_API_CALL int GLAD_GL_ARB_shader_storage_buffer_object;
|
||||||
#define GL_ARB_shading_language_100 1
|
#define GL_ARB_shading_language_100 1
|
||||||
GLAD_API_CALL int GLAD_GL_ARB_shading_language_100;
|
GLAD_API_CALL int GLAD_GL_ARB_shading_language_100;
|
||||||
|
#define GL_ARB_texture_compression_bptc 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_ARB_texture_compression_bptc;
|
||||||
#define GL_ARB_texture_float 1
|
#define GL_ARB_texture_float 1
|
||||||
GLAD_API_CALL int GLAD_GL_ARB_texture_float;
|
GLAD_API_CALL int GLAD_GL_ARB_texture_float;
|
||||||
#define GL_ARB_texture_rg 1
|
#define GL_ARB_texture_rg 1
|
||||||
@ -2907,6 +2952,10 @@ GLAD_API_CALL int GLAD_GL_ARB_vertex_type_2_10_10_10_rev;
|
|||||||
GLAD_API_CALL int GLAD_GL_EXT_direct_state_access;
|
GLAD_API_CALL int GLAD_GL_EXT_direct_state_access;
|
||||||
#define GL_EXT_framebuffer_blit 1
|
#define GL_EXT_framebuffer_blit 1
|
||||||
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_blit;
|
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_blit;
|
||||||
|
#define GL_EXT_framebuffer_multisample 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_multisample;
|
||||||
|
#define GL_EXT_framebuffer_multisample_blit_scaled 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_multisample_blit_scaled;
|
||||||
#define GL_EXT_framebuffer_object 1
|
#define GL_EXT_framebuffer_object 1
|
||||||
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_object;
|
GLAD_API_CALL int GLAD_GL_EXT_framebuffer_object;
|
||||||
#define GL_EXT_framebuffer_sRGB 1
|
#define GL_EXT_framebuffer_sRGB 1
|
||||||
@ -2919,8 +2968,12 @@ GLAD_API_CALL int GLAD_GL_EXT_gpu_shader4;
|
|||||||
GLAD_API_CALL int GLAD_GL_EXT_shader_image_load_store;
|
GLAD_API_CALL int GLAD_GL_EXT_shader_image_load_store;
|
||||||
#define GL_EXT_texture_array 1
|
#define GL_EXT_texture_array 1
|
||||||
GLAD_API_CALL int GLAD_GL_EXT_texture_array;
|
GLAD_API_CALL int GLAD_GL_EXT_texture_array;
|
||||||
|
#define GL_EXT_texture_compression_rgtc 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_EXT_texture_compression_rgtc;
|
||||||
#define GL_EXT_texture_compression_s3tc 1
|
#define GL_EXT_texture_compression_s3tc 1
|
||||||
GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
|
GLAD_API_CALL int GLAD_GL_EXT_texture_compression_s3tc;
|
||||||
|
#define GL_EXT_texture_filter_anisotropic 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_EXT_texture_filter_anisotropic;
|
||||||
#define GL_EXT_texture_integer 1
|
#define GL_EXT_texture_integer 1
|
||||||
GLAD_API_CALL int GLAD_GL_EXT_texture_integer;
|
GLAD_API_CALL int GLAD_GL_EXT_texture_integer;
|
||||||
#define GL_EXT_texture_sRGB 1
|
#define GL_EXT_texture_sRGB 1
|
||||||
@ -2929,6 +2982,8 @@ GLAD_API_CALL int GLAD_GL_EXT_texture_sRGB;
|
|||||||
GLAD_API_CALL int GLAD_GL_EXT_transform_feedback;
|
GLAD_API_CALL int GLAD_GL_EXT_transform_feedback;
|
||||||
#define GL_INTEL_conservative_rasterization 1
|
#define GL_INTEL_conservative_rasterization 1
|
||||||
GLAD_API_CALL int GLAD_GL_INTEL_conservative_rasterization;
|
GLAD_API_CALL int GLAD_GL_INTEL_conservative_rasterization;
|
||||||
|
#define GL_KHR_texture_compression_astc_ldr 1
|
||||||
|
GLAD_API_CALL int GLAD_GL_KHR_texture_compression_astc_ldr;
|
||||||
#define GL_NV_conservative_raster 1
|
#define GL_NV_conservative_raster 1
|
||||||
GLAD_API_CALL int GLAD_GL_NV_conservative_raster;
|
GLAD_API_CALL int GLAD_GL_NV_conservative_raster;
|
||||||
|
|
||||||
@ -3949,6 +4004,7 @@ typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum mode);
|
|||||||
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
|
typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||||
typedef void (GLAD_API_PTR *PFNGLRESUMETRANSFORMFEEDBACKPROC)(void);
|
typedef void (GLAD_API_PTR *PFNGLRESUMETRANSFORMFEEDBACKPROC)(void);
|
||||||
typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
|
typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
|
||||||
typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
|
typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
|
||||||
@ -6458,6 +6514,8 @@ GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
|
|||||||
#define glRenderbufferStorageEXT glad_glRenderbufferStorageEXT
|
#define glRenderbufferStorageEXT glad_glRenderbufferStorageEXT
|
||||||
GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
|
GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
|
||||||
#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
|
#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
|
||||||
|
GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
|
||||||
|
#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
|
||||||
GLAD_API_CALL PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback;
|
GLAD_API_CALL PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback;
|
||||||
#define glResumeTransformFeedback glad_glResumeTransformFeedback
|
#define glResumeTransformFeedback glad_glResumeTransformFeedback
|
||||||
GLAD_API_CALL PFNGLROTATEDPROC glad_glRotated;
|
GLAD_API_CALL PFNGLROTATEDPROC glad_glRotated;
|
||||||
@ -7480,6 +7538,7 @@ int GLAD_GL_ARB_shader_image_size = 0;
|
|||||||
int GLAD_GL_ARB_shader_objects = 0;
|
int GLAD_GL_ARB_shader_objects = 0;
|
||||||
int GLAD_GL_ARB_shader_storage_buffer_object = 0;
|
int GLAD_GL_ARB_shader_storage_buffer_object = 0;
|
||||||
int GLAD_GL_ARB_shading_language_100 = 0;
|
int GLAD_GL_ARB_shading_language_100 = 0;
|
||||||
|
int GLAD_GL_ARB_texture_compression_bptc = 0;
|
||||||
int GLAD_GL_ARB_texture_float = 0;
|
int GLAD_GL_ARB_texture_float = 0;
|
||||||
int GLAD_GL_ARB_texture_rg = 0;
|
int GLAD_GL_ARB_texture_rg = 0;
|
||||||
int GLAD_GL_ARB_texture_rgb10_a2ui = 0;
|
int GLAD_GL_ARB_texture_rgb10_a2ui = 0;
|
||||||
@ -7489,17 +7548,22 @@ int GLAD_GL_ARB_vertex_shader = 0;
|
|||||||
int GLAD_GL_ARB_vertex_type_2_10_10_10_rev = 0;
|
int GLAD_GL_ARB_vertex_type_2_10_10_10_rev = 0;
|
||||||
int GLAD_GL_EXT_direct_state_access = 0;
|
int GLAD_GL_EXT_direct_state_access = 0;
|
||||||
int GLAD_GL_EXT_framebuffer_blit = 0;
|
int GLAD_GL_EXT_framebuffer_blit = 0;
|
||||||
|
int GLAD_GL_EXT_framebuffer_multisample = 0;
|
||||||
|
int GLAD_GL_EXT_framebuffer_multisample_blit_scaled = 0;
|
||||||
int GLAD_GL_EXT_framebuffer_object = 0;
|
int GLAD_GL_EXT_framebuffer_object = 0;
|
||||||
int GLAD_GL_EXT_framebuffer_sRGB = 0;
|
int GLAD_GL_EXT_framebuffer_sRGB = 0;
|
||||||
int GLAD_GL_EXT_geometry_shader4 = 0;
|
int GLAD_GL_EXT_geometry_shader4 = 0;
|
||||||
int GLAD_GL_EXT_gpu_shader4 = 0;
|
int GLAD_GL_EXT_gpu_shader4 = 0;
|
||||||
int GLAD_GL_EXT_shader_image_load_store = 0;
|
int GLAD_GL_EXT_shader_image_load_store = 0;
|
||||||
int GLAD_GL_EXT_texture_array = 0;
|
int GLAD_GL_EXT_texture_array = 0;
|
||||||
|
int GLAD_GL_EXT_texture_compression_rgtc = 0;
|
||||||
int GLAD_GL_EXT_texture_compression_s3tc = 0;
|
int GLAD_GL_EXT_texture_compression_s3tc = 0;
|
||||||
|
int GLAD_GL_EXT_texture_filter_anisotropic = 0;
|
||||||
int GLAD_GL_EXT_texture_integer = 0;
|
int GLAD_GL_EXT_texture_integer = 0;
|
||||||
int GLAD_GL_EXT_texture_sRGB = 0;
|
int GLAD_GL_EXT_texture_sRGB = 0;
|
||||||
int GLAD_GL_EXT_transform_feedback = 0;
|
int GLAD_GL_EXT_transform_feedback = 0;
|
||||||
int GLAD_GL_INTEL_conservative_rasterization = 0;
|
int GLAD_GL_INTEL_conservative_rasterization = 0;
|
||||||
|
int GLAD_GL_KHR_texture_compression_astc_ldr = 0;
|
||||||
int GLAD_GL_NV_conservative_raster = 0;
|
int GLAD_GL_NV_conservative_raster = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -8520,6 +8584,7 @@ PFNGLRENDERMODEPROC glad_glRenderMode = NULL;
|
|||||||
PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
|
PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
|
||||||
PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT = NULL;
|
PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT = NULL;
|
||||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
|
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
|
||||||
|
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT = NULL;
|
||||||
PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback = NULL;
|
PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback = NULL;
|
||||||
PFNGLROTATEDPROC glad_glRotated = NULL;
|
PFNGLROTATEDPROC glad_glRotated = NULL;
|
||||||
PFNGLROTATEFPROC glad_glRotatef = NULL;
|
PFNGLROTATEFPROC glad_glRotatef = NULL;
|
||||||
@ -10618,6 +10683,10 @@ static void glad_gl_load_GL_EXT_framebuffer_blit( GLADuserptrloadfunc load, void
|
|||||||
if(!GLAD_GL_EXT_framebuffer_blit) return;
|
if(!GLAD_GL_EXT_framebuffer_blit) return;
|
||||||
glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC) load(userptr, "glBlitFramebufferEXT");
|
glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC) load(userptr, "glBlitFramebufferEXT");
|
||||||
}
|
}
|
||||||
|
static void glad_gl_load_GL_EXT_framebuffer_multisample( GLADuserptrloadfunc load, void* userptr) {
|
||||||
|
if(!GLAD_GL_EXT_framebuffer_multisample) return;
|
||||||
|
glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) load(userptr, "glRenderbufferStorageMultisampleEXT");
|
||||||
|
}
|
||||||
static void glad_gl_load_GL_EXT_framebuffer_object( GLADuserptrloadfunc load, void* userptr) {
|
static void glad_gl_load_GL_EXT_framebuffer_object( GLADuserptrloadfunc load, void* userptr) {
|
||||||
if(!GLAD_GL_EXT_framebuffer_object) return;
|
if(!GLAD_GL_EXT_framebuffer_object) return;
|
||||||
glad_glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) load(userptr, "glBindFramebufferEXT");
|
glad_glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) load(userptr, "glBindFramebufferEXT");
|
||||||
@ -10816,6 +10885,7 @@ static int glad_gl_find_extensions_gl(void) {
|
|||||||
GLAD_GL_ARB_shader_objects = glad_gl_has_extension(exts, exts_i, "GL_ARB_shader_objects");
|
GLAD_GL_ARB_shader_objects = glad_gl_has_extension(exts, exts_i, "GL_ARB_shader_objects");
|
||||||
GLAD_GL_ARB_shader_storage_buffer_object = glad_gl_has_extension(exts, exts_i, "GL_ARB_shader_storage_buffer_object");
|
GLAD_GL_ARB_shader_storage_buffer_object = glad_gl_has_extension(exts, exts_i, "GL_ARB_shader_storage_buffer_object");
|
||||||
GLAD_GL_ARB_shading_language_100 = glad_gl_has_extension(exts, exts_i, "GL_ARB_shading_language_100");
|
GLAD_GL_ARB_shading_language_100 = glad_gl_has_extension(exts, exts_i, "GL_ARB_shading_language_100");
|
||||||
|
GLAD_GL_ARB_texture_compression_bptc = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_compression_bptc");
|
||||||
GLAD_GL_ARB_texture_float = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_float");
|
GLAD_GL_ARB_texture_float = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_float");
|
||||||
GLAD_GL_ARB_texture_rg = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_rg");
|
GLAD_GL_ARB_texture_rg = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_rg");
|
||||||
GLAD_GL_ARB_texture_rgb10_a2ui = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_rgb10_a2ui");
|
GLAD_GL_ARB_texture_rgb10_a2ui = glad_gl_has_extension(exts, exts_i, "GL_ARB_texture_rgb10_a2ui");
|
||||||
@ -10825,17 +10895,22 @@ static int glad_gl_find_extensions_gl(void) {
|
|||||||
GLAD_GL_ARB_vertex_type_2_10_10_10_rev = glad_gl_has_extension(exts, exts_i, "GL_ARB_vertex_type_2_10_10_10_rev");
|
GLAD_GL_ARB_vertex_type_2_10_10_10_rev = glad_gl_has_extension(exts, exts_i, "GL_ARB_vertex_type_2_10_10_10_rev");
|
||||||
GLAD_GL_EXT_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_EXT_direct_state_access");
|
GLAD_GL_EXT_direct_state_access = glad_gl_has_extension(exts, exts_i, "GL_EXT_direct_state_access");
|
||||||
GLAD_GL_EXT_framebuffer_blit = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_blit");
|
GLAD_GL_EXT_framebuffer_blit = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_blit");
|
||||||
|
GLAD_GL_EXT_framebuffer_multisample = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_multisample");
|
||||||
|
GLAD_GL_EXT_framebuffer_multisample_blit_scaled = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_multisample_blit_scaled");
|
||||||
GLAD_GL_EXT_framebuffer_object = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_object");
|
GLAD_GL_EXT_framebuffer_object = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_object");
|
||||||
GLAD_GL_EXT_framebuffer_sRGB = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_sRGB");
|
GLAD_GL_EXT_framebuffer_sRGB = glad_gl_has_extension(exts, exts_i, "GL_EXT_framebuffer_sRGB");
|
||||||
GLAD_GL_EXT_geometry_shader4 = glad_gl_has_extension(exts, exts_i, "GL_EXT_geometry_shader4");
|
GLAD_GL_EXT_geometry_shader4 = glad_gl_has_extension(exts, exts_i, "GL_EXT_geometry_shader4");
|
||||||
GLAD_GL_EXT_gpu_shader4 = glad_gl_has_extension(exts, exts_i, "GL_EXT_gpu_shader4");
|
GLAD_GL_EXT_gpu_shader4 = glad_gl_has_extension(exts, exts_i, "GL_EXT_gpu_shader4");
|
||||||
GLAD_GL_EXT_shader_image_load_store = glad_gl_has_extension(exts, exts_i, "GL_EXT_shader_image_load_store");
|
GLAD_GL_EXT_shader_image_load_store = glad_gl_has_extension(exts, exts_i, "GL_EXT_shader_image_load_store");
|
||||||
GLAD_GL_EXT_texture_array = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_array");
|
GLAD_GL_EXT_texture_array = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_array");
|
||||||
|
GLAD_GL_EXT_texture_compression_rgtc = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_compression_rgtc");
|
||||||
GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_compression_s3tc");
|
GLAD_GL_EXT_texture_compression_s3tc = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_compression_s3tc");
|
||||||
|
GLAD_GL_EXT_texture_filter_anisotropic = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_filter_anisotropic");
|
||||||
GLAD_GL_EXT_texture_integer = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_integer");
|
GLAD_GL_EXT_texture_integer = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_integer");
|
||||||
GLAD_GL_EXT_texture_sRGB = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_sRGB");
|
GLAD_GL_EXT_texture_sRGB = glad_gl_has_extension(exts, exts_i, "GL_EXT_texture_sRGB");
|
||||||
GLAD_GL_EXT_transform_feedback = glad_gl_has_extension(exts, exts_i, "GL_EXT_transform_feedback");
|
GLAD_GL_EXT_transform_feedback = glad_gl_has_extension(exts, exts_i, "GL_EXT_transform_feedback");
|
||||||
GLAD_GL_INTEL_conservative_rasterization = glad_gl_has_extension(exts, exts_i, "GL_INTEL_conservative_rasterization");
|
GLAD_GL_INTEL_conservative_rasterization = glad_gl_has_extension(exts, exts_i, "GL_INTEL_conservative_rasterization");
|
||||||
|
GLAD_GL_KHR_texture_compression_astc_ldr = glad_gl_has_extension(exts, exts_i, "GL_KHR_texture_compression_astc_ldr");
|
||||||
GLAD_GL_NV_conservative_raster = glad_gl_has_extension(exts, exts_i, "GL_NV_conservative_raster");
|
GLAD_GL_NV_conservative_raster = glad_gl_has_extension(exts, exts_i, "GL_NV_conservative_raster");
|
||||||
|
|
||||||
glad_gl_free_extensions(exts_i);
|
glad_gl_free_extensions(exts_i);
|
||||||
@ -10929,6 +11004,7 @@ int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
|
|||||||
glad_gl_load_GL_ARB_vertex_type_2_10_10_10_rev(load, userptr);
|
glad_gl_load_GL_ARB_vertex_type_2_10_10_10_rev(load, userptr);
|
||||||
glad_gl_load_GL_EXT_direct_state_access(load, userptr);
|
glad_gl_load_GL_EXT_direct_state_access(load, userptr);
|
||||||
glad_gl_load_GL_EXT_framebuffer_blit(load, userptr);
|
glad_gl_load_GL_EXT_framebuffer_blit(load, userptr);
|
||||||
|
glad_gl_load_GL_EXT_framebuffer_multisample(load, userptr);
|
||||||
glad_gl_load_GL_EXT_framebuffer_object(load, userptr);
|
glad_gl_load_GL_EXT_framebuffer_object(load, userptr);
|
||||||
glad_gl_load_GL_EXT_geometry_shader4(load, userptr);
|
glad_gl_load_GL_EXT_geometry_shader4(load, userptr);
|
||||||
glad_gl_load_GL_EXT_gpu_shader4(load, userptr);
|
glad_gl_load_GL_EXT_gpu_shader4(load, userptr);
|
||||||
|
@ -351,7 +351,7 @@ __attribute__((optimize("Ofast"))) static void k3MixDoYourThang(size_t sampleCou
|
|||||||
} else i++;
|
} else i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < sampleCount * FinalChannels; i += 4) {
|
/*for(size_t i = 0; i < sampleCount * FinalChannels; i += 4) {
|
||||||
// Compute tanh approximation x*(27+x*x)/(27+9*x*x)
|
// Compute tanh approximation x*(27+x*x)/(27+9*x*x)
|
||||||
|
|
||||||
float *ptr = FinalData + i;
|
float *ptr = FinalData + i;
|
||||||
@ -363,7 +363,7 @@ __attribute__((optimize("Ofast"))) static void k3MixDoYourThang(size_t sampleCou
|
|||||||
__m128 denom = _mm_add_ps(_mm_set1_ps(27), _mm_mul_ps(_mm_set1_ps(9), xx));
|
__m128 denom = _mm_add_ps(_mm_set1_ps(27), _mm_mul_ps(_mm_set1_ps(9), xx));
|
||||||
|
|
||||||
_mm_storeu_ps(ptr, _mm_div_ps(numer, denom));
|
_mm_storeu_ps(ptr, _mm_div_ps(numer, denom));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// The accuracy isn't worth the function call per sample
|
// The accuracy isn't worth the function call per sample
|
||||||
/*for(size_t i = 0; i < sampleCount * FinalChannels; i++) {
|
/*for(size_t i = 0; i < sampleCount * FinalChannels; i++) {
|
||||||
|
@ -253,15 +253,27 @@ static int refresh_texture(struct ResManRes *res) {
|
|||||||
|
|
||||||
int w, h, origN;
|
int w, h, origN;
|
||||||
unsigned char *data = stbi_load(namebuf, &w, &h, &origN, n);
|
unsigned char *data = stbi_load(namebuf, &w, &h, &origN, n);
|
||||||
int stbifree = 1;
|
|
||||||
|
|
||||||
if(TextureResolutionReduction && data) {
|
int newW = w, newH = h;
|
||||||
int newW = w >> TextureResolutionReduction;
|
|
||||||
int newH = h >> TextureResolutionReduction;
|
|
||||||
|
|
||||||
if(newW <= 4) newW = 4;
|
if(TextureResolutionReduction) {
|
||||||
if(newH <= 4) newH = 4;
|
newW = newW >> TextureResolutionReduction;
|
||||||
|
newH = newH >> TextureResolutionReduction;
|
||||||
|
}
|
||||||
|
if(newW > k3TexSzMax()) {
|
||||||
|
newW = k3TexSzMax();
|
||||||
|
}
|
||||||
|
if(newH > k3TexSzMax()) {
|
||||||
|
newH = k3TexSzMax();
|
||||||
|
}
|
||||||
|
if(newW < 4) {
|
||||||
|
newW = 4;
|
||||||
|
}
|
||||||
|
if(newH < 4) {
|
||||||
|
newH = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newW != w || newH != h) {
|
||||||
unsigned char *data2 = malloc(newW * newH * n);
|
unsigned char *data2 = malloc(newW * newH * n);
|
||||||
int success = stbir_resize_uint8_generic(data, w, h, 0, data2, newW, newH, 0, n, n == 4 ? 3 : -1, 0, STBIR_EDGE_WRAP, STBIR_FILTER_DEFAULT, gamma ? STBIR_COLORSPACE_SRGB : STBIR_COLORSPACE_LINEAR, NULL);
|
int success = stbir_resize_uint8_generic(data, w, h, 0, data2, newW, newH, 0, n, n == 4 ? 3 : -1, 0, STBIR_EDGE_WRAP, STBIR_FILTER_DEFAULT, gamma ? STBIR_COLORSPACE_SRGB : STBIR_COLORSPACE_LINEAR, NULL);
|
||||||
|
|
||||||
@ -271,7 +283,6 @@ static int refresh_texture(struct ResManRes *res) {
|
|||||||
w = newW;
|
w = newW;
|
||||||
h = newH;
|
h = newH;
|
||||||
data = data2;
|
data = data2;
|
||||||
stbifree = 0;
|
|
||||||
} else {
|
} else {
|
||||||
free(data2);
|
free(data2);
|
||||||
}
|
}
|
||||||
@ -283,12 +294,7 @@ static int refresh_texture(struct ResManRes *res) {
|
|||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
k3TexUpdate(res->thing, type, 0, w, h, data);
|
k3TexUpdate(res->thing, type, 0, w, h, data);
|
||||||
|
free(data);
|
||||||
if(stbifree) {
|
|
||||||
stbi_image_free(data);
|
|
||||||
} else {
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
414
src/luaapi.c
414
src/luaapi.c
@ -15,6 +15,8 @@
|
|||||||
#include"k3menu.h"
|
#include"k3menu.h"
|
||||||
#include<assert.h>
|
#include<assert.h>
|
||||||
#include"net_hi.h"
|
#include"net_hi.h"
|
||||||
|
#include"k3particles.h"
|
||||||
|
#include<GLFW/glfw3.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is by far the least clean or well-maintained source in the
|
* This is by far the least clean or well-maintained source in the
|
||||||
@ -170,6 +172,24 @@ error:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct mixitem {
|
||||||
|
void *thing;
|
||||||
|
#define MIXITEM_SOURCE 0
|
||||||
|
#define MIXITEM_SOUND 1
|
||||||
|
#define MIXITEM_QUEUE 2
|
||||||
|
#define MIXITEM_POWER 3
|
||||||
|
int type;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Animator {
|
||||||
|
struct k3Mdl *mdl;
|
||||||
|
struct k3Animator animator;
|
||||||
|
struct k3AnimationBone *bones;
|
||||||
|
|
||||||
|
bool playing;
|
||||||
|
double playStartTime;
|
||||||
|
};
|
||||||
|
|
||||||
static int game_addentity(lua_State *L) {
|
static int game_addentity(lua_State *L) {
|
||||||
lua_Integer li;
|
lua_Integer li;
|
||||||
int i;
|
int i;
|
||||||
@ -666,15 +686,6 @@ static int game_water_disturb(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mixitem {
|
|
||||||
void *thing;
|
|
||||||
#define MIXITEM_SOURCE 0
|
|
||||||
#define MIXITEM_SOUND 1
|
|
||||||
#define MIXITEM_QUEUE 2
|
|
||||||
#define MIXITEM_POWER 3
|
|
||||||
int type;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int dagame_mixsound(lua_State *L) {
|
static int dagame_mixsound(lua_State *L) {
|
||||||
struct mixitem *i = lua_touserdata(L, 1);
|
struct mixitem *i = lua_touserdata(L, 1);
|
||||||
|
|
||||||
@ -866,13 +877,15 @@ static int game_ref(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int game_batch(lua_State *L) {
|
static int game_batch(lua_State *L) {
|
||||||
void **r = lua_touserdata(L, 1);
|
void *r = lua_touserdata(L, 1);
|
||||||
|
|
||||||
struct k3Mdl *mdl;
|
struct k3Mdl *mdl;
|
||||||
if(luaL_testudata(L, 1, "k3water")) {
|
if(luaL_testudata(L, 1, "k3water")) {
|
||||||
mdl = ((struct k3Water*) *r)->mdl;
|
mdl = (*(struct k3Water**) r)->mdl;
|
||||||
|
} else if(luaL_testudata(L, 1, "k3cpuparticles")) {
|
||||||
|
mdl = (*(struct k3CPUQuadParticles**) r)->mdl;
|
||||||
} else if(luaL_testudata(L, 1, "k3mdl")) {
|
} else if(luaL_testudata(L, 1, "k3mdl")) {
|
||||||
mdl = *r;
|
mdl = *(struct k3Mdl**) r;
|
||||||
} else return 0;
|
} else return 0;
|
||||||
|
|
||||||
lua_rawgeti(L, 2, 1);
|
lua_rawgeti(L, 2, 1);
|
||||||
@ -884,7 +897,28 @@ static int game_batch(lua_State *L) {
|
|||||||
|
|
||||||
lua_pop(L, 3);
|
lua_pop(L, 3);
|
||||||
|
|
||||||
if(lua_gettop(L) == 3) {
|
struct k3AnimationBone *bones = NULL;
|
||||||
|
|
||||||
|
if(lua_gettop(L) >= 4) {
|
||||||
|
struct Animator *anim = lua_touserdata(L, 4);
|
||||||
|
|
||||||
|
if(anim->playing) {
|
||||||
|
k3AnimatorSet(&anim->animator, glfwGetTime() - anim->playStartTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
bones = anim->bones;
|
||||||
|
|
||||||
|
size_t boneCount = k3MdlGetBoneCount(anim->mdl);
|
||||||
|
|
||||||
|
for(size_t m = 0; m < boneCount; m++) {
|
||||||
|
vec3 scaleignore;
|
||||||
|
mat4 rot;
|
||||||
|
glm_decompose(anim->animator.inter[m], bones[m].translation, rot, scaleignore);
|
||||||
|
glm_mat4_quat(anim->animator.inter[m], bones[m].rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lua_gettop(L) >= 3) {
|
||||||
mat4 anchor;
|
mat4 anchor;
|
||||||
for(int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++) {
|
||||||
lua_rawgeti(L, 3, i + 1);
|
lua_rawgeti(L, 3, i + 1);
|
||||||
@ -895,7 +929,7 @@ static int game_batch(lua_State *L) {
|
|||||||
glm_mat4_mul(anchor, m, m);
|
glm_mat4_mul(anchor, m, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
k3Batch(mdl, m, NULL);
|
k3Batch(mdl, m, bones);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -986,6 +1020,22 @@ static int game_submissive_send(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dagame_cphysics_add_force(lua_State *L) {
|
||||||
|
struct CPhysics *c = *(struct CPhysics**) lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
dBodyID bid = dGeomGetBody(c->geom);
|
||||||
|
|
||||||
|
if(!bid) {
|
||||||
|
lua_pushboolean(L, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dBodyAddForce(bid, lua_tonumber(L, 2), lua_tonumber(L, 3), lua_tonumber(L, 4));
|
||||||
|
|
||||||
|
lua_pushboolean(L, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int game_cphysics_get(lua_State *L) {
|
static int game_cphysics_get(lua_State *L) {
|
||||||
struct CPhysics *c = *(struct CPhysics**) lua_touserdata(L, 1);
|
struct CPhysics *c = *(struct CPhysics**) lua_touserdata(L, 1);
|
||||||
|
|
||||||
@ -1052,7 +1102,7 @@ static int game_cphysics_get(lua_State *L) {
|
|||||||
lua_pushnumber(L, c->speed);
|
lua_pushnumber(L, c->speed);
|
||||||
return 1;
|
return 1;
|
||||||
} else if(!strcmp(k, "add_force")) {
|
} else if(!strcmp(k, "add_force")) {
|
||||||
//lua_pushcfunction(L, );
|
lua_pushcfunction(L, dagame_cphysics_add_force);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,7 +1133,9 @@ static int game_cphysics_set(lua_State *L) {
|
|||||||
lua_rawgeti(L, 3, 3);
|
lua_rawgeti(L, 3, 3);
|
||||||
lua_rawgeti(L, 3, 4);
|
lua_rawgeti(L, 3, 4);
|
||||||
|
|
||||||
dGeomSetQuaternion(c->geom, (dQuaternion) {lua_tonumber(L, -1), lua_tonumber(L, -4), lua_tonumber(L, -3), lua_tonumber(L, -2)});
|
dQuaternion q = {lua_tonumber(L, -1), lua_tonumber(L, -4), lua_tonumber(L, -3), lua_tonumber(L, -2)};
|
||||||
|
|
||||||
|
dGeomSetQuaternion(c->geom, q);
|
||||||
|
|
||||||
lua_pop(L, 4);
|
lua_pop(L, 4);
|
||||||
} else if(!strcmp(k, "vel")) {
|
} else if(!strcmp(k, "vel")) {
|
||||||
@ -1280,7 +1332,11 @@ static int game_get(lua_State *L) {
|
|||||||
} else if(!strcmp(i, "authority")) {
|
} else if(!strcmp(i, "authority")) {
|
||||||
lua_pushboolean(L, Game.isAuthority);
|
lua_pushboolean(L, Game.isAuthority);
|
||||||
} else if(!strcmp(i, "spectated")) {
|
} else if(!strcmp(i, "spectated")) {
|
||||||
lua_pushinteger(L, Game.spectated);
|
if(Game.spectated == ENT_ID_INVALID) {
|
||||||
|
lua_pushnil(L);
|
||||||
|
} else {
|
||||||
|
lua_pushinteger(L, Game.spectated);
|
||||||
|
}
|
||||||
} else if(!strcmp(i, "fov")) {
|
} else if(!strcmp(i, "fov")) {
|
||||||
lua_pushnumber(L, LuaapiFov);
|
lua_pushnumber(L, LuaapiFov);
|
||||||
} else if(!strcmp(i, "rate")) {
|
} else if(!strcmp(i, "rate")) {
|
||||||
@ -1491,7 +1547,6 @@ static int game_load(lua_State *L) {
|
|||||||
|
|
||||||
static int dagame_cleanup(lua_State *L) {
|
static int dagame_cleanup(lua_State *L) {
|
||||||
luaapi_cleanup();
|
luaapi_cleanup();
|
||||||
LuaapiCamFocus = false;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,7 +1652,7 @@ static int dagame_mdl(lua_State *L) {
|
|||||||
vertexCount = lua_tointeger(L, -1) / 3;
|
vertexCount = lua_tointeger(L, -1) / 3;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
positions = malloc(sizeof(*positions) * vertexCount);
|
positions = calloc(vertexCount, sizeof(*positions));
|
||||||
|
|
||||||
for(size_t i = 0; i < vertexCount; i++) {
|
for(size_t i = 0; i < vertexCount; i++) {
|
||||||
lua_geti(L, -1, i * 3 + 1);
|
lua_geti(L, -1, i * 3 + 1);
|
||||||
@ -1615,7 +1670,7 @@ static int dagame_mdl(lua_State *L) {
|
|||||||
indexCount = lua_tointeger(L, -1);
|
indexCount = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
indices = malloc(sizeof(*indices) * indexCount);
|
indices = calloc(indexCount, sizeof(*indices));
|
||||||
|
|
||||||
for(size_t i = 0; i < indexCount; i++) {
|
for(size_t i = 0; i < indexCount; i++) {
|
||||||
lua_geti(L, -1, i + 1);
|
lua_geti(L, -1, i + 1);
|
||||||
@ -1637,7 +1692,7 @@ static int dagame_mdl(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
normals = malloc(sizeof(*normals) * 3 * vertexCount);
|
normals = calloc(vertexCount, sizeof(*normals) * 3);
|
||||||
|
|
||||||
for(size_t i = 0; i < vertexCount; i++) {
|
for(size_t i = 0; i < vertexCount; i++) {
|
||||||
lua_geti(L, -1, i * 3 + 1);
|
lua_geti(L, -1, i * 3 + 1);
|
||||||
@ -1660,7 +1715,7 @@ static int dagame_mdl(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uvs = malloc(sizeof(*uvs) * vertexCount);
|
uvs = calloc(vertexCount, sizeof(*uvs));
|
||||||
|
|
||||||
for(size_t i = 0; i < vertexCount; i++) {
|
for(size_t i = 0; i < vertexCount; i++) {
|
||||||
lua_geti(L, -1, i * 2 + 1);
|
lua_geti(L, -1, i * 2 + 1);
|
||||||
@ -1858,7 +1913,7 @@ static int dagame_draw(lua_State *L) {
|
|||||||
float b = lua_type(L, -2) == LUA_TNUMBER ? lua_tonumber(L, -2) : 1;
|
float b = lua_type(L, -2) == LUA_TNUMBER ? lua_tonumber(L, -2) : 1;
|
||||||
float a = lua_type(L, -1) == LUA_TNUMBER ? lua_tonumber(L, -1) : 1;
|
float a = lua_type(L, -1) == LUA_TNUMBER ? lua_tonumber(L, -1) : 1;
|
||||||
|
|
||||||
k3BatchAdd(tex, (struct k3RectF) {.x = sx, .y = sy, .w = sw, .h = sh}, (struct k3RectF) {.x = x, .y = y, .w = w, .h = h}, 0, (vec4) {r, g, b, a});
|
k3BatchAdd(tex, (struct k3RectF) {.x = sx, .y = sy, .w = sw, .h = sh}, (struct k3RectF) {.x = x, .y = y, .w = w, .h = h}, 0, (vec4) {r, g, b, a}, 0);
|
||||||
|
|
||||||
lua_pop(L, 13);
|
lua_pop(L, 13);
|
||||||
} else {
|
} else {
|
||||||
@ -2348,12 +2403,277 @@ static int dagame_mdl_desc_append(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include<GLFW/glfw3.h>
|
|
||||||
static int os_time(lua_State *L) {
|
static int os_time(lua_State *L) {
|
||||||
lua_pushnumber(L, glfwGetTime() - LuaapiStartTime);
|
lua_pushnumber(L, glfwGetTime() - LuaapiStartTime);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dagame_particle_system(lua_State *L) {
|
||||||
|
struct k3CPUQuadParticles *qp = calloc(1, sizeof(*qp));
|
||||||
|
qp->capacity = lua_tointeger(L, 1);
|
||||||
|
|
||||||
|
qp->origin[0] = 0;
|
||||||
|
qp->origin[1] = 0;
|
||||||
|
qp->origin[2] = 0;
|
||||||
|
|
||||||
|
qp->emissionEnabled = true;
|
||||||
|
qp->emissionRate = 100;
|
||||||
|
qp->emissionConeDirection[0] = 0;
|
||||||
|
qp->emissionConeDirection[1] = 1;
|
||||||
|
qp->emissionConeDirection[2] = 0;
|
||||||
|
qp->emissionConeAngle = M_PI / 2;
|
||||||
|
qp->gravity[0] = 0;
|
||||||
|
qp->gravity[1] = 0.03;
|
||||||
|
qp->gravity[2] = 0;
|
||||||
|
qp->particleLifetime = 4;
|
||||||
|
|
||||||
|
qp->colorStart[0] = 1;
|
||||||
|
qp->colorStart[1] = 1;
|
||||||
|
qp->colorStart[2] = 1;
|
||||||
|
qp->colorStart[3] = 1;
|
||||||
|
|
||||||
|
qp->colorEnd[0] = 1;
|
||||||
|
qp->colorEnd[1] = 1;
|
||||||
|
qp->colorEnd[2] = 1;
|
||||||
|
qp->colorEnd[3] = 0;
|
||||||
|
|
||||||
|
struct k3Mat *mat = *(struct k3Mat**) lua_touserdata(L, 2);
|
||||||
|
/*struct k3Mat mat = {
|
||||||
|
.primitive = {
|
||||||
|
.diffuse = {1, 1, 1, 1},
|
||||||
|
.specular = {0, 0, 0, 0},
|
||||||
|
.emission = {0, 0, 0, 0},
|
||||||
|
.shininess = 16,
|
||||||
|
},
|
||||||
|
.passes = {
|
||||||
|
{
|
||||||
|
.unitsUsed = 0,
|
||||||
|
.aabb = NAN,
|
||||||
|
.transparent = true,
|
||||||
|
.nocull = false,
|
||||||
|
.alphatest = false,
|
||||||
|
.depthwrite = false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};*/
|
||||||
|
|
||||||
|
k3CPUQuadParticlesInit(qp, mat);
|
||||||
|
|
||||||
|
void **z = lua_newuserdata(L, sizeof(*z));
|
||||||
|
*z = qp;
|
||||||
|
luaL_setmetatable(L, "k3cpuparticles");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_k3cpuparticles_update(lua_State *L) {
|
||||||
|
struct k3CPUQuadParticles *qp = *(void**) lua_touserdata(L, 1);
|
||||||
|
k3CPUQuadParticlesUpdate(qp, lua_tonumber(L, 2), &LuaapiCamMatrix[0], &LuaapiCamMatrix[1], &LuaapiCamMatrix[2]);
|
||||||
|
lua_pushvalue(L, 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_k3cpuparticles_set(lua_State *L) {
|
||||||
|
struct k3CPUQuadParticles *qp = *(void**) lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
const char *key = lua_tostring(L, 2);
|
||||||
|
|
||||||
|
if(!strcmp(key, "origin")) {
|
||||||
|
lua_geti(L, 3, 1);
|
||||||
|
lua_geti(L, 3, 2);
|
||||||
|
lua_geti(L, 3, 3);
|
||||||
|
qp->origin[0] = lua_tonumber(L, -3);
|
||||||
|
qp->origin[1] = lua_tonumber(L, -2);
|
||||||
|
qp->origin[2] = lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 3);
|
||||||
|
} else if(!strcmp(key, "enabled")) {
|
||||||
|
qp->emissionEnabled = lua_toboolean(L, 3);
|
||||||
|
} else if(!strcmp(key, "rate")) {
|
||||||
|
qp->emissionRate = lua_tonumber(L, 3);
|
||||||
|
} else if(!strcmp(key, "cone_direction")) {
|
||||||
|
lua_geti(L, 3, 1);
|
||||||
|
lua_geti(L, 3, 2);
|
||||||
|
lua_geti(L, 3, 3);
|
||||||
|
qp->emissionConeDirection[0] = lua_tonumber(L, -3);
|
||||||
|
qp->emissionConeDirection[1] = lua_tonumber(L, -2);
|
||||||
|
qp->emissionConeDirection[2] = lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 3);
|
||||||
|
} else if(!strcmp(key, "cone_angle")) {
|
||||||
|
qp->emissionConeAngle = lua_tonumber(L, 3);
|
||||||
|
} else if(!strcmp(key, "gravity")) {
|
||||||
|
lua_geti(L, 3, 1);
|
||||||
|
lua_geti(L, 3, 2);
|
||||||
|
lua_geti(L, 3, 3);
|
||||||
|
qp->gravity[0] = lua_tonumber(L, -3);
|
||||||
|
qp->gravity[1] = lua_tonumber(L, -2);
|
||||||
|
qp->gravity[2] = lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 3);
|
||||||
|
} else if(!strcmp(key, "lifetime")) {
|
||||||
|
qp->particleLifetime = lua_tonumber(L, 3);
|
||||||
|
} else if(!strcmp(key, "remaining")) {
|
||||||
|
qp->emissionLifetime = lua_tonumber(L, 3);
|
||||||
|
} else if(!strcmp(key, "color_start")) {
|
||||||
|
lua_geti(L, 3, 1);
|
||||||
|
lua_geti(L, 3, 2);
|
||||||
|
lua_geti(L, 3, 3);
|
||||||
|
lua_geti(L, 3, 4);
|
||||||
|
qp->colorStart[0] = lua_tonumber(L, -4);
|
||||||
|
qp->colorStart[1] = lua_tonumber(L, -3);
|
||||||
|
qp->colorStart[2] = lua_tonumber(L, -2);
|
||||||
|
qp->colorStart[3] = lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 4);
|
||||||
|
} else if(!strcmp(key, "color_end")) {
|
||||||
|
lua_geti(L, 3, 1);
|
||||||
|
lua_geti(L, 3, 2);
|
||||||
|
lua_geti(L, 3, 3);
|
||||||
|
lua_geti(L, 3, 4);
|
||||||
|
qp->colorEnd[0] = lua_tonumber(L, -4);
|
||||||
|
qp->colorEnd[1] = lua_tonumber(L, -3);
|
||||||
|
qp->colorEnd[2] = lua_tonumber(L, -2);
|
||||||
|
qp->colorEnd[3] = lua_tonumber(L, -1);
|
||||||
|
lua_pop(L, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_k3cpuparticles_get(lua_State *L) {
|
||||||
|
struct k3CPUQuadParticles *qp = *(void**) lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
const char *key = lua_tostring(L, 2);
|
||||||
|
|
||||||
|
if(!strcmp(key, "update")) {
|
||||||
|
lua_pushcfunction(L, dagame_k3cpuparticles_update);
|
||||||
|
return 1;
|
||||||
|
} else if(!strcmp(key, "remaining")) {
|
||||||
|
lua_pushnumber(L, qp->emissionLifetime);
|
||||||
|
return 1;
|
||||||
|
} else if(!strcmp(key, "count")) {
|
||||||
|
lua_pushinteger(L, qp->count);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include"noise1234.h"
|
||||||
|
static int dagame_perlin3(lua_State *L) {
|
||||||
|
lua_pushnumber(L, noise3(lua_tonumber(L, 1), lua_tonumber(L, 2), lua_tonumber(L, 3)));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_fbm(lua_State *L) {
|
||||||
|
float x = lua_tonumber(L, 1);
|
||||||
|
float y = lua_tonumber(L, 2);
|
||||||
|
float z = lua_tonumber(L, 3);
|
||||||
|
int octaves = lua_type(L, 4) == LUA_TNIL ? 8 : lua_tointeger(L, 4);
|
||||||
|
float lacunarity = lua_type(L, 5) == LUA_TNIL ? 2 : lua_tonumber(L, 5);
|
||||||
|
float gain = lua_type(L, 6) == LUA_TNIL ? 0.5 : lua_tonumber(L, 6);
|
||||||
|
float sum = 0;
|
||||||
|
float freq = 1;
|
||||||
|
float amp = 1;
|
||||||
|
for(int o = 0; o < octaves; o++) {
|
||||||
|
sum += amp * noise3(x * freq, y * freq, z * freq);
|
||||||
|
amp *= gain;
|
||||||
|
freq *= lacunarity;
|
||||||
|
}
|
||||||
|
lua_pushnumber(L, sum);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_kill(lua_State *L) {
|
||||||
|
if(lua_type(L, 1) != LUA_TNUMBER) {
|
||||||
|
return luaL_error(L, "Invalid entity ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
game_killentity(lua_tointeger(L, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_animator(lua_State *L) {
|
||||||
|
struct Animator *this = lua_newuserdata(L, sizeof(*this));
|
||||||
|
|
||||||
|
this->mdl = *(struct k3Mdl**) lua_touserdata(L, 1);
|
||||||
|
memset(&this->animator, 0, sizeof(this->animator));
|
||||||
|
|
||||||
|
size_t boneCount = k3MdlGetBoneCount(this->mdl);
|
||||||
|
this->bones = _mm_malloc(boneCount * sizeof(*this->bones), 16);
|
||||||
|
for(size_t b = 0; b < boneCount; b++) {
|
||||||
|
this->bones[b].translation[0] = 0;
|
||||||
|
this->bones[b].translation[1] = 0;
|
||||||
|
this->bones[b].translation[2] = 0;
|
||||||
|
this->bones[b].translation[3] = 1;
|
||||||
|
|
||||||
|
this->bones[b].rotation[0] = 0;
|
||||||
|
this->bones[b].rotation[1] = 0;
|
||||||
|
this->bones[b].rotation[2] = 0;
|
||||||
|
this->bones[b].rotation[3] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
luaL_setmetatable(L, "k4animator");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_animator_set(lua_State *L) {
|
||||||
|
struct Animator *this = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
size_t animIdx = lua_tointeger(L, 2);
|
||||||
|
|
||||||
|
this->animator.base = k3MdlGetAnim(this->mdl, animIdx);
|
||||||
|
this->animator.loop = false;
|
||||||
|
|
||||||
|
this->playStartTime = glfwGetTime();
|
||||||
|
k3AnimatorSet(&this->animator, 0);
|
||||||
|
|
||||||
|
lua_pushvalue(L, 1);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_animator_play(lua_State *L) {
|
||||||
|
struct Animator *this = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
this->playing = true;
|
||||||
|
this->playStartTime = glfwGetTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_animator_index(lua_State *L) {
|
||||||
|
struct Animator *this = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
const char *key = lua_tostring(L, 2);
|
||||||
|
|
||||||
|
if(!strcmp(key, "set")) {
|
||||||
|
lua_pushcfunction(L, dagame_animator_set);
|
||||||
|
return 1;
|
||||||
|
} else if(!strcmp(key, "play")) {
|
||||||
|
lua_pushcfunction(L, dagame_animator_play);
|
||||||
|
return 1;
|
||||||
|
} else if(!strcmp(key, "time")) {
|
||||||
|
lua_pushnumber(L, this->animator.time);
|
||||||
|
return 1;
|
||||||
|
} else if(!strcmp(key, "loop")) {
|
||||||
|
lua_pushboolean(L, this->animator.loop);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dagame_animator_newindex(lua_State *L) {
|
||||||
|
struct Animator *this = lua_touserdata(L, 1);
|
||||||
|
|
||||||
|
const char *key = lua_tostring(L, 2);
|
||||||
|
|
||||||
|
if(!strcmp(key, "time")) {
|
||||||
|
k3AnimatorSet(&this->animator, lua_tonumber(L, 3));
|
||||||
|
} else if(!strcmp(key, "loop")) {
|
||||||
|
this->animator.loop = lua_toboolean(L, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void luaapi_init() {
|
void luaapi_init() {
|
||||||
k3Log(k3_DEBUG, "Creating Lua environment");
|
k3Log(k3_DEBUG, "Creating Lua environment");
|
||||||
|
|
||||||
@ -2496,6 +2816,21 @@ void luaapi_init() {
|
|||||||
lua_pushcfunction(L, dagame_set_texture_reduction);
|
lua_pushcfunction(L, dagame_set_texture_reduction);
|
||||||
lua_setfield(L, -2, "set_texture_reduction");
|
lua_setfield(L, -2, "set_texture_reduction");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_particle_system);
|
||||||
|
lua_setfield(L, -2, "particle_system");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_perlin3);
|
||||||
|
lua_setfield(L, -2, "perlin3");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_fbm);
|
||||||
|
lua_setfield(L, -2, "fbm3");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_kill);
|
||||||
|
lua_setfield(L, -2, "kill");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_animator);
|
||||||
|
lua_setfield(L, -2, "animator");
|
||||||
|
|
||||||
k3Log(k3_DEBUG, "Creating table game.ui");
|
k3Log(k3_DEBUG, "Creating table game.ui");
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushcfunction(L, dagame_ui_screen);
|
lua_pushcfunction(L, dagame_ui_screen);
|
||||||
@ -2753,6 +3088,28 @@ void luaapi_init() {
|
|||||||
lua_pushcfunction(L, os_time);
|
lua_pushcfunction(L, os_time);
|
||||||
lua_setfield(L, -2, "time");
|
lua_setfield(L, -2, "time");
|
||||||
lua_setglobal(L, "os");
|
lua_setglobal(L, "os");
|
||||||
|
|
||||||
|
luaL_newmetatable(L, "k3cpuparticles");
|
||||||
|
lua_pushcfunction(L, dagame_k3cpuparticles_set);
|
||||||
|
lua_setfield(L, -2, "__newindex");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_k3cpuparticles_get);
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
|
lua_pushboolean(L, 0);
|
||||||
|
lua_setfield(L, -2, "__metatable");
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
luaL_newmetatable(L, "k4animator");
|
||||||
|
lua_pushcfunction(L, dagame_animator_index);
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, dagame_animator_newindex);
|
||||||
|
lua_setfield(L, -2, "__newindex");
|
||||||
|
|
||||||
|
lua_pushboolean(L, 0);
|
||||||
|
lua_setfield(L, -2, "__metatable");
|
||||||
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void luaapi_load(const char *name) {
|
void luaapi_load(const char *name) {
|
||||||
@ -3211,6 +3568,10 @@ void luaapi_fillmaterial_direct(struct k3Mat *mat) {
|
|||||||
mat->passes[0].alphatest = lua_toboolean(L, -1);
|
mat->passes[0].alphatest = lua_toboolean(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_getfield(L, -1, "depthwrite");
|
||||||
|
mat->passes[0].depthwrite = lua_isnil(L, -1) ? true : lua_toboolean(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
lua_getfield(L, -1, "aabb");
|
lua_getfield(L, -1, "aabb");
|
||||||
mat->passes[0].aabb = lua_isnil(L, -1) ? NAN : lua_tonumber(L, -1);
|
mat->passes[0].aabb = lua_isnil(L, -1) ? NAN : lua_tonumber(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
@ -3417,6 +3778,9 @@ struct k3Light *luaapi_getlights(size_t *count) {
|
|||||||
ret[i].dir.direction[3] = lua_tonumber(L, -1);
|
ret[i].dir.direction[3] = lua_tonumber(L, -1);
|
||||||
glm_vec3_normalize(ret[i].dir.direction);
|
glm_vec3_normalize(ret[i].dir.direction);
|
||||||
lua_pop(L, 5);
|
lua_pop(L, 5);
|
||||||
|
lua_getfield(L, -1, "cascades");
|
||||||
|
ret[i].dir.cascadeCount = lua_tointeger(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
@ -3428,6 +3792,8 @@ struct k3Light *luaapi_getlights(size_t *count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void luaapi_cleanup() {
|
void luaapi_cleanup() {
|
||||||
|
LuaapiCamFocus = false;
|
||||||
|
|
||||||
game_cleanup();
|
game_cleanup();
|
||||||
|
|
||||||
lua_getglobal(L, "game");
|
lua_getglobal(L, "game");
|
||||||
|
116
src/main.c
116
src/main.c
@ -46,6 +46,7 @@ static int TextureResolutionReduction = 0;
|
|||||||
|
|
||||||
static int IrregularShadows = 0;
|
static int IrregularShadows = 0;
|
||||||
|
|
||||||
|
static int InstantCamShift = 5;
|
||||||
static float CamPitch, CamYaw;
|
static float CamPitch, CamYaw;
|
||||||
static vec3 CamPos;
|
static vec3 CamPos;
|
||||||
static int ThirdPerson = 1;
|
static int ThirdPerson = 1;
|
||||||
@ -169,8 +170,10 @@ static void charcallback(GLFWwindow *window, unsigned int codepoint) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fix_resol();
|
||||||
static void resizecallback(GLFWwindow *window, int width, int height) {
|
static void resizecallback(GLFWwindow *window, int width, int height) {
|
||||||
k3Resize(width, height);
|
k3Resize(width, height);
|
||||||
|
fix_resol();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int argc;
|
static int argc;
|
||||||
@ -184,86 +187,6 @@ const char *k4_get_arg(const char *name) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void netwrap_step() {
|
|
||||||
if(NetWrap.stage && CurrentTime >= NetWrap.timeout) {
|
|
||||||
if(NetWrap.stage == 1) {
|
|
||||||
if(stoon_req(&NetWrap.stoon)) {
|
|
||||||
if(stoon_listen(&NetWrap.stoon)) {
|
|
||||||
uint8_t conndata[STOON_CONN_INFO_SIZE] = {};
|
|
||||||
stoon_serialize(&NetWrap.stoon, conndata);
|
|
||||||
|
|
||||||
char str[STOON_CONN_INFO_SIZE * 2 + 1] = {};
|
|
||||||
for(int i = 0; i < sizeof(conndata); i++) {
|
|
||||||
snprintf(str + i * 2, 3, "%02x", conndata[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
luaapi_peercode_found(str);
|
|
||||||
|
|
||||||
NetWrap.stage = 2;
|
|
||||||
} else {
|
|
||||||
k3Log(k3_INFO, "Stoon listen timeout.");
|
|
||||||
NetWrap.timeout = CurrentTime + 0.5;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
k3Log(k3_INFO, "Stoon request failed.");
|
|
||||||
NetWrap.timeout = CurrentTime + 0.5;
|
|
||||||
}
|
|
||||||
} else if(NetWrap.stage == 2) {
|
|
||||||
stoon_keepalive(&NetWrap.stoon);
|
|
||||||
NetWrap.timeout = CurrentTime + 1;
|
|
||||||
} else if(NetWrap.stage == 3) {
|
|
||||||
if(NetWrap.isHost) {
|
|
||||||
stoon_kill(&NetWrap.stoon);
|
|
||||||
net_server_init();
|
|
||||||
NetWrap.stage = 4;
|
|
||||||
}
|
|
||||||
} else if(NetWrap.stage == 4) {
|
|
||||||
if(NetWrap.isHost) {
|
|
||||||
ENetBuffer buf = {.data = "Punch!", .dataLength = 6};
|
|
||||||
|
|
||||||
ENetHost *h = net_server_get_enethost();
|
|
||||||
|
|
||||||
for(size_t i = 0; i < NETWRAP_BACKLOG; i++) {
|
|
||||||
if(NetWrap.otherpeersActive[i]) {
|
|
||||||
ENetAddress v4 = {}, v6 = {};
|
|
||||||
stoonpeer_to_enets(NetWrap.otherpeers[i], &v4, &v6);
|
|
||||||
|
|
||||||
enet_socket_send(h->socket, &v4, &buf, 1);
|
|
||||||
enet_socket_send(h->socket, &v6, &buf, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stoon_keepalive(&NetWrap.stoon);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetWrap.timeout = CurrentTime + 1;
|
|
||||||
} else if(NetWrap.stage == 5) {
|
|
||||||
if(!NetWrap.isHost) {
|
|
||||||
char ip[64];
|
|
||||||
int port;
|
|
||||||
if(*(uint16_t*) (NetWrap.otherpeer + 22) == 0) {
|
|
||||||
inet_ntop(AF_INET, NetWrap.otherpeer, ip, sizeof(ip));
|
|
||||||
port = ntohs(*(uint16_t*) (NetWrap.otherpeer + 4));
|
|
||||||
} else {
|
|
||||||
inet_ntop(AF_INET6, NetWrap.otherpeer + 6, ip, sizeof(ip));
|
|
||||||
port = ntohs(*(uint16_t*) (NetWrap.otherpeer + 22));
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Trying [%s]:%u\n", ip, port);
|
|
||||||
|
|
||||||
net_client_init();
|
|
||||||
if(net_client_connect(ip, port)) {
|
|
||||||
NetWrap.stage = 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NetWrap.timeout = CurrentTime + 0.5;
|
|
||||||
} else {
|
|
||||||
NetWrap.timeout = CurrentTime + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
#include<signal.h>
|
#include<signal.h>
|
||||||
void k4k3LogCallback(enum k3LogLevel lvl, const char *str, size_t len) {
|
void k4k3LogCallback(enum k3LogLevel lvl, const char *str, size_t len) {
|
||||||
static const char *prefixes[] = {
|
static const char *prefixes[] = {
|
||||||
@ -459,26 +382,12 @@ static int gr_lowres(int newW, int newH) {
|
|||||||
}
|
}
|
||||||
k3TexUpdate(lowresDepth, k3_DEPTH, 0, newW, newH, NULL);
|
k3TexUpdate(lowresDepth, k3_DEPTH, 0, newW, newH, NULL);
|
||||||
|
|
||||||
lowresOffscreen = k3OffscreenCreate(lowres, lowresDepth);
|
lowresOffscreen = k3OffscreenCreateMultisampled(lowres, lowresDepth, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!lowresOffscreen;
|
return !!lowresOffscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_RAYS 64
|
|
||||||
static struct LocalRay RaysToCast[MAX_RAYS];
|
|
||||||
static size_t RaysToCastCount = 0;
|
|
||||||
|
|
||||||
struct LocalRay *request_ray(struct LocalRay *lr) {
|
|
||||||
if(RaysToCastCount == MAX_RAYS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(RaysToCast + RaysToCastCount, lr, sizeof(*lr));
|
|
||||||
|
|
||||||
return &RaysToCast[RaysToCastCount++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc_, char **argv_) {
|
int main(int argc_, char **argv_) {
|
||||||
argc = argc_;
|
argc = argc_;
|
||||||
argv = argv_;
|
argv = argv_;
|
||||||
@ -557,9 +466,6 @@ int main(int argc_, char **argv_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game_raycast(RaysToCast, RaysToCastCount);
|
|
||||||
RaysToCastCount = 0;
|
|
||||||
|
|
||||||
while(accumulator >= 1. / GAME_TPS) {
|
while(accumulator >= 1. / GAME_TPS) {
|
||||||
for(size_t i = 0; i < Game.entities.renderCount; i++) {
|
for(size_t i = 0; i < Game.entities.renderCount; i++) {
|
||||||
glm_vec4_copy(Game.entities.render[i].pos, Game.entities.render[i].posLast);
|
glm_vec4_copy(Game.entities.render[i].pos, Game.entities.render[i].posLast);
|
||||||
@ -586,10 +492,10 @@ int main(int argc_, char **argv_) {
|
|||||||
glfwGetFramebufferSize(GameWnd, &width, &height);
|
glfwGetFramebufferSize(GameWnd, &width, &height);
|
||||||
|
|
||||||
mat4 proj;
|
mat4 proj;
|
||||||
glm_perspective(glm_rad(LuaapiFov), (float) width / height, 0.01f, 100.f, proj);
|
glm_perspective(glm_rad(LuaapiFov), (float) width / height, 0.1f, 80.f, proj);
|
||||||
|
|
||||||
/* Third-person camera movement */
|
/* Third-person camera movement */
|
||||||
struct LocalRay camray;
|
struct LocalRay camray = {};
|
||||||
if(Game.spectated != ENT_ID_INVALID) {
|
if(Game.spectated != ENT_ID_INVALID) {
|
||||||
struct CRender *c = game_getcomponent(Game.spectated, render);
|
struct CRender *c = game_getcomponent(Game.spectated, render);
|
||||||
if(c) {
|
if(c) {
|
||||||
@ -610,6 +516,9 @@ int main(int argc_, char **argv_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat4 cam;
|
mat4 cam;
|
||||||
|
if(InstantCamShift) {
|
||||||
|
InstantCamShift--;
|
||||||
|
}
|
||||||
if(LuaapiFirstPerson) {
|
if(LuaapiFirstPerson) {
|
||||||
struct CRender *c = game_getcomponent(Game.spectated, render);
|
struct CRender *c = game_getcomponent(Game.spectated, render);
|
||||||
|
|
||||||
@ -628,10 +537,15 @@ int main(int argc_, char **argv_) {
|
|||||||
vec3 almostThere;
|
vec3 almostThere;
|
||||||
|
|
||||||
if(LuaapiCamFocus) {
|
if(LuaapiCamFocus) {
|
||||||
|
float lerpa = InstantCamShift ? 1 : 0.1;
|
||||||
|
|
||||||
glm_vec3_copy(LuaapiCamFocusPos, almostThere);
|
glm_vec3_copy(LuaapiCamFocusPos, almostThere);
|
||||||
glm_vec3_lerp(CamPos, almostThere, 0.1, CamPos);
|
glm_vec3_lerp(CamPos, almostThere, 0.1, CamPos);
|
||||||
|
glm_vec3_copy(LuaapiCamFocusPos, CamPos);
|
||||||
glm_look(CamPos, LuaapiCamFocusDir, (vec3) {0, 1, 0}, cam);
|
glm_look(CamPos, LuaapiCamFocusDir, (vec3) {0, 1, 0}, cam);
|
||||||
} else {
|
} else {
|
||||||
|
float lerpa = InstantCamShift ? 1 : 0.2;
|
||||||
|
|
||||||
vec3 dirneg;
|
vec3 dirneg;
|
||||||
glm_vec3_negate_to(camray.dir, dirneg);
|
glm_vec3_negate_to(camray.dir, dirneg);
|
||||||
|
|
||||||
@ -745,7 +659,7 @@ int main(int argc_, char **argv_) {
|
|||||||
|
|
||||||
// Shadowmap debugging
|
// Shadowmap debugging
|
||||||
if(glfwGetKey(GameWnd, GLFW_KEY_F5) == GLFW_PRESS) {
|
if(glfwGetKey(GameWnd, GLFW_KEY_F5) == GLFW_PRESS) {
|
||||||
k3BlitToScreen(shadowmapOffscreen, 0);
|
k3BlitToScreenEffect(shadowmapOffscreen, 0, k3_ARBFRAG, shadowmapDebugThing, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(GameWnd);
|
glfwSwapBuffers(GameWnd);
|
||||||
|
524
src/noise1234.c
Normal file
524
src/noise1234.c
Normal file
@ -0,0 +1,524 @@
|
|||||||
|
// noise1234
|
||||||
|
//
|
||||||
|
// Author: Stefan Gustavson, 2003-2005
|
||||||
|
// Contact: stefan.gustavson@liu.se
|
||||||
|
//
|
||||||
|
// This code was GPL licensed until February 2011.
|
||||||
|
// As the original author of this code, I hereby
|
||||||
|
// release it into the public domain.
|
||||||
|
// Please feel free to use it for whatever you want.
|
||||||
|
// Credit is appreciated where appropriate, and I also
|
||||||
|
// appreciate being told where this code finds any use,
|
||||||
|
// but you may do as you like.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This implementation is "Improved Noise" as presented by
|
||||||
|
* Ken Perlin at Siggraph 2002. The 3D function is a direct port
|
||||||
|
* of his Java reference code which was once publicly available
|
||||||
|
* on www.noisemachine.com (although I cleaned it up, made it
|
||||||
|
* faster and made the code more readable), but the 1D, 2D and
|
||||||
|
* 4D functions were implemented from scratch by me.
|
||||||
|
*
|
||||||
|
* This is a backport to C of my improved noise class in C++
|
||||||
|
* which was included in the Aqsis renderer project.
|
||||||
|
* It is highly reusable without source code modifications.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "noise1234.h"
|
||||||
|
|
||||||
|
// This is the new and improved, C(2) continuous interpolant
|
||||||
|
#define FADE(t) ( t * t * t * ( t * ( t * 6 - 15 ) + 10 ) )
|
||||||
|
|
||||||
|
#define FASTFLOOR(x) ( ((int)(x)<(x)) ? ((int)x) : ((int)x-1 ) )
|
||||||
|
#define LERP(t, a, b) ((a) + (t)*((b)-(a)))
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Static data
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Permutation table. This is just a random jumble of all numbers 0-255,
|
||||||
|
* repeated twice to avoid wrapping the index at 255 for each lookup.
|
||||||
|
* This needs to be exactly the same for all instances on all platforms,
|
||||||
|
* so it's easiest to just keep it as static explicit data.
|
||||||
|
* This also removes the need for any initialisation of this class.
|
||||||
|
*
|
||||||
|
* Note that making this an int[] instead of a char[] might make the
|
||||||
|
* code run faster on platforms with a high penalty for unaligned single
|
||||||
|
* byte addressing. Intel x86 is generally single-byte-friendly, but
|
||||||
|
* some other CPUs are faster with 4-aligned reads.
|
||||||
|
* However, a char[] is smaller, which avoids cache trashing, and that
|
||||||
|
* is probably the most important aspect on most architectures.
|
||||||
|
* This array is accessed a *lot* by the noise functions.
|
||||||
|
* A vector-valued noise over 3D accesses it 96 times, and a
|
||||||
|
* float-valued 4D noise 64 times. We want this to fit in the cache!
|
||||||
|
*/
|
||||||
|
unsigned char perm[] = {151,160,137,91,90,15,
|
||||||
|
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
|
||||||
|
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
|
||||||
|
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
|
||||||
|
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
|
||||||
|
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
|
||||||
|
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
|
||||||
|
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
|
||||||
|
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
|
||||||
|
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
|
||||||
|
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
|
||||||
|
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
|
||||||
|
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,
|
||||||
|
151,160,137,91,90,15,
|
||||||
|
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
|
||||||
|
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
|
||||||
|
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
|
||||||
|
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
|
||||||
|
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
|
||||||
|
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
|
||||||
|
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
|
||||||
|
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
|
||||||
|
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
|
||||||
|
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
|
||||||
|
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
|
||||||
|
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
|
||||||
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper functions to compute gradients-dot-residualvectors (1D to 4D)
|
||||||
|
* Note that these generate gradients of more than unit length. To make
|
||||||
|
* a close match with the value range of classic Perlin noise, the final
|
||||||
|
* noise values need to be rescaled. To match the RenderMan noise in a
|
||||||
|
* statistical sense, the approximate scaling values (empirically
|
||||||
|
* determined from test renderings) are:
|
||||||
|
* 1D noise needs rescaling with 0.188
|
||||||
|
* 2D noise needs rescaling with 0.507
|
||||||
|
* 3D noise needs rescaling with 0.936
|
||||||
|
* 4D noise needs rescaling with 0.87
|
||||||
|
* Note that these noise functions are the most practical and useful
|
||||||
|
* signed version of Perlin noise. To return values according to the
|
||||||
|
* RenderMan specification from the SL noise() and pnoise() functions,
|
||||||
|
* the noise values need to be scaled and offset to [0,1], like this:
|
||||||
|
* float SLnoise = (noise3(x,y,z) + 1.0) * 0.5;
|
||||||
|
*/
|
||||||
|
|
||||||
|
float grad1( int hash, float x ) {
|
||||||
|
int h = hash & 15;
|
||||||
|
float grad = 1.0 + (h & 7); // Gradient value 1.0, 2.0, ..., 8.0
|
||||||
|
if (h&8) grad = -grad; // and a random sign for the gradient
|
||||||
|
return ( grad * x ); // Multiply the gradient with the distance
|
||||||
|
}
|
||||||
|
|
||||||
|
float grad2( int hash, float x, float y ) {
|
||||||
|
int h = hash & 7; // Convert low 3 bits of hash code
|
||||||
|
float u = h<4 ? x : y; // into 8 simple gradient directions,
|
||||||
|
float v = h<4 ? y : x; // and compute the dot product with (x,y).
|
||||||
|
return ((h&1)? -u : u) + ((h&2)? -2.0*v : 2.0*v);
|
||||||
|
}
|
||||||
|
|
||||||
|
float grad3( int hash, float x, float y , float z ) {
|
||||||
|
int h = hash & 15; // Convert low 4 bits of hash code into 12 simple
|
||||||
|
float u = h<8 ? x : y; // gradient directions, and compute dot product.
|
||||||
|
float v = h<4 ? y : h==12||h==14 ? x : z; // Fix repeats at h = 12 to 15
|
||||||
|
return ((h&1)? -u : u) + ((h&2)? -v : v);
|
||||||
|
}
|
||||||
|
|
||||||
|
float grad4( int hash, float x, float y, float z, float t ) {
|
||||||
|
int h = hash & 31; // Convert low 5 bits of hash code into 32 simple
|
||||||
|
float u = h<24 ? x : y; // gradient directions, and compute dot product.
|
||||||
|
float v = h<16 ? y : z;
|
||||||
|
float w = h<8 ? z : t;
|
||||||
|
return ((h&1)? -u : u) + ((h&2)? -v : v) + ((h&4)? -w : w);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 1D float Perlin noise, SL "noise()"
|
||||||
|
*/
|
||||||
|
float noise1( float x )
|
||||||
|
{
|
||||||
|
int ix0, ix1;
|
||||||
|
float fx0, fx1;
|
||||||
|
float s, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
ix1 = ( ix0+1 ) & 0xff;
|
||||||
|
ix0 = ix0 & 0xff; // Wrap to 0..255
|
||||||
|
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
n0 = grad1( perm[ ix0 ], fx0 );
|
||||||
|
n1 = grad1( perm[ ix1 ], fx1 );
|
||||||
|
return 0.188f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 1D float Perlin periodic noise, SL "pnoise()"
|
||||||
|
*/
|
||||||
|
float pnoise1( float x, int px )
|
||||||
|
{
|
||||||
|
int ix0, ix1;
|
||||||
|
float fx0, fx1;
|
||||||
|
float s, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
ix1 = (( ix0 + 1 ) % px) & 0xff; // Wrap to 0..px-1 *and* wrap to 0..255
|
||||||
|
ix0 = ( ix0 % px ) & 0xff; // (because px might be greater than 256)
|
||||||
|
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
n0 = grad1( perm[ ix0 ], fx0 );
|
||||||
|
n1 = grad1( perm[ ix1 ], fx1 );
|
||||||
|
return 0.188f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 2D float Perlin noise.
|
||||||
|
*/
|
||||||
|
float noise2( float x, float y )
|
||||||
|
{
|
||||||
|
int ix0, iy0, ix1, iy1;
|
||||||
|
float fx0, fy0, fx1, fy1;
|
||||||
|
float s, t, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
ix1 = (ix0 + 1) & 0xff; // Wrap to 0..255
|
||||||
|
iy1 = (iy0 + 1) & 0xff;
|
||||||
|
ix0 = ix0 & 0xff;
|
||||||
|
iy0 = iy0 & 0xff;
|
||||||
|
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nx0 = grad2(perm[ix0 + perm[iy0]], fx0, fy0);
|
||||||
|
nx1 = grad2(perm[ix0 + perm[iy1]], fx0, fy1);
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nx0 = grad2(perm[ix1 + perm[iy0]], fx1, fy0);
|
||||||
|
nx1 = grad2(perm[ix1 + perm[iy1]], fx1, fy1);
|
||||||
|
n1 = LERP(t, nx0, nx1);
|
||||||
|
|
||||||
|
return 0.507f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 2D float Perlin periodic noise.
|
||||||
|
*/
|
||||||
|
float pnoise2( float x, float y, int px, int py )
|
||||||
|
{
|
||||||
|
int ix0, iy0, ix1, iy1;
|
||||||
|
float fx0, fy0, fx1, fy1;
|
||||||
|
float s, t, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
ix1 = (( ix0 + 1 ) % px) & 0xff; // Wrap to 0..px-1 and wrap to 0..255
|
||||||
|
iy1 = (( iy0 + 1 ) % py) & 0xff; // Wrap to 0..py-1 and wrap to 0..255
|
||||||
|
ix0 = ( ix0 % px ) & 0xff;
|
||||||
|
iy0 = ( iy0 % py ) & 0xff;
|
||||||
|
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nx0 = grad2(perm[ix0 + perm[iy0]], fx0, fy0);
|
||||||
|
nx1 = grad2(perm[ix0 + perm[iy1]], fx0, fy1);
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nx0 = grad2(perm[ix1 + perm[iy0]], fx1, fy0);
|
||||||
|
nx1 = grad2(perm[ix1 + perm[iy1]], fx1, fy1);
|
||||||
|
n1 = LERP(t, nx0, nx1);
|
||||||
|
|
||||||
|
return 0.507f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 3D float Perlin noise.
|
||||||
|
*/
|
||||||
|
float noise3( float x, float y, float z )
|
||||||
|
{
|
||||||
|
int ix0, iy0, ix1, iy1, iz0, iz1;
|
||||||
|
float fx0, fy0, fz0, fx1, fy1, fz1;
|
||||||
|
float s, t, r;
|
||||||
|
float nxy0, nxy1, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
iz0 = FASTFLOOR( z ); // Integer part of z
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fz0 = z - iz0; // Fractional part of z
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
fz1 = fz0 - 1.0f;
|
||||||
|
ix1 = ( ix0 + 1 ) & 0xff; // Wrap to 0..255
|
||||||
|
iy1 = ( iy0 + 1 ) & 0xff;
|
||||||
|
iz1 = ( iz0 + 1 ) & 0xff;
|
||||||
|
ix0 = ix0 & 0xff;
|
||||||
|
iy0 = iy0 & 0xff;
|
||||||
|
iz0 = iz0 & 0xff;
|
||||||
|
|
||||||
|
r = FADE( fz0 );
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix0 + perm[iy0 + perm[iz0]]], fx0, fy0, fz0);
|
||||||
|
nxy1 = grad3(perm[ix0 + perm[iy0 + perm[iz1]]], fx0, fy0, fz1);
|
||||||
|
nx0 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix0 + perm[iy1 + perm[iz0]]], fx0, fy1, fz0);
|
||||||
|
nxy1 = grad3(perm[ix0 + perm[iy1 + perm[iz1]]], fx0, fy1, fz1);
|
||||||
|
nx1 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix1 + perm[iy0 + perm[iz0]]], fx1, fy0, fz0);
|
||||||
|
nxy1 = grad3(perm[ix1 + perm[iy0 + perm[iz1]]], fx1, fy0, fz1);
|
||||||
|
nx0 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix1 + perm[iy1 + perm[iz0]]], fx1, fy1, fz0);
|
||||||
|
nxy1 = grad3(perm[ix1 + perm[iy1 + perm[iz1]]], fx1, fy1, fz1);
|
||||||
|
nx1 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n1 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
return 0.936f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 3D float Perlin periodic noise.
|
||||||
|
*/
|
||||||
|
float pnoise3( float x, float y, float z, int px, int py, int pz )
|
||||||
|
{
|
||||||
|
int ix0, iy0, ix1, iy1, iz0, iz1;
|
||||||
|
float fx0, fy0, fz0, fx1, fy1, fz1;
|
||||||
|
float s, t, r;
|
||||||
|
float nxy0, nxy1, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
iz0 = FASTFLOOR( z ); // Integer part of z
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fz0 = z - iz0; // Fractional part of z
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
fz1 = fz0 - 1.0f;
|
||||||
|
ix1 = (( ix0 + 1 ) % px ) & 0xff; // Wrap to 0..px-1 and wrap to 0..255
|
||||||
|
iy1 = (( iy0 + 1 ) % py ) & 0xff; // Wrap to 0..py-1 and wrap to 0..255
|
||||||
|
iz1 = (( iz0 + 1 ) % pz ) & 0xff; // Wrap to 0..pz-1 and wrap to 0..255
|
||||||
|
ix0 = ( ix0 % px ) & 0xff;
|
||||||
|
iy0 = ( iy0 % py ) & 0xff;
|
||||||
|
iz0 = ( iz0 % pz ) & 0xff;
|
||||||
|
|
||||||
|
r = FADE( fz0 );
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix0 + perm[iy0 + perm[iz0]]], fx0, fy0, fz0);
|
||||||
|
nxy1 = grad3(perm[ix0 + perm[iy0 + perm[iz1]]], fx0, fy0, fz1);
|
||||||
|
nx0 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix0 + perm[iy1 + perm[iz0]]], fx0, fy1, fz0);
|
||||||
|
nxy1 = grad3(perm[ix0 + perm[iy1 + perm[iz1]]], fx0, fy1, fz1);
|
||||||
|
nx1 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix1 + perm[iy0 + perm[iz0]]], fx1, fy0, fz0);
|
||||||
|
nxy1 = grad3(perm[ix1 + perm[iy0 + perm[iz1]]], fx1, fy0, fz1);
|
||||||
|
nx0 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxy0 = grad3(perm[ix1 + perm[iy1 + perm[iz0]]], fx1, fy1, fz0);
|
||||||
|
nxy1 = grad3(perm[ix1 + perm[iy1 + perm[iz1]]], fx1, fy1, fz1);
|
||||||
|
nx1 = LERP( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n1 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
return 0.936f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 4D float Perlin noise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
float noise4( float x, float y, float z, float w )
|
||||||
|
{
|
||||||
|
int ix0, iy0, iz0, iw0, ix1, iy1, iz1, iw1;
|
||||||
|
float fx0, fy0, fz0, fw0, fx1, fy1, fz1, fw1;
|
||||||
|
float s, t, r, q;
|
||||||
|
float nxyz0, nxyz1, nxy0, nxy1, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
iz0 = FASTFLOOR( z ); // Integer part of y
|
||||||
|
iw0 = FASTFLOOR( w ); // Integer part of w
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fz0 = z - iz0; // Fractional part of z
|
||||||
|
fw0 = w - iw0; // Fractional part of w
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
fz1 = fz0 - 1.0f;
|
||||||
|
fw1 = fw0 - 1.0f;
|
||||||
|
ix1 = ( ix0 + 1 ) & 0xff; // Wrap to 0..255
|
||||||
|
iy1 = ( iy0 + 1 ) & 0xff;
|
||||||
|
iz1 = ( iz0 + 1 ) & 0xff;
|
||||||
|
iw1 = ( iw0 + 1 ) & 0xff;
|
||||||
|
ix0 = ix0 & 0xff;
|
||||||
|
iy0 = iy0 & 0xff;
|
||||||
|
iz0 = iz0 & 0xff;
|
||||||
|
iw0 = iw0 & 0xff;
|
||||||
|
|
||||||
|
q = FADE( fw0 );
|
||||||
|
r = FADE( fz0 );
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy0 + perm[iz0 + perm[iw0]]]], fx0, fy0, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy0 + perm[iz0 + perm[iw1]]]], fx0, fy0, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy0 + perm[iz1 + perm[iw0]]]], fx0, fy0, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy0 + perm[iz1 + perm[iw1]]]], fx0, fy0, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx0 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy1 + perm[iz0 + perm[iw0]]]], fx0, fy1, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy1 + perm[iz0 + perm[iw1]]]], fx0, fy1, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy1 + perm[iz1 + perm[iw0]]]], fx0, fy1, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy1 + perm[iz1 + perm[iw1]]]], fx0, fy1, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx1 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy0 + perm[iz0 + perm[iw0]]]], fx1, fy0, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy0 + perm[iz0 + perm[iw1]]]], fx1, fy0, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy0 + perm[iz1 + perm[iw0]]]], fx1, fy0, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy0 + perm[iz1 + perm[iw1]]]], fx1, fy0, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx0 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy1 + perm[iz0 + perm[iw0]]]], fx1, fy1, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy1 + perm[iz0 + perm[iw1]]]], fx1, fy1, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy1 + perm[iz1 + perm[iw0]]]], fx1, fy1, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy1 + perm[iz1 + perm[iw1]]]], fx1, fy1, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx1 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n1 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
return 0.87f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
/** 4D float Perlin periodic noise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
float pnoise4( float x, float y, float z, float w,
|
||||||
|
int px, int py, int pz, int pw )
|
||||||
|
{
|
||||||
|
int ix0, iy0, iz0, iw0, ix1, iy1, iz1, iw1;
|
||||||
|
float fx0, fy0, fz0, fw0, fx1, fy1, fz1, fw1;
|
||||||
|
float s, t, r, q;
|
||||||
|
float nxyz0, nxyz1, nxy0, nxy1, nx0, nx1, n0, n1;
|
||||||
|
|
||||||
|
ix0 = FASTFLOOR( x ); // Integer part of x
|
||||||
|
iy0 = FASTFLOOR( y ); // Integer part of y
|
||||||
|
iz0 = FASTFLOOR( z ); // Integer part of y
|
||||||
|
iw0 = FASTFLOOR( w ); // Integer part of w
|
||||||
|
fx0 = x - ix0; // Fractional part of x
|
||||||
|
fy0 = y - iy0; // Fractional part of y
|
||||||
|
fz0 = z - iz0; // Fractional part of z
|
||||||
|
fw0 = w - iw0; // Fractional part of w
|
||||||
|
fx1 = fx0 - 1.0f;
|
||||||
|
fy1 = fy0 - 1.0f;
|
||||||
|
fz1 = fz0 - 1.0f;
|
||||||
|
fw1 = fw0 - 1.0f;
|
||||||
|
ix1 = (( ix0 + 1 ) % px ) & 0xff; // Wrap to 0..px-1 and wrap to 0..255
|
||||||
|
iy1 = (( iy0 + 1 ) % py ) & 0xff; // Wrap to 0..py-1 and wrap to 0..255
|
||||||
|
iz1 = (( iz0 + 1 ) % pz ) & 0xff; // Wrap to 0..pz-1 and wrap to 0..255
|
||||||
|
iw1 = (( iw0 + 1 ) % pw ) & 0xff; // Wrap to 0..pw-1 and wrap to 0..255
|
||||||
|
ix0 = ( ix0 % px ) & 0xff;
|
||||||
|
iy0 = ( iy0 % py ) & 0xff;
|
||||||
|
iz0 = ( iz0 % pz ) & 0xff;
|
||||||
|
iw0 = ( iw0 % pw ) & 0xff;
|
||||||
|
|
||||||
|
q = FADE( fw0 );
|
||||||
|
r = FADE( fz0 );
|
||||||
|
t = FADE( fy0 );
|
||||||
|
s = FADE( fx0 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy0 + perm[iz0 + perm[iw0]]]], fx0, fy0, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy0 + perm[iz0 + perm[iw1]]]], fx0, fy0, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy0 + perm[iz1 + perm[iw0]]]], fx0, fy0, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy0 + perm[iz1 + perm[iw1]]]], fx0, fy0, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx0 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy1 + perm[iz0 + perm[iw0]]]], fx0, fy1, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy1 + perm[iz0 + perm[iw1]]]], fx0, fy1, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix0 + perm[iy1 + perm[iz1 + perm[iw0]]]], fx0, fy1, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix0 + perm[iy1 + perm[iz1 + perm[iw1]]]], fx0, fy1, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx1 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n0 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy0 + perm[iz0 + perm[iw0]]]], fx1, fy0, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy0 + perm[iz0 + perm[iw1]]]], fx1, fy0, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy0 + perm[iz1 + perm[iw0]]]], fx1, fy0, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy0 + perm[iz1 + perm[iw1]]]], fx1, fy0, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx0 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy1 + perm[iz0 + perm[iw0]]]], fx1, fy1, fz0, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy1 + perm[iz0 + perm[iw1]]]], fx1, fy1, fz0, fw1);
|
||||||
|
nxy0 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nxyz0 = grad4(perm[ix1 + perm[iy1 + perm[iz1 + perm[iw0]]]], fx1, fy1, fz1, fw0);
|
||||||
|
nxyz1 = grad4(perm[ix1 + perm[iy1 + perm[iz1 + perm[iw1]]]], fx1, fy1, fz1, fw1);
|
||||||
|
nxy1 = LERP( q, nxyz0, nxyz1 );
|
||||||
|
|
||||||
|
nx1 = LERP ( r, nxy0, nxy1 );
|
||||||
|
|
||||||
|
n1 = LERP( t, nx0, nx1 );
|
||||||
|
|
||||||
|
return 0.87f * ( LERP( s, n0, n1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
41
src/noise1234.h
Normal file
41
src/noise1234.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// noise1234
|
||||||
|
//
|
||||||
|
// Author: Stefan Gustavson, 2003-2005
|
||||||
|
// Contact: stefan.gustavson@liu.se
|
||||||
|
//
|
||||||
|
// This code was GPL licensed until February 2011.
|
||||||
|
// As the original author of this code, I hereby
|
||||||
|
// release it into the public domain.
|
||||||
|
// Please feel free to use it for whatever you want.
|
||||||
|
// Credit is appreciated where appropriate, and I also
|
||||||
|
// appreciate being told where this code finds any use,
|
||||||
|
// but you may do as you like.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This implementation is "Improved Noise" as presented by
|
||||||
|
* Ken Perlin at Siggraph 2002. The 3D function is a direct port
|
||||||
|
* of his Java reference code which was once publicly available
|
||||||
|
* on www.noisemachine.com (although I cleaned it up, made it
|
||||||
|
* faster and made the code more readable), but the 1D, 2D and
|
||||||
|
* 4D functions were implemented from scratch by me.
|
||||||
|
*
|
||||||
|
* This is a backport to C of my improved noise class in C++
|
||||||
|
* which was included in the Aqsis renderer project.
|
||||||
|
* It is highly reusable without source code modifications.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** 1D, 2D, 3D and 4D float Perlin noise
|
||||||
|
*/
|
||||||
|
extern float noise1( float x );
|
||||||
|
extern float noise2( float x, float y );
|
||||||
|
extern float noise3( float x, float y, float z );
|
||||||
|
extern float noise4( float x, float y, float z, float w );
|
||||||
|
|
||||||
|
/** 1D, 2D, 3D and 4D float Perlin periodic noise
|
||||||
|
*/
|
||||||
|
extern float pnoise1( float x, int px );
|
||||||
|
extern float pnoise2( float x, float y, int px, int py );
|
||||||
|
extern float pnoise3( float x, float y, float z, int px, int py, int pz );
|
||||||
|
extern float pnoise4( float x, float y, float z, float w,
|
||||||
|
int px, int py, int pz, int pw );
|
Loading…
Reference in New Issue
Block a user