mirror of
https://github.com/HomeworldSDL/HomeworldSDL.git
synced 2025-10-29 11:36:12 +00:00
feat: Add wasm32 (web browser) build 🎆
nix: update to emscripten 3.1.64 Remove use of legacy GL_PERSPECTIVE_CORRECTION_HINT Disable intro plugscreens for emscripten builds for now Use stored background color instead of glGetFloatv() call that is slow in emscripten due to wasm<>javascript context switch Co-authored-by: Thibault Lemaire <thibault.lemaire@protonmail.com>
This commit is contained in:
parent
edda6ec769
commit
38dda1fb92
@ -108,6 +108,8 @@ ln -srv compile_commands.json ..
|
||||
[LLVM's Sanitizers] are a powerful suite of tools for memory debugging.
|
||||
They can detect and help debug many kinds of invalid or dangerous memory handling patterns (like buffer overflows, use after free, or leaks).
|
||||
|
||||
[LLVM's Sanitizers]: https://clang.llvm.org/docs/AddressSanitizer.html
|
||||
|
||||
#### With Meson
|
||||
|
||||
The `address` and `undefined` sanitizers are enabled by default.
|
||||
@ -121,4 +123,33 @@ You can build a debug version of the game that includes those sanitizers with
|
||||
../configure --enable-sanitizers
|
||||
```
|
||||
|
||||
[LLVM's Sanitizers]: https://clang.llvm.org/docs/AddressSanitizer.html
|
||||
## Cross-compiling to wasm32-emscripten
|
||||
|
||||
You need to have emscripten installed and enable your installed emsdk tools in your current shell environment.
|
||||
(If you're using the nix shell, you can skip this step)
|
||||
|
||||
```sh
|
||||
source emsdk_env.sh
|
||||
```
|
||||
|
||||
Then copy the necessary Homeworld demo assets (HomeworldDL.big, DL_demo.vce, DL_Music.wxd and ideally the Update.big from the Homeworld 1.05 Update) to the wasm/demo_assets/ folder.
|
||||
|
||||
Now you can setup meson for cross-compiling to wasm32 using emscripten:
|
||||
|
||||
```sh
|
||||
meson setup --cross-file ../wasm32-emscripten.meson-cross-build-definition.txt -Db_sanitize=none -Dmovies=false build.emscripten ..
|
||||
```
|
||||
|
||||
Now switch to the created build.emscripten folder and compile:
|
||||
|
||||
```sh
|
||||
cd build.emscripten
|
||||
meson compile
|
||||
```
|
||||
|
||||
To automatically open the compiled wasm32 binaries in the browser using the provided index.html one can use the mini webserver provided with emscripten:
|
||||
```sh
|
||||
emrun .
|
||||
```
|
||||
|
||||
|
||||
|
||||
24
Linux/flake.lock
generated
24
Linux/flake.lock
generated
@ -22,11 +22,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1695579954,
|
||||
"narHash": "sha256-SxoBKYXBBgiEzZR5BRjjTsHWShg4hIny5Tk84AWaVOE=",
|
||||
"lastModified": 1704036571,
|
||||
"narHash": "sha256-y4OyAOuHmks/VNC365cohMPIhoErh4BJYGx9UYk+liQ=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "a8727098d0c17529648ccdda1e08113299859eb8",
|
||||
"revCount": 4,
|
||||
"rev": "872937107097f19168213ce7f93d30af7cd091e9",
|
||||
"revCount": 9,
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/homeworldsdl/the-guidestone.git"
|
||||
},
|
||||
@ -43,11 +43,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685908677,
|
||||
"narHash": "sha256-E4zUPEUFyVWjVm45zICaHRpfGepfkE9Z2OECV9HXfA4=",
|
||||
"lastModified": 1713543440,
|
||||
"narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=",
|
||||
"owner": "guibou",
|
||||
"repo": "nixGL",
|
||||
"rev": "489d6b095ab9d289fe11af0219a9ff00fe87c7c5",
|
||||
"rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -58,12 +58,10 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1695318763,
|
||||
"narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e12483116b3b51a185a33a272bf351e357ba9a99",
|
||||
"type": "github"
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
|
||||
"path": "/nix/store/5w3dp0m37794iffsbm9vd9f1xmmhda6i-source",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
|
||||
@ -27,9 +27,10 @@
|
||||
gdb
|
||||
ffmpeg
|
||||
nixpkgs-fmt
|
||||
emscripten
|
||||
];
|
||||
# With --enable-sanitizers dlopen() fails to find libs. This is used by SDL2 to open the sound library (pipewire), and by libglvnd to open the vendor-specific OpenGL driver
|
||||
LD_LIBRARY_PATH = "${pipewire.lib}/lib;/run/opengl-driver/lib";
|
||||
LD_LIBRARY_PATH = "${pipewire}/lib;/run/opengl-driver/lib";
|
||||
# The (wrapped) gcc provided by this nix env has source fortifications enabled because its the same gcc that's used to compile nix packages.
|
||||
# However we are in a dev build env and we'd like to have sanitizers enabled. They require `-O0` which is incompatible with source fortification
|
||||
# `error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O)`
|
||||
|
||||
111
meson.build
111
meson.build
@ -1,7 +1,7 @@
|
||||
project('homeworld',
|
||||
'c',
|
||||
version: '1.2.0',
|
||||
default_options: ['warning_level=3', 'c_std=c17', 'b_sanitize=address,undefined'])
|
||||
default_options: ['warning_level=3', 'c_std=gnu11', 'b_sanitize=address,undefined'])
|
||||
|
||||
if get_option('b_sanitize') != 'none'
|
||||
warning('Building with memory sanitizers on. If linking fails, try disabling them with `meson configure -Db_sanitize=none`.')
|
||||
@ -16,7 +16,6 @@ base_deps = [
|
||||
]
|
||||
|
||||
c_base_args = [
|
||||
'-DHW_GAME_HOMEWORLD',
|
||||
'-DHAVE_CONFIG_H',
|
||||
'-D_REENTRANT',
|
||||
|
||||
@ -69,28 +68,53 @@ c_base_args = [
|
||||
'-Wno-unused-result',
|
||||
]
|
||||
|
||||
if build_machine.cpu_family() == 'x86_64'
|
||||
c_base_args += ['-D_X86_64', '-D_X86_64_FIX_ME', '-DGENERIC_ETGCALLFUNCTION']
|
||||
elif build_machine.cpu_family() == 'x86'
|
||||
c_base_args += ['-malign-double', '-D_X86', '-msse']
|
||||
elif build_machine.cpu_family() in ['arm', 'aarch64']
|
||||
c_base_args += ['-DARM', '-DGENERIC_ETGCALLFUNCTION']
|
||||
if host_machine.system() == 'emscripten'
|
||||
c_base_args += [
|
||||
'-DHW_GAME_DEMO',
|
||||
|
||||
# TODO: fix warnings
|
||||
'-Wno-unknown-warning-option',
|
||||
'-Wno-constant-logical-operand',
|
||||
'-Wno-deprecated-non-prototype',
|
||||
'-Wno-pointer-sign',
|
||||
'-Wno-invalid-source-encoding',
|
||||
'-Wno-uninitialized',
|
||||
'-Wno-sometimes-uninitialized',
|
||||
'-Wno-non-literal-null-conversion', # 1 occurrence
|
||||
]
|
||||
else
|
||||
c_base_args += ['-DHW_GAME_HOMEWORLD']
|
||||
endif
|
||||
|
||||
if build_machine.system() == 'linux'
|
||||
if host_machine.cpu_family() != 'x86'
|
||||
c_base_args += ['-DGENERIC_ETGCALLFUNCTION']
|
||||
endif
|
||||
|
||||
if host_machine.cpu_family() == 'x86_64'
|
||||
c_base_args += ['-D_X86_64', '-D_X86_64_FIX_ME']
|
||||
elif host_machine.cpu_family() == 'x86'
|
||||
c_base_args += ['-malign-double', '-D_X86', '-msse']
|
||||
elif host_machine.cpu_family() in ['arm', 'aarch64']
|
||||
c_base_args += ['-DARM']
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
base_deps += [dependency('x11')]
|
||||
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE']
|
||||
elif build_machine.system() == 'darwin'
|
||||
elif host_machine.system() == 'darwin'
|
||||
base_deps += [dependency('x11')]
|
||||
c_base_args += ['-D__APPLE___FIX_ANIM', '-D__APPLE___FIX_LAN', '-D__APPLE___FIX_MISC', '-DGENERIC_ETGCALLFUNCTION']
|
||||
c_base_args += ['-D__APPLE___FIX_ANIM', '-D__APPLE___FIX_LAN', '-D__APPLE___FIX_MISC']
|
||||
|
||||
if build_machine.cpu_family() == 'x86_64'
|
||||
if host_machine.cpu_family() == 'x86_64'
|
||||
c_base_args += ['-D__APPLE___64', '-D__APPLE___FIX_64']
|
||||
elif build_machine.cpu_family() == 'x86'
|
||||
elif host_machine.cpu_family() == 'x86'
|
||||
c_base_args += ['-D__APPLE___86', '-D__APPLE___FIX_86']
|
||||
endif
|
||||
elif build_machine.system() == 'windows'
|
||||
elif host_machine.system() == 'windows'
|
||||
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE', '-D_WIN32', '-DWIN32', '-DWINDOWS']
|
||||
elif host_machine.system() == 'emscripten'
|
||||
base_deps += [dependency('x11')]
|
||||
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE']
|
||||
endif
|
||||
|
||||
if get_option('debug') and get_option('debug_asserts')
|
||||
@ -111,6 +135,37 @@ if get_option('movies')
|
||||
c_args += ['-DHW_ENABLE_MOVIES']
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'emscripten'
|
||||
emscripten_shared_args = [
|
||||
'--use-port=sdl2',
|
||||
'-Wno-int-conversion',
|
||||
'-pthread',
|
||||
'-gsource-map',
|
||||
]
|
||||
|
||||
emscripten_compile_args = emscripten_shared_args
|
||||
emscripten_link_args = emscripten_shared_args + [
|
||||
'-lidbfs.js',
|
||||
'-sASSERTIONS=0',
|
||||
'-sWASM=1',
|
||||
'-sUSE_PTHREADS=1',
|
||||
'-sPTHREAD_POOL_SIZE=4',
|
||||
'-sLEGACY_GL_EMULATION=1',
|
||||
'-s', 'TOTAL_MEMORY=50331648',
|
||||
'-s', 'ALLOW_MEMORY_GROWTH=1',
|
||||
'--use-preload-plugins',
|
||||
|
||||
'--preload-file', '../../wasm/demo_assets@/',
|
||||
'-o', 'homeworld.html',
|
||||
]
|
||||
|
||||
|
||||
dep_sdl = []
|
||||
|
||||
add_global_arguments(emscripten_compile_args, language: ['c', 'cpp'])
|
||||
add_global_link_arguments(emscripten_link_args, language: ['c', 'cpp'])
|
||||
endif
|
||||
|
||||
|
||||
subdir('tools')
|
||||
subdir('src')
|
||||
@ -121,10 +176,24 @@ if build_machine.cpu_family() == 'x86_64'
|
||||
subdir('tools/x86_64')
|
||||
endif
|
||||
|
||||
executable(meson.project_name(),
|
||||
src,
|
||||
include_directories: inc_src,
|
||||
link_with: [lib_sdl],
|
||||
dependencies: base_deps,
|
||||
c_args: c_args,
|
||||
install: true)
|
||||
if host_machine.system() == 'emscripten'
|
||||
fs = import('fs')
|
||||
copy = fs.copyfile('wasm/index.html')
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'emscripten'
|
||||
executable(meson.project_name(),
|
||||
src,
|
||||
include_directories: inc_src,
|
||||
link_with: [lib_sdl],
|
||||
c_args: c_args,
|
||||
install: true)
|
||||
else
|
||||
executable(meson.project_name(),
|
||||
src,
|
||||
include_directories: inc_src,
|
||||
link_with: [lib_sdl],
|
||||
dependencies: base_deps,
|
||||
c_args: c_args,
|
||||
install: true)
|
||||
endif
|
||||
@ -1283,7 +1283,10 @@ void btgRender(void)
|
||||
#else
|
||||
glShadeModel(GL_SMOOTH);
|
||||
#endif
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, _bgColor);
|
||||
_bgColor[0] = colReal32(colRed(universe.backgroundColor));
|
||||
_bgColor[1] = colReal32(colGreen(universe.backgroundColor));
|
||||
_bgColor[2] = colReal32(colBlue(universe.backgroundColor));
|
||||
_bgColor[3] = colReal32(colAlpha(universe.backgroundColor));
|
||||
for (index = 0; index < 4; index++)
|
||||
{
|
||||
_bgByte[index] = (GLubyte)(_bgColor[index] * 255.0f);
|
||||
@ -1337,7 +1340,6 @@ void btgRender(void)
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
//stars
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
rndAdditiveBlends(TRUE);
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
Unfortunately POSIX does not define a way to test whether a system is
|
||||
POSIX-compatible. */
|
||||
#include <fnmatch.h>
|
||||
#include <limits.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
@ -1093,11 +1093,17 @@ void cloudRenderLightning(vector* pa, vector* pb, udword depth, sdword lod, vect
|
||||
{
|
||||
if (width == 0.0f)
|
||||
{
|
||||
glColor3f(CLOUD_LIGHTNING_LINE_RED, CLOUD_LIGHTNING_LINE_GREEN, CLOUD_LIGHTNING_LINE_BLUE);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(CLOUD_LIGHTNING_LINE_RED, CLOUD_LIGHTNING_LINE_GREEN, CLOUD_LIGHTNING_LINE_BLUE);
|
||||
glVertex3fv((real32*)&from);
|
||||
|
||||
glColor3f(CLOUD_LIGHTNING_LINE_RED, CLOUD_LIGHTNING_LINE_GREEN, CLOUD_LIGHTNING_LINE_BLUE);
|
||||
glVertex3fv((real32*)&mid);
|
||||
|
||||
glColor3f(CLOUD_LIGHTNING_LINE_RED, CLOUD_LIGHTNING_LINE_GREEN, CLOUD_LIGHTNING_LINE_BLUE);
|
||||
glVertex3fv((real32*)&mid);
|
||||
|
||||
glColor3f(CLOUD_LIGHTNING_LINE_RED, CLOUD_LIGHTNING_LINE_GREEN, CLOUD_LIGHTNING_LINE_BLUE);
|
||||
glVertex3fv((real32*)&to);
|
||||
glEnd();
|
||||
}
|
||||
@ -1132,16 +1138,23 @@ void cloudRenderLightning(vector* pa, vector* pb, udword depth, sdword lod, vect
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
glVertex3fv((GLfloat*)&_from);
|
||||
glVertex3fv((GLfloat*)&fromHi);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
|
||||
glVertex3fv((GLfloat*)&_from);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
glVertex3fv((GLfloat*)&_mid);
|
||||
|
||||
|
||||
glVertex3fv((GLfloat*)&_mid);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
glVertex3fv((GLfloat*)&toHi);
|
||||
|
||||
glVertex3fv((GLfloat*)&_mid);
|
||||
glVertex3fv((GLfloat*)&toHi);
|
||||
glVertex3fv((GLfloat*)&_to);
|
||||
|
||||
glEnd();
|
||||
@ -1159,16 +1172,23 @@ void cloudRenderLightning(vector* pa, vector* pb, udword depth, sdword lod, vect
|
||||
glColor4f(CLOUD_LIGHTNING_MAIN_RED, CLOUD_LIGHTNING_MAIN_GREEN,
|
||||
CLOUD_LIGHTNING_MAIN_BLUE, CLOUD_LIGHTNING_MAIN_ALPHA);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
glVertex3fv((GLfloat*)&from);
|
||||
glVertex3fv((GLfloat*)&fromHi);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
|
||||
glVertex3fv((GLfloat*)&from);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
glVertex3fv((GLfloat*)&mid);
|
||||
|
||||
|
||||
glVertex3fv((GLfloat*)&mid);
|
||||
glVertex3fv((GLfloat*)&midHi);
|
||||
glVertex3fv((GLfloat*)&toHi);
|
||||
|
||||
glVertex3fv((GLfloat*)&mid);
|
||||
glVertex3fv((GLfloat*)&toHi);
|
||||
glVertex3fv((GLfloat*)&to);
|
||||
|
||||
glEnd();
|
||||
@ -1256,7 +1276,7 @@ void cloudRenderSystem(void* mesh, cloudSystem* system, sdword lod)
|
||||
return;
|
||||
}
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
rndTextureEnable(FALSE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@ -941,7 +941,6 @@ void cpPreviewImageDraw(featom *atom, regionhandle region)
|
||||
cpPreviewImagePrepare();
|
||||
}
|
||||
trPalettedTextureMakeCurrent(cpPreviewTexture, cpPreviewTexturePalette);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(®ion->rect);
|
||||
primRectOutline2(®ion->rect, atom->borderWidth, atom->borderColor);
|
||||
#endif
|
||||
@ -982,7 +981,6 @@ void cpHueSaturationDraw(featom *atom, regionhandle region)
|
||||
}
|
||||
|
||||
trRGBTextureMakeCurrent(cpHueSatTexture);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(®ion->rect);
|
||||
|
||||
primLine2(region->rect.x0, region->rect.y1-1, region->rect.x1, region->rect.y1-1, atom->borderColor);
|
||||
|
||||
@ -1451,7 +1451,6 @@ void cmStartup(void)
|
||||
textureRect.x1 = rect.x1-SP_TEXTURE_INSET;
|
||||
textureRect.y1 = rect.y1-SP_TEXTURE_INSET;
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect);
|
||||
*/
|
||||
}
|
||||
@ -3782,7 +3781,6 @@ void cmDrawShipImage(regionhandle region, sdword shipID)
|
||||
trRGBTextureMakeCurrent(cmShipTexture[universe.curPlayerPtr->race][usetexture]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&rect);
|
||||
|
||||
}
|
||||
|
||||
@ -79,8 +79,8 @@ scriptEntry cratesScriptTable[] =
|
||||
makeEntry(CrateClassProbCLASS_NonCombat,scriptSetReal32CB),
|
||||
makeEntry(CRATE_EXPIRY_TIME,scriptSetReal32CB),
|
||||
|
||||
{"shipProbability", (void(*)(char *,char *,void*))scriptSetShipProbCB, SHIP_PROBS },
|
||||
{"shipGroupSize", (void(*)(char *,char *,void*))scriptSetShipGroupSizeCB, NUM_IN_GROUPS },
|
||||
{"shipProbability", scriptSetShipProbCB, SHIP_PROBS },
|
||||
{"shipGroupSize", scriptSetShipGroupSizeCB, NUM_IN_GROUPS },
|
||||
|
||||
END_SCRIPT_ENTRY
|
||||
};
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
Updated August 1998 by Darren Stone - added bigfile support
|
||||
=============================================================================*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#define ___FILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/syslimits.h>
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "CommandDefs.h"
|
||||
#include "CommandWrap.h"
|
||||
|
||||
@ -416,6 +416,10 @@ void hsRectangle(vector* origin, real32 rightlength, real32 uplength, ubyte alph
|
||||
origin->x + rlen, origin->y + ulen, origin->z,
|
||||
origin->x - rlen, origin->y - ulen, origin->z,
|
||||
origin->x + rlen, origin->y - ulen, origin->z };
|
||||
real32 v2[12] = {origin->x - rlen, origin->y + ulen, origin->z,
|
||||
origin->x + rlen, origin->y + ulen, origin->z,
|
||||
origin->x + rlen, origin->y - ulen, origin->z,
|
||||
origin->x - rlen, origin->y - ulen, origin->z};
|
||||
ubyte red = colRed(c);
|
||||
ubyte green = colGreen(c);
|
||||
ubyte blue = colBlue(c);
|
||||
@ -430,7 +434,8 @@ void hsRectangle(vector* origin, real32 rightlength, real32 uplength, ubyte alph
|
||||
ubyte l[4] = { 0, 1, 3, 2 };
|
||||
glLineWidth(2.0f);
|
||||
glColor4ub((ubyte)(red + 40), (ubyte)(green + 40), blue, alpha);
|
||||
glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_BYTE, l);
|
||||
glVertexPointer(3, GL_FLOAT, 0, v2);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "HorseRace.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "StatScript.h"
|
||||
#include "Memory.h"
|
||||
|
||||
@ -1169,7 +1169,6 @@ void lmDrawShipImage(regionhandle region, smemsize shipID)
|
||||
trRGBTextureMakeCurrent(lmShipTexture[universe.curPlayerPtr->race][usetexture]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&rect);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "LevelLoad.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "StatScript.h"
|
||||
|
||||
@ -1931,10 +1931,14 @@ void meshObjectRender(polygonobject *object, materialentry *materials, sdword iC
|
||||
case MPM_Flat:
|
||||
dbgAssertOrIgnore(polygon->iFaceNormal != UWORD_Max);
|
||||
normal = &normalList[polygon->iFaceNormal];
|
||||
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV0].x);
|
||||
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV1].x);
|
||||
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV2].x);
|
||||
|
||||
#if RND_POLY_STATS
|
||||
@ -1945,13 +1949,14 @@ void meshObjectRender(polygonobject *object, materialentry *materials, sdword iC
|
||||
dbgAssertOrIgnore(polygon->iFaceNormal != UWORD_Max);
|
||||
normal = &normalList[polygon->iFaceNormal];
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
|
||||
glTexCoord2f(polygon->s0, polygon->t0);
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV0].x);
|
||||
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
glTexCoord2f(polygon->s1, polygon->t1);
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV1].x);
|
||||
|
||||
glNormal3f(normal->x, normal->y, normal->z);
|
||||
glTexCoord2f(polygon->s2, polygon->t2);
|
||||
glVertex3fv((GLfloat*)&vertexList[polygon->iV2].x);
|
||||
|
||||
@ -2025,7 +2030,7 @@ void meshObjectRender(polygonobject *object, materialentry *materials, sdword iC
|
||||
glEnd(); //done drawing these triangles
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
if (!usingShader) glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
if (!usingShader) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
|
||||
if (enableBlend)
|
||||
{
|
||||
@ -2087,6 +2092,9 @@ void meshDisableVertexArrays(void)
|
||||
----------------------------------------------------------------------------*/
|
||||
void meshObjectRenderLit(polygonobject *object, materialentry *materials, sdword iColorScheme)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
meshObjectRender(object, materials, iColorScheme);
|
||||
#else
|
||||
sdword iPoly;
|
||||
vertexentry *vertexList;
|
||||
polyentry *polygon;
|
||||
@ -2229,7 +2237,7 @@ void meshObjectRenderLit(polygonobject *object, materialentry *materials, sdword
|
||||
meshDisableVertexArrays();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
if (!usingShader) glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
if (!usingShader) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
|
||||
if (bFade)
|
||||
{
|
||||
@ -2237,6 +2245,7 @@ void meshObjectRenderLit(polygonobject *object, materialentry *materials, sdword
|
||||
}
|
||||
|
||||
rndLightingEnable(TRUE); //shader
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@ -2610,9 +2619,12 @@ void meshMorphedObjectRender(
|
||||
meshLerpNormal(&normal, &normalList1[polygon->iFaceNormal], &normalList2[polygon->iFaceNormal], frac);
|
||||
if (g_SpecHack) meshMorphedSpecColour(&normal, modelview, modelviewInv);
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
|
||||
glVertex3fv((GLfloat*)&vert0);
|
||||
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
glVertex3fv((GLfloat*)&vert1);
|
||||
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
glVertex3fv((GLfloat*)&vert2);
|
||||
#if RND_POLY_STATS
|
||||
rndNumberPolys++;
|
||||
@ -2629,11 +2641,14 @@ void meshMorphedObjectRender(
|
||||
meshLerpNormal(&normal, &normalList1[polygon->iFaceNormal], &normalList2[polygon->iFaceNormal], frac);
|
||||
if (g_SpecHack) meshMorphedSpecColour(&normal, modelview, modelviewInv);
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
|
||||
glTexCoord2f(uvPolygon->s0, uvPolygon->t0);
|
||||
glVertex3fv((GLfloat*)&vert0);
|
||||
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
glTexCoord2f(uvPolygon->s1, uvPolygon->t1);
|
||||
glVertex3fv((GLfloat*)&vert1);
|
||||
|
||||
glNormal3f(normal.x, normal.y, normal.z);
|
||||
glTexCoord2f(uvPolygon->s2, uvPolygon->t2);
|
||||
glVertex3fv((GLfloat*)&vert2);
|
||||
#if RND_POLY_STATS
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#define MESH_ERROR_CHECKING 1 //general error checking
|
||||
#define MESH_ANAL_CHECKING 1 //extra-anal error checking
|
||||
#define MESH_RETAIN_FILENAMES 1 //keep a copy of the fileName
|
||||
#define MESH_MORPH_DEBUG 1 //debug morph render code
|
||||
#define MESH_MORPH_DEBUG 0 //debug morph render code
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -5384,7 +5383,7 @@ void nisStaticDraw(nisstatic *snow)
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
rndGLStateLog("Textured Static");
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
while (nLines)
|
||||
{
|
||||
y0 = frandyrandombetween(RANDOM_STATIC, top, bottom);
|
||||
@ -5400,10 +5399,21 @@ void nisStaticDraw(nisstatic *snow)
|
||||
|
||||
glTexCoord2f(s0, t0);
|
||||
glVertex2f(x0, y1);
|
||||
|
||||
glTexCoord2f(s0, t0);
|
||||
glVertex2f(x0, y0);
|
||||
|
||||
glTexCoord2f(s1, t0);
|
||||
glVertex2f(x1, y0);
|
||||
|
||||
|
||||
glTexCoord2f(s0, t0);
|
||||
glVertex2f(x0, y1);
|
||||
|
||||
glTexCoord2f(s1, t0);
|
||||
glVertex2f(x1, y0);
|
||||
|
||||
glTexCoord2f(s1, t0);
|
||||
glVertex2f(x1, y1);
|
||||
|
||||
}
|
||||
@ -5438,6 +5448,7 @@ void nisStaticDraw(nisstatic *snow)
|
||||
nLines--;
|
||||
glColor4f(red, green, blue, alpha);
|
||||
glVertex2f(x0, y0);
|
||||
glColor4f(red, green, blue, alpha);
|
||||
glVertex2f(x1, y0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1311,7 +1311,7 @@ void nebDrawChunk2(nebChunk* chunk, sdword lod)
|
||||
nebGetTendrilNormal(ta, ia1, lod, &norma1);
|
||||
nebGetTendrilNormal(tb, ib1, lod, &normb1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
|
||||
COLOUR(cola);
|
||||
glNormal3f(norma0.x, norma0.y, norma0.z);
|
||||
@ -1323,16 +1323,16 @@ void nebDrawChunk2(nebChunk* chunk, sdword lod)
|
||||
nebColourAdjust(&vertb0, &normb0, m, minv);
|
||||
glVertex3fv((GLfloat*)&vertb0);
|
||||
|
||||
COLOUR(colb);
|
||||
glNormal3f(normb1.x, normb1.y, normb1.z);
|
||||
nebColourAdjust(&vertb1, &normb1, m, minv);
|
||||
glVertex3fv((GLfloat*)&vertb1);
|
||||
|
||||
COLOUR(cola);
|
||||
glNormal3f(norma1.x, norma1.y, norma1.z);
|
||||
nebColourAdjust(&verta1, &norma1, m, minv);
|
||||
glVertex3fv((GLfloat*)&verta1);
|
||||
|
||||
COLOUR(colb);
|
||||
glNormal3f(normb1.x, normb1.y, normb1.z);
|
||||
nebColourAdjust(&vertb1, &normb1, m, minv);
|
||||
glVertex3fv((GLfloat*)&vertb1);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
alodIncPolys(ta->lod[lod].slices);
|
||||
@ -1410,7 +1410,7 @@ void nebDrawTendril(nebTendril* tendril, sdword lod)
|
||||
dPosA = tendril->a->dPos;
|
||||
dPosB = tendril->b->dPos;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (j = 1; j <= tendril->lod[lod].stacks; j++)
|
||||
{
|
||||
for (i = 0; i < tendril->lod[lod].slices; i++)
|
||||
@ -1462,6 +1462,37 @@ void nebDrawTendril(nebTendril* tendril, sdword lod)
|
||||
glVertex3fv((GLfloat*)&vert);
|
||||
TENDRILCOLOR(tendril,colAlpha(tendril->colour));
|
||||
|
||||
|
||||
nebGetTendrilNormal(tendril, (j-1)*tendril->lod[lod].slices + i, lod, &norm);
|
||||
glNormal3f(norm.x, norm.y, norm.z);
|
||||
nebGetTendrilVert(tendril, (j-1)*tendril->lod[lod].slices + i, lod, &vert);
|
||||
if (j == 1)
|
||||
{
|
||||
vecAddTo(vert, dPosA);
|
||||
if (bitTest(tendril->flags, NEB_TENDRIL_LEADING))
|
||||
{
|
||||
TENDRILCOLOR(tendril,0);
|
||||
}
|
||||
}
|
||||
nebColourAdjust(&vert, &norm, m, minv);
|
||||
glVertex3fv((GLfloat*)&vert);
|
||||
TENDRILCOLOR(tendril,colAlpha(tendril->colour));
|
||||
|
||||
nebGetTendrilNormal(tendril, j*tendril->lod[lod].slices + t, lod, &norm);
|
||||
glNormal3f(norm.x, norm.y, norm.z);
|
||||
nebGetTendrilVert(tendril, j*tendril->lod[lod].slices + t, lod, &vert);
|
||||
if (j == tendril->lod[lod].stacks)
|
||||
{
|
||||
vecAddTo(vert, dPosB);
|
||||
if (bitTest(tendril->flags, NEB_TENDRIL_TRAILING))
|
||||
{
|
||||
TENDRILCOLOR(tendril,0);
|
||||
}
|
||||
}
|
||||
nebColourAdjust(&vert, &norm, m, minv);
|
||||
glVertex3fv((GLfloat*)&vert);
|
||||
TENDRILCOLOR(tendril,colAlpha(tendril->colour));
|
||||
|
||||
nebGetTendrilNormal(tendril, (j-1)*tendril->lod[lod].slices + t, lod, &norm);
|
||||
glNormal3f(norm.x, norm.y, norm.z);
|
||||
nebGetTendrilVert(tendril, (j-1)*tendril->lod[lod].slices + t, lod, &vert);
|
||||
@ -2025,7 +2056,7 @@ void nebRenderNebula(nebulae_t* neb)
|
||||
atOn = glIsEnabled(GL_ALPHA_TEST);
|
||||
cullOff = !glIsEnabled(GL_CULL_FACE);
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||
if (fogOn) glDisable(GL_FOG);
|
||||
|
||||
rndLightingEnable(FALSE);
|
||||
|
||||
@ -342,7 +342,7 @@ color partEffectColor;
|
||||
real32 partNLips;
|
||||
|
||||
//box helper
|
||||
static void drawBox(GLfloat size, GLenum type)
|
||||
static void drawBox(GLfloat size, GLenum type, particle *p, bool32 alpha)
|
||||
{
|
||||
static GLfloat n[6][3] =
|
||||
{
|
||||
@ -375,11 +375,42 @@ static void drawBox(GLfloat size, GLenum type)
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
glBegin(type);
|
||||
glNormal3fv(&n[i][0]);
|
||||
glVertex3fv(&v[faces[i][0]][0]);
|
||||
glVertex3fv(&v[faces[i][1]][0]);
|
||||
glVertex3fv(&v[faces[i][2]][0]);
|
||||
glVertex3fv(&v[faces[i][3]][0]);
|
||||
if (alpha)
|
||||
{
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3fv(&v[faces[i][0]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3fv(&v[faces[i][1]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3fv(&v[faces[i][3]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3fv(&v[faces[i][2]][0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3fv(&v[faces[i][0]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3fv(&v[faces[i][1]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3fv(&v[faces[i][3]][0]);
|
||||
|
||||
glNormal3fv(&n[i][0]);
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3fv(&v[faces[i][2]][0]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
@ -391,21 +422,23 @@ void partCircleSolid3(vector *centre, real32 radius, sdword nSlices, color c)
|
||||
GLfloat v[3];
|
||||
double theta;
|
||||
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y;
|
||||
v[2] = centre->z;
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex3fv(v);
|
||||
for (index = 0, theta = 0.0; index < nSlices; index++)
|
||||
{
|
||||
v[0] = centre->x + (real32)(sin(theta)) * radius;
|
||||
v[1] = centre->y + (real32)(cos(theta)) * radius;
|
||||
theta += 2.0 * PI / (double)nSlices;
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex3fv(v);
|
||||
}
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y + radius;
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex3fv(v);
|
||||
glEnd();
|
||||
}
|
||||
@ -618,7 +651,23 @@ void partBindAlternate(trhandle tex)
|
||||
|
||||
// ... from the data of the old texture (ASSERT: currently bound)
|
||||
data = (ubyte*)memAlloc(4*reg->scaledWidth*reg->scaledHeight, "temp part alternate", Pyrophoric);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
#else
|
||||
// webgl does not support glgetteximage so we have to use read pixels via framebuffer attachements
|
||||
GLuint fbo;
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, reg->handle, 0);
|
||||
|
||||
glReadPixels(0, 0, reg->scaledWidth, reg->scaledHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 4*reg->scaledWidth*reg->scaledHeight; i += 4)
|
||||
{
|
||||
data[i+0] = data[i+1] = data[i+2] = 200;
|
||||
@ -668,6 +717,7 @@ udword partRenderBillSystem(udword n, particle* p, udword flags,
|
||||
matrix* partMat;
|
||||
trhandle tex;
|
||||
real32 saturatedBias[3] = {0.0, 0.0, 0.0};
|
||||
real32 tmpColors[4] = {0.0, 0.0, 0.0, 0.0};
|
||||
sdword blended;
|
||||
|
||||
slices = bpart->slices;
|
||||
@ -735,14 +785,16 @@ udword partRenderBillSystem(udword n, particle* p, udword flags,
|
||||
|
||||
if (p->icolor[3] == 1.0f)
|
||||
{
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
tmpColors[0] = p->icolor[0];
|
||||
tmpColors[1] = p->icolor[1];
|
||||
tmpColors[2] = p->icolor[2];
|
||||
tmpColors[3] = p->icolor[3];
|
||||
|
||||
if (currentTex == TR_Invalid)
|
||||
{
|
||||
@ -781,21 +833,32 @@ udword partRenderBillSystem(udword n, particle* p, udword flags,
|
||||
if (p->rot == 0.0f)
|
||||
{
|
||||
AGAIN0:
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[0][0]), TEXY(uv[0][1]));
|
||||
glVertex3f(-sx, -sy, 0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[0][1]));
|
||||
glVertex3f(sx, -sy, 0.0f);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[1][1]));
|
||||
glVertex3f(sx, sy, 0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[0][0]), TEXY(uv[1][1]));
|
||||
glVertex3f(-sx, sy, 0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[1][1]));
|
||||
glVertex3f(sx, sy, 0.0f);
|
||||
|
||||
glEnd();
|
||||
if (blended)
|
||||
{
|
||||
blended--;
|
||||
rndAdditiveBlends(TRUE);
|
||||
glColor4f(saturatedBias[0], saturatedBias[1], saturatedBias[2], p->icolor[3]);
|
||||
tmpColors[0] = saturatedBias[0];
|
||||
tmpColors[1] = saturatedBias[1];
|
||||
tmpColors[2] = saturatedBias[2];
|
||||
tmpColors[3] = p->icolor[3];
|
||||
//render this guy again, additively blending over the last
|
||||
partBindAlternate(currentTex);
|
||||
partFilter(TRUE);
|
||||
@ -805,29 +868,40 @@ AGAIN0:
|
||||
else
|
||||
{
|
||||
AGAIN1:
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[0][0]), TEXY(uv[0][1]));
|
||||
glVertex3f((-sx*cosTheta) - (-sy*sinTheta),
|
||||
(-sx*sinTheta) + (-sy*cosTheta),
|
||||
0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[0][1]));
|
||||
glVertex3f((sx*cosTheta) - (-sy*sinTheta),
|
||||
(sx*sinTheta) + (-sy*cosTheta),
|
||||
0.0f);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[1][1]));
|
||||
glVertex3f((sx*cosTheta) - (sy*sinTheta),
|
||||
(sx*sinTheta) + (sy*cosTheta),
|
||||
0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[0][0]), TEXY(uv[1][1]));
|
||||
glVertex3f((-sx*cosTheta) - (sy*sinTheta),
|
||||
(-sx*sinTheta) + (sy*cosTheta),
|
||||
0.0f);
|
||||
|
||||
glColor4f(tmpColors[0], tmpColors[1], tmpColors[2], tmpColors[3]);
|
||||
glTexCoord2f(TEXX(uv[1][0]), TEXY(uv[1][1]));
|
||||
glVertex3f((sx*cosTheta) - (sy*sinTheta),
|
||||
(sx*sinTheta) + (sy*cosTheta),
|
||||
0.0f);
|
||||
|
||||
glEnd();
|
||||
if (blended)
|
||||
{
|
||||
blended--;
|
||||
rndAdditiveBlends(TRUE);
|
||||
glColor4f(saturatedBias[0], saturatedBias[1], saturatedBias[2], p->icolor[3]);
|
||||
tmpColors[0] = saturatedBias[0];
|
||||
tmpColors[1] = saturatedBias[1];
|
||||
tmpColors[2] = saturatedBias[2];
|
||||
tmpColors[3] = p->icolor[3];
|
||||
//render again, additively blending over previous
|
||||
partBindAlternate(currentTex);
|
||||
partFilter(TRUE);
|
||||
@ -1425,9 +1499,7 @@ udword partRenderLineSystem(udword n, particle *p, udword flags)
|
||||
vector pos;
|
||||
bool32 texEnabled, lightEnabled;
|
||||
bool32 alpha = FALSE;
|
||||
GLfloat linewidth;
|
||||
|
||||
glGetFloatv(GL_LINE_WIDTH, &linewidth);
|
||||
if (bitTest(flags, PART_ALPHA))
|
||||
{
|
||||
alpha = TRUE;
|
||||
@ -1460,14 +1532,7 @@ udword partRenderLineSystem(udword n, particle *p, udword flags)
|
||||
|
||||
glLineWidth(p->scale);
|
||||
glBegin(GL_LINES);
|
||||
if (alpha)
|
||||
{
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
}
|
||||
|
||||
pos = p->position;
|
||||
if (bitTest(flags, PART_WORLDSPACE))
|
||||
{
|
||||
@ -1497,8 +1562,22 @@ udword partRenderLineSystem(udword n, particle *p, udword flags)
|
||||
vecMultiplyByScalar(rv, p->length);
|
||||
vecAddTo(pos, rv);
|
||||
}
|
||||
glVertex3f(p->position.x, p->position.y, p->position.z);
|
||||
glVertex3f(pos.x, pos.y, pos.z);
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3f(p->position.x, p->position.y, p->position.z);
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
glVertex3f(pos.x, pos.y, pos.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3f(p->position.x, p->position.y, p->position.z);
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
glVertex3f(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@ -1511,7 +1590,6 @@ udword partRenderLineSystem(udword n, particle *p, udword flags)
|
||||
rndTextureEnable(texEnabled);
|
||||
rndLightingEnable(lightEnabled);
|
||||
|
||||
glLineWidth(linewidth);
|
||||
return hits;
|
||||
}
|
||||
|
||||
@ -1546,12 +1624,8 @@ udword partRenderCubeSystem(udword n, particle *p, udword flags)
|
||||
continue;
|
||||
glPushMatrix();
|
||||
glTranslatef(p->position.x, p->position.y, p->position.z);
|
||||
if (alpha)
|
||||
glColor4f(p->icolor[0], p->icolor[1], p->icolor[2], p->icolor[3]);
|
||||
else
|
||||
glColor3f(p->icolor[0], p->icolor[1], p->icolor[2]);
|
||||
handleIllum(p);
|
||||
drawBox(p->scale * 0.5f, GL_QUADS);
|
||||
drawBox(p->scale * 0.5f, GL_TRIANGLE_STRIP, p, alpha);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@ -1576,12 +1650,10 @@ udword partRenderPointSystem(udword n, particle *p, udword flags)
|
||||
bool32 alpha = FALSE;
|
||||
|
||||
bool32 texEnabled, lightEnabled;
|
||||
GLfloat pointsize;
|
||||
|
||||
texEnabled = rndTextureEnable(FALSE);
|
||||
lightEnabled = rndLightingEnable(FALSE);
|
||||
|
||||
glGetFloatv(GL_POINT_SIZE, &pointsize);
|
||||
if (bitTest(flags, PART_ALPHA))
|
||||
{
|
||||
alpha = TRUE;
|
||||
@ -1625,7 +1697,6 @@ udword partRenderPointSystem(udword n, particle *p, udword flags)
|
||||
rndTextureEnable(texEnabled);
|
||||
rndLightingEnable(lightEnabled);
|
||||
|
||||
glPointSize(pointsize);
|
||||
rndAdditiveBlends(FALSE);
|
||||
return hits;
|
||||
}
|
||||
|
||||
@ -998,7 +998,7 @@ void piePointSpecDraw(void)
|
||||
{
|
||||
vector world0, world1;
|
||||
vector highPoint, lowPoint;
|
||||
GLdouble modelView[16], projection[16];
|
||||
GLfloat modelView[16], projection[16];
|
||||
hmatrix modelViewF, projectionF;
|
||||
real32 distance, deltaX, deltaY;
|
||||
real32 oldPointSpecZ, slope, b;
|
||||
@ -1055,8 +1055,8 @@ void piePointSpecDraw(void)
|
||||
|
||||
windowHeightMinusOne = (real32)(MAIN_WindowHeight - 1);
|
||||
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, projection);
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, modelView); //get the matrices
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, projection);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, modelView); //get the matrices
|
||||
|
||||
world0.x = mrCamera->eyeposition.x - selCentrePoint.x;
|
||||
world0.y = mrCamera->eyeposition.y - selCentrePoint.y;
|
||||
|
||||
@ -828,7 +828,6 @@ void rmDrawLabButton(LabPrintList *labprint, regionhandle region)
|
||||
trRGBTextureMakeCurrent(rmLabTexture[universe.curPlayerPtr->race]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&rect);
|
||||
break;
|
||||
|
||||
@ -848,7 +847,6 @@ void rmDrawLabButton(LabPrintList *labprint, regionhandle region)
|
||||
trRGBTextureMakeCurrent(rmLabTexture[universe.curPlayerPtr->race]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&rect);
|
||||
|
||||
// compute progress bar length
|
||||
@ -908,7 +906,6 @@ void rmDrawLabButton(LabPrintList *labprint, regionhandle region)
|
||||
trRGBTextureMakeCurrent(rmLabTexture[universe.curPlayerPtr->race]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&rect);
|
||||
break;
|
||||
|
||||
@ -1714,7 +1711,6 @@ void rmTechImageDraw(featom *atom, regionhandle region)
|
||||
textureRect.x1 = region->rect.x1-RM_TEXTURE_INSET;
|
||||
textureRect.y1 = region->rect.y1-RM_TEXTURE_INSET;
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect);
|
||||
|
||||
if (rmExtendedInfoActive)
|
||||
@ -1765,7 +1761,6 @@ void rmTechImageDraw(featom *atom, regionhandle region)
|
||||
textureRect.x1 = region->rect.x1 - RM_TEXTURE_INSET;
|
||||
textureRect.y1 = region->rect.y1 - RM_TEXTURE_INSET;
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect);
|
||||
|
||||
if (rmExtendedInfoActive)
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
#include "SaveGame.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "AIPlayer.h"
|
||||
@ -44,6 +43,10 @@
|
||||
#include "UnivUpdate.h"
|
||||
#include "utility.h"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
void SaveConsMgr(void);
|
||||
void LoadConsMgr(void);
|
||||
|
||||
@ -739,6 +742,15 @@ bool32 SaveGame(char *filename)
|
||||
fileClose(savefile);
|
||||
savefile = 0;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_ASM(
|
||||
FS.syncfs(function (err) {
|
||||
if (err) console.log("FS.syncfs error when saving game: " + err);
|
||||
});
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
if (savefilestatus)
|
||||
{
|
||||
fileDelete(filename);
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "Debug.h"
|
||||
#include "File.h"
|
||||
#include "Memory.h"
|
||||
@ -1161,7 +1160,6 @@ void spScenarioBitmap(featom *atom, regionhandle region)
|
||||
if (scenarioTexture != TR_InvalidInternalHandle)
|
||||
{
|
||||
trRGBTextureMakeCurrent(scenarioTexture);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect); //draw the bitmap
|
||||
feStaticRectangleDraw(region); //draw a border
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
|
||||
//located in mainrg.c
|
||||
//falko's fault...not mine..long story
|
||||
void toFieldSphereDraw(ShipPtr ship,real32 radius, real32 scale);
|
||||
void toFieldSphereDraw(ShipPtr ship,real32 radius, real32 scale, color passedColour);
|
||||
|
||||
void (*smHoldLeft)(void);
|
||||
void (*smHoldRight)(void);
|
||||
@ -894,7 +894,7 @@ void smBlobDrawClear(Camera *camera, blob *thisBlob, hmatrix *modelView, hmatrix
|
||||
{
|
||||
if (((GravWellGeneratorSpec *)((Ship *)obj)->ShipSpecifics)->GravFieldOn)
|
||||
{
|
||||
toFieldSphereDraw(((Ship *)obj),((GravWellGeneratorStatics *) ((ShipStaticInfo *)(((Ship *)obj)->staticinfo))->custstatinfo)->GravWellRadius, 1.0f);
|
||||
toFieldSphereDraw(((Ship *)obj),((GravWellGeneratorStatics *) ((ShipStaticInfo *)(((Ship *)obj)->staticinfo))->custstatinfo)->GravWellRadius, 1.0f, TW_GRAVWELL_SPHERE_COLOUR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1173,6 +1173,7 @@ renderDerelictAsDot:
|
||||
color c = neb->tendrilTable[t].colour;
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), 192);
|
||||
glVertex3fv((GLfloat*)&neb->tendrilTable[t].a->position);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), 192);
|
||||
glVertex3fv((GLfloat*)&neb->tendrilTable[t].b->position);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
@ -472,8 +472,6 @@ void svShipViewRender(featom* atom, regionhandle region)
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
rndPerspectiveCorrection(TRUE);
|
||||
|
||||
//svCamera.lookatpoint.x = -info->staticheader.staticCollInfo.collsphereoffset.z * scale;
|
||||
//svCamera.lookatpoint.y = -info->staticheader.staticCollInfo.collsphereoffset.x * scale;
|
||||
//svCamera.lookatpoint.z = -info->staticheader.staticCollInfo.collsphereoffset.y * scale;
|
||||
@ -565,7 +563,6 @@ void svShipViewRender(featom* atom, regionhandle region)
|
||||
glViewport(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);
|
||||
|
||||
rndLightingEnable(FALSE);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
|
||||
x = rect->x0 + 2 + SV_ViewMargin;
|
||||
y = rect->y0 + 2 + SV_ViewMargin;
|
||||
|
||||
@ -2567,7 +2567,7 @@ void singlePlayerGameUpdate(void)
|
||||
// was: HW_COMPUTER_GAMING_WORLD_DEMO but the standard demo
|
||||
// had a short single player campaign surely? If not get rid of this
|
||||
#ifdef HW_GAME_DEMO
|
||||
if (spGetCurrentMission() == MISSION_2_OUTSKIRTS_OF_KHARAK)
|
||||
if (spGetCurrentMission() == MISSION_2_OUTSKIRTS_OF_KHARAK_SYSTEM)
|
||||
{
|
||||
universe.quittime = universe.totaltimeelapsed;
|
||||
utyPlugScreens = TRUE;
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
#include "StatScript.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -1272,13 +1272,16 @@ void subTitlesDraw(subregion *region)
|
||||
if ((!mrRenderMainScreen && !smFleetIntel) && region == &subRegion[STR_LetterboxBar])
|
||||
{ //if some full screen gui is up
|
||||
rndTextureEnable(FALSE);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
//top scissor part
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(0));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(NIS_LetterHeight));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(NIS_LetterHeight));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(0));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(NIS_LetterHeight));
|
||||
glEnd();
|
||||
//ferDrawBoxRegion(region->rect, ferMediumTextures, ferInternalGlow, NULL, FALSE);
|
||||
}
|
||||
|
||||
@ -1100,7 +1100,6 @@ void tmTechImageDraw(featom *atom, regionhandle region)
|
||||
textureRect.x1=region->rect.x1-TM_TEXTURE_INSET;
|
||||
textureRect.y1=region->rect.y1-TM_TEXTURE_INSET;
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect);
|
||||
|
||||
//if(tmExtendedInfoActive)
|
||||
@ -1151,7 +1150,6 @@ void tmTechImageDraw(featom *atom, regionhandle region)
|
||||
textureRect.x1=region->rect.x1-TM_TEXTURE_INSET;
|
||||
textureRect.y1=region->rect.y1-TM_TEXTURE_INSET;
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
primRectSolidTextured2(&textureRect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1411,7 +1411,7 @@ void trailLinePyramid(
|
||||
glEnable(GL_BLEND);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
//a
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a1);
|
||||
@ -1419,30 +1419,56 @@ void trailLinePyramid(
|
||||
VERT(b1);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0hi);
|
||||
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a1);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0hi);
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0hi);
|
||||
|
||||
//b
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0hi);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0hi);
|
||||
COLx(cb,PYRAMID_ALPHA_LO);
|
||||
VERT(b2);
|
||||
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0hi);
|
||||
COLx(cb,PYRAMID_ALPHA_LO);
|
||||
VERT(b2);
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a2);
|
||||
|
||||
//c
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a2);
|
||||
COLx(cb,PYRAMID_ALPHA_LO);
|
||||
VERT(b2);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0lo);
|
||||
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a2);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0lo);
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0lo);
|
||||
|
||||
//d
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0lo);
|
||||
COLx(cb,PYRAMID_ALPHA_HI);
|
||||
VERT(b0lo);
|
||||
COLx(cb,PYRAMID_ALPHA_LO);
|
||||
VERT(b1);
|
||||
|
||||
COLx(c,PYRAMID_ALPHA_HI);
|
||||
VERT(a0lo);
|
||||
COLx(cb,PYRAMID_ALPHA_LO);
|
||||
VERT(b1);
|
||||
COLx(c,PYRAMID_ALPHA_LO);
|
||||
VERT(a1);
|
||||
glEnd();
|
||||
@ -1528,14 +1554,15 @@ void trailLineFuzzySheath(sdword LOD, sdword i, vector* vectora, vector* vectorb
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
COLx(c, PYRAMID_ALPHA_MID);
|
||||
VERT(a1);
|
||||
COLx(cb, PYRAMID_ALPHA_MID);
|
||||
VERT(b1);
|
||||
VERT(b2);
|
||||
COLx(c, PYRAMID_ALPHA_MID);
|
||||
VERT(a2);
|
||||
COLx(cb, PYRAMID_ALPHA_MID);
|
||||
VERT(b2);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -1597,7 +1624,7 @@ void trailLineBillboard(
|
||||
|
||||
alpha = usingShader ? (ubyte)(127.0f * meshFadeAlpha) : 127;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
if (i == 0)
|
||||
{
|
||||
cb = c;
|
||||
@ -1609,10 +1636,12 @@ void trailLineBillboard(
|
||||
}
|
||||
COLx(cb,alpha);
|
||||
VERT(from);
|
||||
COLx(cb,alpha);
|
||||
VERT(fromHi);
|
||||
COLx(c,alpha);
|
||||
VERT(toHi);
|
||||
VERT(to);
|
||||
COLx(c,alpha);
|
||||
VERT(toHi);
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
@ -1525,7 +1525,6 @@ void tutDrawNextButtonFunction(regionhandle reg)
|
||||
else
|
||||
trRGBTextureMakeCurrent(tutTexture[TUT_NEXT_OFF]);
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
// glEnable(GL_BLEND);
|
||||
primRectSolidTextured2(®->rect);
|
||||
// glDisable(GL_BLEND);
|
||||
@ -1649,7 +1648,6 @@ void tutDrawBackButtonFunction(regionhandle reg)
|
||||
trRGBTextureMakeCurrent(tutTexture[TUT_REST_OFF]);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
// glEnable(GL_BLEND);
|
||||
primRectSolidTextured2(®->rect);
|
||||
// glDisable(GL_BLEND);
|
||||
@ -1782,7 +1780,6 @@ long x, y;
|
||||
Index = szImageIndexList[i];
|
||||
|
||||
trRGBTextureMakeCurrent(tutTexture[Index]);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
rect.x0 = x + (64 * i);
|
||||
rect.y0 = y;
|
||||
rect.x1 = x + (64 * i) + 64;
|
||||
|
||||
@ -22,14 +22,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// PATH_MAX is Homeworld's standard #define for stating
|
||||
// "maximum length of a filesystem path string".
|
||||
#ifdef __APPLE__
|
||||
#include <sys/syslimits.h>
|
||||
#elif defined linux
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Warning turn ons:
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
@ -2026,6 +2026,15 @@ void InitStatShipInfo(ShipStaticInfo *statinfo,ShipType type,ShipRace race)
|
||||
strcpy(fullshipname,directory);
|
||||
strcat(fullshipname,shipname);
|
||||
|
||||
#ifdef HW_GAME_DEMO
|
||||
// The demo assets don't contain everything necessary for these ships, disable them
|
||||
if ( (strcmp(shipname, "CloakedFighter.shp") == 0) || (strcmp(shipname, "MinelayerCorvette.shp") == 0) ) {
|
||||
SetInfoNeededForShipAndRelatedStaticInfo(type,race,FALSE);
|
||||
rmEnableShip(race, type, FALSE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!fileExists(fullshipname,0) || universeForceDefaultShip)
|
||||
{
|
||||
//we now disable this ship if we can't find it...
|
||||
|
||||
@ -203,15 +203,15 @@ static void Draw_Stretch (int x, int y, int w, int h, int cols, int rows, char *
|
||||
glBindTexture(GL_TEXTURE_2D, strtex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
glBegin (GL_QUADS);
|
||||
glBegin (GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f (0.0f, (GLfloat)rows/tex_height);
|
||||
glVertex2f (x, y);
|
||||
glTexCoord2f ((GLfloat)cols/tex_width, (GLfloat)rows/tex_height);
|
||||
glVertex2f (x+w, y);
|
||||
glTexCoord2f ((GLfloat)cols/tex_width, 0.0f);
|
||||
glVertex2f (x+w, y+h);
|
||||
glTexCoord2f (0.0f, 0.0f);
|
||||
glVertex2f (x, y+h);
|
||||
glTexCoord2f ((GLfloat)cols/tex_width, 0.0f);
|
||||
glVertex2f (x+w, y+h);
|
||||
glEnd ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ bool32 glfontDisplayCharacter(fontheader* font, char ch, sdword x, sdword y, col
|
||||
glBindTexture(GL_TEXTURE_2D, page->glhandle);
|
||||
}
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
|
||||
VERT(sBegin, tEnd,
|
||||
x + fcharacter->offsetX,
|
||||
@ -515,12 +515,12 @@ bool32 glfontDisplayCharacter(fontheader* font, char ch, sdword x, sdword y, col
|
||||
VERT(sBegin, tBegin,
|
||||
x + fcharacter->offsetX,
|
||||
y + fcharacter->offsetY + fcharacter->height);
|
||||
VERT(sEnd, tBegin,
|
||||
x + fcharacter->offsetX + fcharacter->width,
|
||||
y + fcharacter->offsetY + fcharacter->height);
|
||||
VERT(sEnd, tEnd,
|
||||
x + fcharacter->offsetX + fcharacter->width,
|
||||
y + fcharacter->offsetY);
|
||||
VERT(sEnd, tBegin,
|
||||
x + fcharacter->offsetX + fcharacter->width,
|
||||
y + fcharacter->offsetY + fcharacter->height);
|
||||
|
||||
glEnd();
|
||||
|
||||
@ -581,7 +581,6 @@ bool32 glfontDisplayString(fontheader* font, char* string, sdword x, sdword y, c
|
||||
if (!blendOn) glEnable(GL_BLEND);
|
||||
if (alphatestOn) glDisable(GL_ALPHA_TEST);
|
||||
rndAdditiveBlends(FALSE);
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
glShadeModel(GL_FLAT);
|
||||
rndTextureEnvironment(RTE_Modulate);
|
||||
|
||||
@ -1213,10 +1212,12 @@ sdword fontPrintN(sdword x, sdword y, color c, char *string, sdword maxCharacter
|
||||
goto noDraw;
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
glRasterPos2f(primScreenToGLX(x + character->offsetX),
|
||||
primScreenToGLY(y + fontCurrentFont->fullHeight + character->offsetY - clip));
|
||||
|
||||
glDrawPixels(character->width, character->height - clip, GL_RGB8, GL_UNSIGNED_BYTE, character->bitmap);
|
||||
#endif
|
||||
|
||||
noDraw:
|
||||
x += character->width + fontCurrentFont->spacing; //update screen location
|
||||
|
||||
@ -215,6 +215,13 @@ static inline void glVertex3fv(const GLfloat *v) {
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
@ -227,6 +234,8 @@ extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int glCheckExtension(const char *ext);
|
||||
|
||||
#endif
|
||||
|
||||
160
src/SDL/main.c
160
src/SDL/main.c
@ -5,7 +5,6 @@
|
||||
Created June 1997 by Luke Moloney.
|
||||
============================================================================*/
|
||||
|
||||
#include <limits.h> // for PATH_MAX
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -69,6 +68,10 @@
|
||||
#include "debugwnd.h"
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*=============================================================================
|
||||
Data:
|
||||
@ -1679,12 +1682,8 @@ udword keyLanguageTranslate(udword wParam)
|
||||
Name : HandleEvent
|
||||
Description : SDL event handling for the application
|
||||
Inputs : pEvent - Pointer to the event to handle
|
||||
Outputs :
|
||||
Return : Result of event handling (based on the event)
|
||||
----------------------------------------------------------------------------*/
|
||||
//long FAR PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
sdword HandleEvent (const SDL_Event* pEvent)
|
||||
{
|
||||
void HandleEvent(SDL_Event const* pEvent) {
|
||||
extern bool32 utilPlayingIntro;
|
||||
|
||||
/* Mouse button press times for double-click support. */
|
||||
@ -1710,9 +1709,7 @@ sdword HandleEvent (const SDL_Event* pEvent)
|
||||
{
|
||||
ActivateMe();
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
} else return;
|
||||
case SDL_APP_WILLENTERBACKGROUND:
|
||||
if (systemActive == TRUE)
|
||||
{ //we're being deactivated
|
||||
@ -1724,9 +1721,7 @@ sdword HandleEvent (const SDL_Event* pEvent)
|
||||
{
|
||||
DeactivateMe();
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0; //per documentation
|
||||
} else return; // per documentation
|
||||
|
||||
case SDL_KEYUP: //keys up/down
|
||||
switch (pEvent->key.keysym.sym)
|
||||
@ -1768,7 +1763,7 @@ sdword HandleEvent (const SDL_Event* pEvent)
|
||||
default:
|
||||
keyPressUp(keyLanguageTranslate(pEvent->key.keysym.scancode));//keyPressUp(KeyMapFromWindows(wParam));
|
||||
}
|
||||
return 0;
|
||||
return;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
/*
|
||||
@ -1780,11 +1775,11 @@ sdword HandleEvent (const SDL_Event* pEvent)
|
||||
*/
|
||||
keyPressDown(keyLanguageTranslate(pEvent->key.keysym.scancode));
|
||||
//keyPressDown(KeyMapFromWindows(wParam));
|
||||
return 0;
|
||||
return;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
CommandProcess(pEvent->user.code);
|
||||
return 0;
|
||||
return;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (!mouseDisabled)
|
||||
@ -1940,10 +1935,9 @@ sdword HandleEvent (const SDL_Event* pEvent)
|
||||
{
|
||||
mainActuallyQuit = TRUE;
|
||||
}
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // WindowProc
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@ -2038,30 +2032,83 @@ void mainCleanupAfterVideo(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Name : WinMain
|
||||
Description : Entry point to the game
|
||||
Inputs :
|
||||
hInstance - instance handle for application
|
||||
hPrevInstance - warning! does nothing under Win32!
|
||||
commandLine - un-tokenized command line string
|
||||
nCmdShow - run state (minimized etc.)
|
||||
Outputs :
|
||||
Return : Exit code (Windows provides an intelligible number)
|
||||
----------------------------------------------------------------------------*/
|
||||
/*
|
||||
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR commandLine, int nCmdShow)
|
||||
*/
|
||||
void main_loop() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
HandleEvent(&event);
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT) {
|
||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
printf("Resolution change: %d %d\n", event.window.data1, event.window.data2);
|
||||
if ((event.window.data1 > 320) && (event.window.data2 > 240))
|
||||
{
|
||||
MAIN_WindowWidth = event.window.data1;
|
||||
MAIN_WindowHeight = event.window.data2;
|
||||
(void)utyChangeResolution(MAIN_WindowWidth, MAIN_WindowHeight, MAIN_WindowDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == SDL_QUIT) {
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
|
||||
utyTasksDispatch(); // execute all tasks
|
||||
|
||||
if (opTimerActive) {
|
||||
if (taskTimeElapsed > (opTimerStart + opTimerLength)) {
|
||||
opTimerExpired();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
static char *errorString = NULL;
|
||||
// create persistent storage
|
||||
EM_ASM(
|
||||
// Make a directory other than '/'
|
||||
FS.mkdir('/home/web_user/.homeworld/');
|
||||
FS.mkdir('/home/web_user/.homeworld/SavedGames/');
|
||||
FS.mkdir('/home/web_user/.homeworldDownloadable/');
|
||||
FS.mkdir('/home/web_user/.homeworldDownloadable/SavedGames/');
|
||||
FS.mkdir('/assets/');
|
||||
|
||||
// Then mount with IDBFS type
|
||||
FS.mount(IDBFS, {}, '/home/web_user/.homeworld/SavedGames/');
|
||||
FS.mount(IDBFS, {}, '/home/web_user/.homeworldDownloadable/SavedGames/');
|
||||
FS.mount(IDBFS, {}, '/assets/');
|
||||
|
||||
// create symlinks to assets
|
||||
FS.symlink('/assets/Homeworld.big', 'Homeworld.big');
|
||||
FS.symlink('/assets/HW_Comp.vce', 'HW_Comp.vce');
|
||||
FS.symlink('/assets/HW_Music.wxd', 'HW_Music.wxd');
|
||||
|
||||
// Then sync
|
||||
FS.syncfs(true, function (err) {
|
||||
if (err) console.log("FS.syncfs error " + err);
|
||||
|
||||
// continue with main after filesystem is synced
|
||||
Module._main_postinit(0, 0);
|
||||
});
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
int EMSCRIPTEN_KEEPALIVE main_postinit(int argc, char* argv[]) {
|
||||
// file system sync is now complete
|
||||
// continue on
|
||||
|
||||
#else
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
#endif
|
||||
static char* errorString = NULL;
|
||||
#ifdef _WIN32
|
||||
static HANDLE hMapping;
|
||||
#endif
|
||||
static bool32 preInit;
|
||||
SDL_Event e;
|
||||
int event_res = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
//check to see if a copy of the program already running and just exit if so.
|
||||
@ -2193,42 +2240,41 @@ int main (int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (errorString == NULL)
|
||||
{
|
||||
if (errorString == NULL) {
|
||||
preInit = FALSE;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// 0 fps means to use requestAnimationFrame; non-0 means to use setTimeout.
|
||||
emscripten_set_main_loop(main_loop, 0, 1);
|
||||
#else
|
||||
|
||||
bool32 breakMainLoop = FALSE;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
// Give sound a break :)
|
||||
SDL_Delay(0);
|
||||
|
||||
while (SDL_PollEvent(&e))
|
||||
{
|
||||
event_res = HandleEvent(&e);
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
HandleEvent(&event);
|
||||
|
||||
if (e.type == SDL_QUIT) {
|
||||
breakMainLoop = TRUE;
|
||||
if (event.type == SDL_QUIT) {
|
||||
SDL_Quit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (breakMainLoop) break;
|
||||
|
||||
utyTasksDispatch(); //execute all tasks
|
||||
utyTasksDispatch(); // execute all tasks
|
||||
|
||||
if (opTimerActive)
|
||||
{
|
||||
if (taskTimeElapsed > (opTimerStart + opTimerLength))
|
||||
{
|
||||
if (opTimerActive) {
|
||||
if (taskTimeElapsed > (opTimerStart + opTimerLength)) {
|
||||
opTimerExpired();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //some error on startup, either from preInit or Init()
|
||||
if (preInit)
|
||||
{
|
||||
#endif
|
||||
} else { // some error on startup, either from preInit or Init()
|
||||
if (preInit) {
|
||||
(void)utyGameSystemsPreShutdown();
|
||||
}
|
||||
fprintf(stderr, "%s\n", errorString);
|
||||
@ -2241,5 +2287,5 @@ int main (int argc, char* argv[])
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
return event_res;
|
||||
} /* WinMain */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ void ActivateMe(void);
|
||||
void DeactivateMe(void);
|
||||
|
||||
// Event handler.
|
||||
sdword HandleEvent (const SDL_Event* pEvent);
|
||||
void HandleEvent(SDL_Event const* pEvent);
|
||||
|
||||
//load/save options from disk
|
||||
void utyOptionsFileRead(void);
|
||||
|
||||
@ -1325,6 +1325,7 @@ void mrCameraMotion(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (mouseCursorX() != MAIN_WindowWidth / 2 ||
|
||||
mouseCursorY() != MAIN_WindowHeight / 2)
|
||||
{
|
||||
@ -1334,7 +1335,18 @@ void mrCameraMotion(void)
|
||||
camMouseY = MAIN_WindowHeight / 2 - mouseCursorY();
|
||||
mousePositionSet(MAIN_WindowWidth / 2, MAIN_WindowHeight / 2);
|
||||
}
|
||||
|
||||
#else
|
||||
sdword mouseCursorXshifted = mrOldMouseX - mouseCursorX();
|
||||
sdword mouseCursorYshifted = mrOldMouseY - mouseCursorY();
|
||||
if (mouseCursorXshifted != 0 || mouseCursorYshifted != 0)
|
||||
{
|
||||
mrMouseHasMoved += abs(mouseCursorXshifted) + abs(mouseCursorYshifted);
|
||||
camMouseX = mouseCursorXshifted;
|
||||
camMouseY = mouseCursorYshifted;
|
||||
mrOldMouseX = mouseCursorX();
|
||||
mrOldMouseY = mouseCursorY();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -4369,7 +4381,9 @@ bool32 toDrawPulsedLine(vector linestart, vector lineend, real32 pulsesize, colo
|
||||
//draw the fadein
|
||||
if (draw_fadein)
|
||||
{
|
||||
glColor3ub(colRed(linecolor), colGreen(linecolor), colBlue(linecolor));
|
||||
glVertex3fv((GLfloat *)&fadestart);
|
||||
glColor3ub(colRed(linecolor), colGreen(linecolor), colBlue(linecolor));
|
||||
glVertex3fv((GLfloat *)&fadestart);
|
||||
}
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
@ -4380,27 +4394,33 @@ bool32 toDrawPulsedLine(vector linestart, vector lineend, real32 pulsesize, colo
|
||||
{
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&linestart);
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulsestart);
|
||||
}
|
||||
|
||||
//draw the pulse
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulsestart);
|
||||
|
||||
if (!pulse_at_end)
|
||||
{
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulseend);
|
||||
|
||||
//draw the line from the pulse to the end of the line
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulseend);
|
||||
glColor3ub(colRed(linecolor), colGreen(linecolor), colBlue(linecolor));
|
||||
|
||||
//draw the fadeout
|
||||
if (draw_fadeout)
|
||||
{
|
||||
glColor3ub(colRed(linecolor), colGreen(linecolor), colBlue(linecolor));
|
||||
glVertex3fv((GLfloat *)&fadeend);
|
||||
glColor3ub(colRed(linecolor), colGreen(linecolor), colBlue(linecolor));
|
||||
glVertex3fv((GLfloat *)&fadeend);
|
||||
}
|
||||
}
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&lineend);
|
||||
}
|
||||
glEnd();
|
||||
@ -4523,6 +4543,7 @@ void toDrawMoveFromLine(ShipPtr ship)
|
||||
//draw the line from the ship to the pulse
|
||||
glColor3ub(colRed(TO_MOVE_LINE_COLOR), colGreen(TO_MOVE_LINE_COLOR), colBlue(TO_MOVE_LINE_COLOR));
|
||||
glVertex3fv((GLfloat *)&shipback);
|
||||
glColor3ub(colRed(TO_MOVE_LINE_COLOR), colGreen(TO_MOVE_LINE_COLOR), colBlue(TO_MOVE_LINE_COLOR));
|
||||
glVertex3fv((GLfloat *)&ship->moveFrom);
|
||||
}
|
||||
glEnd();
|
||||
@ -4955,6 +4976,7 @@ void toPulse1(vector linestart, vector lineend, real32 pulsesize, color pulsecol
|
||||
{
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulsestart);
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulseend);
|
||||
|
||||
}
|
||||
@ -5162,6 +5184,7 @@ void toPulse2(vector linestart, vector lineend, real32 pulsesize, color pulsecol
|
||||
{
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulsestart);
|
||||
glColor3ub(colRed(pulsecolor), colGreen(pulsecolor), colBlue(pulsecolor));
|
||||
glVertex3fv((GLfloat *)&pulseend);
|
||||
|
||||
}
|
||||
@ -5669,12 +5692,15 @@ void mrRegionDraw(regionhandle reg)
|
||||
y = NIS_LetterHeight;
|
||||
}
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, nisBlackFade);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(y - NIS_EXCESSSCISSORMARGIN));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, nisBlackFade);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(MAIN_WindowHeight - y + NIS_EXCESSSCISSORMARGIN));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight - y + NIS_EXCESSSCISSORMARGIN));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, nisBlackFade);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(y - NIS_EXCESSSCISSORMARGIN));
|
||||
glColor4f(0.0f, 0.0f, 0.0f, nisBlackFade);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight - y + NIS_EXCESSSCISSORMARGIN));
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@ -1072,24 +1072,26 @@ void mouseDraw(void)
|
||||
|
||||
glColor3ub(255,255,255);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(SX(mouseCursorXPosition), SY(mouseCursorYPosition));
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(SX(mouseCursorXPosition), SY(mouseCursorYPosition + texture->height));
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(SX(mouseCursorXPosition + texture->width), SY(mouseCursorYPosition + texture->height));
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(SX(mouseCursorXPosition + texture->width), SY(mouseCursorYPosition));
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(SX(mouseCursorXPosition + texture->width), SY(mouseCursorYPosition + texture->height));
|
||||
glEnd();
|
||||
|
||||
rndTextureEnable(texOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
#ifndef __EMSCRIPTEN__
|
||||
glRasterPos2f(primScreenToGLX(mouseCursorXPosition),
|
||||
primScreenToGLY(mouseCursorYPosition + texture->height));
|
||||
glDrawPixels(texture->width, texture->height, GL_RGBA, GL_UNSIGNED_BYTE, texture->data);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
100
src/SDL/prim2d.c
100
src/SDL/prim2d.c
@ -88,10 +88,12 @@ void primModeClearFunction2(void)
|
||||
----------------------------------------------------------------------------*/
|
||||
void primTriSolid2(triangle *tri, color c)
|
||||
{
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x0), primScreenToGLY(tri->y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x1), primScreenToGLY(tri->y1));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x2), primScreenToGLY(tri->y2));
|
||||
glEnd();
|
||||
}
|
||||
@ -109,11 +111,13 @@ void primTriOutline2(triangle *tri, sdword thickness, color c)
|
||||
{
|
||||
GLfloat linewidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, &linewidth);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glLineWidth((GLfloat)thickness);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x0), primScreenToGLY(tri->y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x1), primScreenToGLY(tri->y1));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(tri->x2), primScreenToGLY(tri->y2));
|
||||
glEnd();
|
||||
glLineWidth(linewidth);
|
||||
@ -131,16 +135,18 @@ void primTriOutline2(triangle *tri, sdword thickness, color c)
|
||||
glVertex2f(primScreenToGLX(X), primScreenToGLY(Y));
|
||||
void primRectSolidTextured2(rectangle *rect)
|
||||
{
|
||||
glColor3ub(255, 255, 255);
|
||||
|
||||
rndTextureEnvironment(RTE_Replace);
|
||||
rndTextureEnable(TRUE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(0.0f, 0.0f, rect->x0, rect->y0);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(0.0f, 1.0f, rect->x0, rect->y1 - 1);
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1 - 1);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(1.0f, 0.0f, rect->x1, rect->y0);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1 - 1);
|
||||
glEnd();
|
||||
|
||||
rndTextureEnable(FALSE);
|
||||
@ -148,16 +154,18 @@ void primRectSolidTextured2(rectangle *rect)
|
||||
}
|
||||
void primRectSolidTexturedFullRect2(rectangle *rect)
|
||||
{
|
||||
glColor3ub(255, 255, 255);
|
||||
|
||||
rndTextureEnvironment(RTE_Replace);
|
||||
rndTextureEnable(TRUE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(0.0f, 0.0f, rect->x0, rect->y0);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(0.0f, 1.0f, rect->x0, rect->y1);
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(1.0f, 0.0f, rect->x1, rect->y0);
|
||||
glColor3ub(255, 255, 255);
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1);
|
||||
glEnd();
|
||||
|
||||
rndTextureEnable(FALSE);
|
||||
@ -165,15 +173,17 @@ void primRectSolidTexturedFullRect2(rectangle *rect)
|
||||
}
|
||||
void primRectSolidTexturedFullRectC2(rectangle *rect, color c)
|
||||
{
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
|
||||
rndTextureEnable(TRUE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
COORD(0.0f, 0.0f, rect->x0, rect->y0);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
COORD(0.0f, 1.0f, rect->x0, rect->y1);
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
COORD(1.0f, 0.0f, rect->x1, rect->y0);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
COORD(1.0f, 1.0f, rect->x1, rect->y1);
|
||||
glEnd();
|
||||
|
||||
rndTextureEnable(FALSE);
|
||||
@ -190,12 +200,15 @@ void primRectSolidTexturedFullRectC2(rectangle *rect, color c)
|
||||
----------------------------------------------------------------------------*/
|
||||
void primRectSolid2(rectangle *rect, color c)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y1));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@ -213,12 +226,15 @@ void primRectTranslucent2(rectangle* rect, color c)
|
||||
|
||||
blendOn = glIsEnabled(GL_BLEND);
|
||||
if (!blendOn) glEnable(GL_BLEND);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y1));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), colAlpha(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
glEnd();
|
||||
|
||||
if (!blendOn) glDisable(GL_BLEND);
|
||||
@ -239,13 +255,16 @@ void primRectOutline2(rectangle *rect, sdword thickness, color c)
|
||||
GLfloat linewidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, &linewidth);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glLineWidth((GLfloat)thickness);
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(bottom));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(bottom));
|
||||
glEnd();
|
||||
|
||||
@ -264,7 +283,7 @@ void primRectShaded2(rectangle *rect, color *c)
|
||||
{
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
|
||||
glColor3ub(colRed(c[0]), colGreen(c[0]), colBlue(c[0]));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y0));
|
||||
@ -272,12 +291,12 @@ void primRectShaded2(rectangle *rect, color *c)
|
||||
glColor3ub(colRed(c[1]), colGreen(c[1]), colBlue(c[1]));
|
||||
glVertex2f(primScreenToGLX(rect->x0), primScreenToGLY(rect->y1));
|
||||
|
||||
glColor3ub(colRed(c[2]), colGreen(c[2]), colBlue(c[2]));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
|
||||
glColor3ub(colRed(c[3]), colGreen(c[3]), colBlue(c[3]));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y0));
|
||||
|
||||
glColor3ub(colRed(c[2]), colGreen(c[2]), colBlue(c[2]));
|
||||
glVertex2f(primScreenToGLX(rect->x1), primScreenToGLY(rect->y1));
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@ -354,13 +373,13 @@ void primOvalArcOutline2(oval *o, real32 radStart, real32 radEnd, sdword thickne
|
||||
segment = (sdword)(radStart * (real32)segments / (2.0f * PI));//get starting segment
|
||||
endSegment = (sdword)(radEnd * (real32)segments / (2.0f * PI) - 0.01f);//get ending segment
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glLineWidth((GLfloat)thickness);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
x = centreX + (real32)sin((double)radStart) * width; //first vertex
|
||||
y = centreY + (real32)cos((double)radStart) * height;
|
||||
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(x, y);
|
||||
|
||||
segment++;
|
||||
@ -372,6 +391,7 @@ void primOvalArcOutline2(oval *o, real32 radStart, real32 radEnd, sdword thickne
|
||||
x = centreX + (real32)sin((double)angle) * width;
|
||||
y = centreY + (real32)cos((double)angle) * height;
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(x, y);
|
||||
|
||||
angle += angleInc; //update angle
|
||||
@ -379,6 +399,7 @@ void primOvalArcOutline2(oval *o, real32 radStart, real32 radEnd, sdword thickne
|
||||
x = centreX + (real32)sin((double)radEnd) * width;
|
||||
y = centreY + (real32)cos((double)radEnd) * height;
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(x, y); //draw last vertex
|
||||
|
||||
glEnd();
|
||||
@ -398,11 +419,12 @@ void primGLCircleOutline2(real32 x, real32 y, real32 radius, sdword nSegments, c
|
||||
double angle, angleInc = 2.0 * PI / (double)nSegments;
|
||||
real32 radiusY = radius * MAIN_WindowWidth / MAIN_WindowHeight;
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(x, y + radiusY);
|
||||
for (index = 0, angle = angleInc; index <= nSegments; index++, angle += angleInc)
|
||||
{
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(x + (real32)sin(angle) * radius, y + (real32)cos(angle) * radiusY);
|
||||
}
|
||||
glEnd();
|
||||
@ -445,9 +467,10 @@ void primLine2(sdword x0, sdword y0, sdword x1, sdword y1, color c)
|
||||
blendon = glIsEnabled(GL_BLEND);
|
||||
if (!blendon) glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_LINES);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
@ -464,9 +487,10 @@ void primLine2(sdword x0, sdword y0, sdword x1, sdword y1, color c)
|
||||
----------------------------------------------------------------------------*/
|
||||
void primNonAALine2(sdword x0, sdword y0, sdword x1, sdword y1, color c)
|
||||
{
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_LINES);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
|
||||
glEnd();
|
||||
}
|
||||
@ -485,9 +509,10 @@ void primLineThick2(sdword x0, sdword y0, sdword x1, sdword y1, sdword thickness
|
||||
GLfloat linewidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, &linewidth);
|
||||
glLineWidth((GLfloat)thickness);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_LINES);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x0), primScreenToGLY(y0));
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex2f(primScreenToGLX(x1), primScreenToGLY(y1));
|
||||
glEnd();
|
||||
glLineWidth(linewidth);
|
||||
@ -627,8 +652,10 @@ void primBeveledRectSolid(rectangle *rect, color c, uword xb, uword yb)
|
||||
|
||||
cull = glIsEnabled(GL_CULL_FACE) ? TRUE : FALSE;
|
||||
glDisable(GL_CULL_FACE);
|
||||
glBegin(GL_POLYGON);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex2f(SX((X0 + X1)/2.0), SY((Y0 + Y1)/2.0));
|
||||
glVertex2f(SX(X0+xb), SY(Y0));
|
||||
glVertex2f(SX(X1-xb), SY(Y0));
|
||||
glVertex2f(SX(X1), SY(Y0+yb));
|
||||
@ -637,11 +664,14 @@ void primBeveledRectSolid(rectangle *rect, color c, uword xb, uword yb)
|
||||
glVertex2f(SX(X0+xb), SY(Y1));
|
||||
glVertex2f(SX(X0), SY(Y1-yb));
|
||||
glVertex2f(SX(X0), SY(Y0+yb));
|
||||
glVertex2f(SX(X0+xb), SY(Y0));
|
||||
glEnd();
|
||||
|
||||
if (cull)
|
||||
{
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@ -980,9 +1010,11 @@ void primCircleBorder(sdword x, sdword y, sdword radInner, sdword radOuter, sdwo
|
||||
for (index = 0; index < nSlices; index++)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
||||
glColor4ub(red, green, blue, 255);
|
||||
|
||||
glVertex2f(x0, y0); //2 common points
|
||||
|
||||
glColor4ub(red, green, blue, 255);
|
||||
glVertex2f(centreX, centreY);
|
||||
|
||||
sinTheta = (real32)sin(theta);
|
||||
@ -990,13 +1022,17 @@ void primCircleBorder(sdword x, sdword y, sdword radInner, sdword radOuter, sdwo
|
||||
|
||||
x0 = centreX + sinTheta * radXInner;
|
||||
y0 = centreY + cosTheta * radYInner;
|
||||
|
||||
glColor4ub(red, green, blue, 255);
|
||||
glVertex2f(x0, y0); //complete
|
||||
glColor4ub(red, green, blue, 0);
|
||||
|
||||
x1 = centreX + sinTheta * radXOuter;
|
||||
y1 = centreY + cosTheta * radYOuter;
|
||||
|
||||
glColor4ub(red, green, blue, 0);
|
||||
glVertex2f(x1, y1); //complete
|
||||
|
||||
glColor4ub(red, green, blue, 0);
|
||||
glVertex2f(x2, y2);
|
||||
x2 = x1;
|
||||
y2 = y1;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
/*=============================================================================
|
||||
Functions:
|
||||
=============================================================================*/
|
||||
#ifdef HW_BUILD_FOR_DEBUGGING
|
||||
#if defined(HW_BUILD_FOR_DEBUGGING) && !defined(__EMSCRIPTEN__)
|
||||
|
||||
#define PRIM_ERROR_CHECKING 1 //general error checking
|
||||
|
||||
|
||||
@ -56,9 +56,10 @@ void primLine3(vector *p1, vector *p2, color c)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
rndAdditiveBlends(FALSE);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_LINES);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv((const GLfloat *)p1);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv((const GLfloat *)p2);
|
||||
glEnd();
|
||||
|
||||
@ -83,21 +84,23 @@ void primCircleSolid3(vector *centre, real32 radius, sdword nSlices, color c)
|
||||
GLfloat v[3];
|
||||
double theta;
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y;
|
||||
v[2] = centre->z;
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv(v); //centre vertex
|
||||
for (index = 0, theta = 0.0; index < nSlices; index++)
|
||||
{
|
||||
v[0] = centre->x + (real32)(sin(theta)) * radius;
|
||||
v[1] = centre->y + (real32)(cos(theta)) * radius;
|
||||
theta += 2.0 * PI / (double)nSlices;
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv(v); //vertex on outer rim
|
||||
}
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y + radius;
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv(v); //final vertex on outer rim
|
||||
glEnd();
|
||||
}
|
||||
@ -115,21 +118,23 @@ void primCircleSolid3Fade(vector *centre, real32 radius, sdword nSlices, color c
|
||||
rndAdditiveBlends(FALSE);
|
||||
}
|
||||
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y;
|
||||
v[2] = centre->z;
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
glVertex3fv(v); //centre vertex
|
||||
for (index = 0, theta = 0.0; index < nSlices; index++)
|
||||
{
|
||||
v[0] = centre->x + (real32)(sin(theta)) * radius;
|
||||
v[1] = centre->y + (real32)(cos(theta)) * radius;
|
||||
theta += 2.0 * PI / (double)nSlices;
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
glVertex3fv(v); //vertex on outer rim
|
||||
}
|
||||
v[0] = centre->x;
|
||||
v[1] = centre->y + radius;
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
glVertex3fv(v); //final vertex on outer rim
|
||||
glEnd();
|
||||
|
||||
@ -235,7 +240,6 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
nSpokes = nSlices / nSpokes;
|
||||
}
|
||||
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
c[0] = centre->x; //compute centre point
|
||||
c[1] = centre->y;
|
||||
c[2] = centre->z;
|
||||
@ -258,6 +262,7 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[1] = centre->y + vec_ptr->y * radius;
|
||||
rim[2] = centre->z + vec_ptr->z * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim); //vertex on rim
|
||||
}
|
||||
glEnd();
|
||||
@ -271,7 +276,9 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[1] = centre->y + vec_ptr->y * radius;
|
||||
rim[2] = centre->z + vec_ptr->z * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(c);
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim);
|
||||
}
|
||||
glEnd();
|
||||
@ -287,6 +294,7 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[0] = centre->x + vec_ptr->x * radius;
|
||||
rim[2] = centre->z + vec_ptr->z * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim); //vertex on rim
|
||||
}
|
||||
glEnd();
|
||||
@ -300,7 +308,9 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[0] = centre->x + vec_ptr->x * radius;
|
||||
rim[2] = centre->z + vec_ptr->z * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(c);
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim);
|
||||
}
|
||||
glEnd();
|
||||
@ -316,6 +326,7 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[0] = centre->x + vec_ptr->x * radius;
|
||||
rim[1] = centre->y + vec_ptr->y * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim); //vertex on rim
|
||||
}
|
||||
glEnd();
|
||||
@ -329,7 +340,9 @@ void primCircleOutline3(vector *centre, real32 radius, sdword nSlices,
|
||||
{
|
||||
rim[0] = centre->x + vec_ptr->x * radius;
|
||||
rim[1] = centre->y + vec_ptr->y * radius;
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(c);
|
||||
glColor3ub(colRed(color), colGreen(color), colBlue(color));
|
||||
glVertex3fv(rim);
|
||||
}
|
||||
glEnd();
|
||||
@ -403,7 +416,6 @@ void primEllipseOutlineZ(vector *centre, real32 rx, real32 ry, sdword nSegments,
|
||||
|
||||
theta = 0.0f;
|
||||
thetaDelta = 2.0 * PI / (double)nSegments;
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
x = centre->x;
|
||||
y = centre->y;
|
||||
rim[2] = centre->z;
|
||||
@ -412,6 +424,7 @@ void primEllipseOutlineZ(vector *centre, real32 rx, real32 ry, sdword nSegments,
|
||||
{
|
||||
rim[0] = x + (real32)sin(theta) * rx;
|
||||
rim[1] = y + (real32)cos(theta) * ry;
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3fv(rim);
|
||||
theta += thetaDelta;
|
||||
}
|
||||
@ -428,8 +441,8 @@ void primEllipseOutlineZ(vector *centre, real32 rx, real32 ry, sdword nSegments,
|
||||
----------------------------------------------------------------------------*/
|
||||
void primPoint3(vector *p1, color c)
|
||||
{
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_POINTS);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3f(p1->x, p1->y, p1->z); //!!! no size
|
||||
glEnd();
|
||||
}
|
||||
@ -511,8 +524,8 @@ void primEndPointSize3Fade(void)
|
||||
void primPointSize3(vector *p1, real32 size, color c)
|
||||
{
|
||||
glPointSize(size);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glBegin(GL_POINTS);
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glVertex3f(p1->x, p1->y, p1->z); //!!! no size
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
@ -528,8 +541,8 @@ void primPointSize3Fade(vector *p1, real32 size, color c, real32 fade)
|
||||
}
|
||||
|
||||
glPointSize(size);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
glBegin(GL_POINTS);
|
||||
glColor4ub(colRed(c), colGreen(c), colBlue(c), (ubyte)(fade * 255.0f));
|
||||
glVertex3f(p1->x, p1->y, p1->z); //!!! no size
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
@ -558,29 +571,60 @@ static void primSolidTexture3_multi(vector* p1, real32 size, color c, trhandle t
|
||||
rndAdditiveBlends(TRUE);
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor3ub(colRed(c), colGreen(c), colBlue(c));
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor3ub(172, 172, 172);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -620,17 +664,22 @@ void primSolidTexture3(vector *p1, real32 size, color c, trhandle tex)
|
||||
biasGreen = colReal32(colGreen(c));
|
||||
biasBlue = colReal32(colBlue(c));
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor3f(biasRed, biasGreen, biasBlue);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor3f(biasRed, biasGreen, biasBlue);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor3f(biasRed, biasGreen, biasBlue);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor3f(biasRed, biasGreen, biasBlue);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -659,17 +708,22 @@ void primSolidTexture3Fade(vector *p1, real32 size, color c, trhandle tex, real3
|
||||
biasGreen = colReal32(colGreen(c));
|
||||
biasBlue = colReal32(colBlue(c));
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glColor4f(biasRed, biasGreen, biasBlue, fade);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y-halfsize, 0.0f);
|
||||
|
||||
glColor4f(biasRed, biasGreen, biasBlue, fade);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y-halfsize, 0.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor4f(biasRed, biasGreen, biasBlue, fade);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex3f(p1->x-halfsize, p1->y+halfsize, 0.0f);
|
||||
|
||||
glColor4f(biasRed, biasGreen, biasBlue, fade);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex3f(p1->x+halfsize, p1->y+halfsize, 0.0f);
|
||||
glEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
111
src/SDL/render.c
111
src/SDL/render.c
@ -150,6 +150,8 @@ static EGLSurface egl_surface = EGL_NO_SURFACE;
|
||||
static EGLContext egl_context = EGL_NO_CONTEXT;
|
||||
static EGLConfig egl_config;
|
||||
#else
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
PFNGLBINDBUFFERPROC glBindBuffer = 0;
|
||||
PFNGLDELETEBUFFERSPROC glDeleteBuffers = 0;
|
||||
PFNGLGENBUFFERSPROC glGenBuffers = 0;
|
||||
@ -158,6 +160,7 @@ PFNGLBUFFERSUBDATAPROC glBufferSubData = 0;
|
||||
PFNGLTEXSTORAGE2DPROC glTexStorage2D = 0;
|
||||
PFNGLGENERATEMIPMAPPROC glGenerateMipmap = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static char const* gl_extensions = 0;
|
||||
|
||||
@ -189,7 +192,6 @@ udword rndTextureEnviron = RTE_Modulate;
|
||||
bool32 rndAdditiveBlending = FALSE;
|
||||
bool32 rndLightingEnabled = TRUE;
|
||||
bool32 rndNormalization = FALSE;
|
||||
bool32 rndPerspectiveCorrect = FALSE;
|
||||
bool32 rndScissorEnabled = FALSE;
|
||||
bool32 rndTextureEnabled = FALSE;
|
||||
|
||||
@ -901,21 +903,16 @@ bool32 setupPixelFormat()
|
||||
#ifndef HW_ENABLE_GLES
|
||||
/* Set attributes. */
|
||||
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, MAIN_WindowDepth);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifndef HW_BUILD_FOR_DEBUGGING
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
#elif defined HW_BUILD_FOR_DEBUGGING
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (/* main */ fullScreen)
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
#endif
|
||||
#else
|
||||
if (/* main */ fullScreen)
|
||||
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
#endif
|
||||
|
||||
#ifdef HW_ENABLE_GLES
|
||||
@ -1022,6 +1019,7 @@ bool32 setupPixelFormat()
|
||||
lastDepth = MAIN_WindowDepth;
|
||||
lastFull = fullScreen;
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
glBindBuffer = SDL_GL_GetProcAddress("glBindBuffer");
|
||||
glDeleteBuffers = SDL_GL_GetProcAddress("glDeleteBuffers");
|
||||
glGenBuffers = SDL_GL_GetProcAddress("glGenBuffers");
|
||||
@ -1029,6 +1027,7 @@ bool32 setupPixelFormat()
|
||||
glBufferSubData = SDL_GL_GetProcAddress("glBufferSubData");
|
||||
glTexStorage2D = SDL_GL_GetProcAddress("glTexStorage2D");
|
||||
glGenerateMipmap = SDL_GL_GetProcAddress("glGenerateMipmap");
|
||||
#endif
|
||||
|
||||
gl_extensions = glGetString(GL_EXTENSIONS);
|
||||
printf("GL Extensions:\n%s\n", gl_extensions);
|
||||
@ -2592,7 +2591,6 @@ void rndMainViewRenderFunction(Camera *camera)
|
||||
dbgAssertOrIgnore(spaceobj->renderlink.belongto != NULL);
|
||||
|
||||
g_WireframeHack = FALSE;
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
|
||||
switch (spaceobj->objtype)
|
||||
{
|
||||
@ -2768,11 +2766,6 @@ dontdraw:
|
||||
|
||||
if (!result)
|
||||
{
|
||||
if (spaceobj->currentLOD == 0)
|
||||
{
|
||||
rndPerspectiveCorrection(TRUE);
|
||||
}
|
||||
|
||||
meshRenders++;
|
||||
|
||||
if (rndInsideShip(spaceobj, camera))
|
||||
@ -2870,8 +2863,6 @@ dontdraw:
|
||||
}
|
||||
spaceobj->renderedLODs |= (1 << spaceobj->currentLOD);
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
|
||||
//navlights
|
||||
if (!bitTest(spaceobj->flags, SOF_Cloaked))
|
||||
{
|
||||
@ -2969,8 +2960,6 @@ dontdraw:
|
||||
}
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
|
||||
rndFade(spaceobj, camera);
|
||||
if (!bitTest(spaceobj->flags, SOF_Cloaked) || (((Ship*)spaceobj)->playerowner == universe.curPlayerPtr) || proximityCanPlayerSeeShip(universe.curPlayerPtr,(Ship*)spaceobj))
|
||||
|
||||
@ -3103,10 +3092,6 @@ renderDefault:
|
||||
{
|
||||
rndFade(spaceobj, camera);
|
||||
|
||||
if (spaceobj->currentLOD == 0)
|
||||
{
|
||||
rndPerspectiveCorrection(TRUE);
|
||||
}
|
||||
rndGLStateLog("Before Derelict");
|
||||
meshRenders++;
|
||||
meshRender((meshdata *)level->pData,colorScheme);
|
||||
@ -3118,7 +3103,6 @@ renderDefault:
|
||||
RenderNAVLights((Ship*)spaceobj);
|
||||
}
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
#if DEBUG_VERBOSE_SHIP_STATS
|
||||
if (rndDisplayFrameRate)
|
||||
{
|
||||
@ -3229,8 +3213,6 @@ renderDefault:
|
||||
|
||||
alodAdjustScaleFactor();
|
||||
|
||||
rndPerspectiveCorrection(FALSE);
|
||||
|
||||
nebRender();
|
||||
|
||||
if (rndPostObjectCallback != NULL)
|
||||
@ -3736,32 +3718,46 @@ void rndDrawScissorBars(bool32 scissorEnabled)
|
||||
dbgAssertOrIgnore(!nisFullyScissored || !scissorEnabled);
|
||||
dbgAssertOrIgnore((nisScissorFade > 0.0f && nisScissorFade <= 1.0f) || !scissorEnabled);
|
||||
glColor3f(MR_LetterboxGrey);
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
//top grey part
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(0));
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(0));
|
||||
glVertex2f(primScreenToGLX(-1), GLy);
|
||||
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(0));
|
||||
glVertex2f(primScreenToGLX(-1), GLy);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), GLy);
|
||||
|
||||
//bottom scissor part
|
||||
glVertex2f(primScreenToGLX(-1), oneGLy);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(MAIN_WindowHeight));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight));
|
||||
|
||||
glVertex2f(primScreenToGLX(-1), oneGLy);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), oneGLy);
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glColor4f(0.0f, 0.0f, 0.0f, nisScissorFade);
|
||||
}
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_TRIANGLES);
|
||||
//top scissor part
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(0));
|
||||
glVertex2f(primScreenToGLX(-1), GLy);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), GLy);
|
||||
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(0));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), GLy);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(0));
|
||||
|
||||
//bottom scissor part
|
||||
glVertex2f(primScreenToGLX(-1), oneGLy);
|
||||
glVertex2f(primScreenToGLX(-1), primScreenToGLY(MAIN_WindowHeight));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight));
|
||||
|
||||
glVertex2f(primScreenToGLX(-1), oneGLy);
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), primScreenToGLY(MAIN_WindowHeight));
|
||||
glVertex2f(primScreenToGLX(MAIN_WindowWidth), oneGLy);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
@ -4139,55 +4135,6 @@ udword rndTextureEnvironment(udword textureMode)
|
||||
return oldMode;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Name : rndPerspectiveCorrection
|
||||
Description : provides a hint to the GL as to whether to perspectively correct textures
|
||||
Inputs : bEnable - TRUE enables (NICEST), FALSE disables (FASTEST)
|
||||
Outputs : may toggle rndPerspectiveCorrect
|
||||
Return : previous status
|
||||
----------------------------------------------------------------------------*/
|
||||
sdword rndPerspectiveCorrection(sdword bEnable)
|
||||
{
|
||||
sdword oldStatus = rndPerspectiveCorrect;
|
||||
#if USE_RND_HINT
|
||||
if (rndHint > 0)
|
||||
{
|
||||
if (rndHint == 1)
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
rndPerspectiveCorrect = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
rndPerspectiveCorrect = FALSE;
|
||||
}
|
||||
return(oldStatus);
|
||||
}
|
||||
#endif
|
||||
if (mainNoPerspective)
|
||||
{
|
||||
return(oldStatus);
|
||||
}
|
||||
if (bEnable)
|
||||
{
|
||||
if (!rndPerspectiveCorrect)
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
rndPerspectiveCorrect = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rndPerspectiveCorrect)
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
rndPerspectiveCorrect = FALSE;
|
||||
}
|
||||
}
|
||||
return(oldStatus);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Name : rndNormalizeEnable
|
||||
Description : enables or disables normalization
|
||||
@ -4466,16 +4413,6 @@ void rndResetGLState(void)
|
||||
glDisable(GL_NORMALIZE);
|
||||
}
|
||||
rndNormalizeEnable(rndNormalization);
|
||||
|
||||
if (rndPerspectiveCorrect)
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
}
|
||||
rndPerspectiveCorrection(rndPerspectiveCorrect);
|
||||
|
||||
rndTextureEnvironment(RTE_Modulate);
|
||||
|
||||
|
||||
@ -139,7 +139,6 @@ sdword rndTextureEnable(sdword bEnable);
|
||||
void rndBillboardEnable(vector *centre);
|
||||
void rndBillboardDisable(void);
|
||||
udword rndTextureEnvironment(udword mode);
|
||||
sdword rndPerspectiveCorrection(sdword bEnable);
|
||||
sdword rndNormalizeEnable(sdword bEnable);
|
||||
sdword rndAdditiveBlends(sdword bAdditive);
|
||||
sdword rndMaterialfv(sdword face, sdword pname, real32* params);
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#define EQ_STEP 0.1
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(__EMSCRIPTEN__)
|
||||
#define SDL_BUFFERSIZE 4*FQ_SIZE
|
||||
#else
|
||||
#define SDL_BUFFERSIZE FQ_SIZE
|
||||
@ -33,7 +33,7 @@ typedef struct
|
||||
} BANKPOINTERS;
|
||||
|
||||
/* function in speechevent.c that needs to be called when shutting down */
|
||||
void musicEventUpdateVolume(void);
|
||||
sdword musicEventUpdateVolume(void);
|
||||
|
||||
/* internal functions */
|
||||
sdword SNDgetchannel(sword patchnum, sdword priority);
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
#include "glinc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "Debug.h"
|
||||
#include "Memory.h"
|
||||
#include "Twiddle.h"
|
||||
@ -150,7 +149,7 @@ void trStartup(void)
|
||||
trNoPalStartup(); //must come before trReset
|
||||
trReset(); //reset the newly-allocated texture registry
|
||||
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
//(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "utility.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -4226,12 +4225,14 @@ DONE_INTROS:
|
||||
// }
|
||||
|
||||
#ifdef HW_GAME_DEMO
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (enableAVI)
|
||||
{
|
||||
primModeSetFunction2();
|
||||
psModeBegin("Plugscreens\\", PMF_CanSkip);
|
||||
psScreenStart("SierraIntro.plug");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (demDemoRecording)
|
||||
{ //if recording a demo
|
||||
@ -4898,6 +4899,11 @@ bool32 utyChangeResolution(sdword width, sdword height, sdword depth) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
rndAspectRatio = (GLfloat)width/(GLfloat)height;
|
||||
glViewport(0, 0, width, height);
|
||||
#endif
|
||||
|
||||
ghMainRegion->rect.x1 = width;
|
||||
ghMainRegion->rect.y1 = height;
|
||||
|
||||
@ -4943,7 +4949,7 @@ void utyToggleKeyStatesRestore(void)
|
||||
{
|
||||
SDL_Keymod target = 0;
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
#if !defined(_WIN32) && !defined(_MACOSX)
|
||||
#if !defined(_WIN32) && !defined(_MACOSX) && !defined(__EMSCRIPTEN__)
|
||||
SDL_SysWMinfo info;
|
||||
SDL_VERSION(&info.version);
|
||||
SDL_GetWindowWMInfo(sdlwindow,&info);
|
||||
@ -4969,7 +4975,7 @@ void utyToggleKeyStatesRestore(void)
|
||||
|
||||
// Simulate a key release
|
||||
keybd_event( VK_CAPITAL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||
#elif !defined(_MACOSX)
|
||||
#elif !defined(_MACOSX) && !defined(__EMSCRIPTEN__)
|
||||
xe.xkey.keycode = XKeysymToKeycode(info.info.x11.display, XK_Caps_Lock);
|
||||
|
||||
// Simulate a key press
|
||||
@ -4992,7 +4998,7 @@ void utyToggleKeyStatesRestore(void)
|
||||
|
||||
// Simulate a key release
|
||||
keybd_event( VK_SCROLL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||
#elif !defined(_MACOSX)
|
||||
#elif !defined(_MACOSX) && !defined(__EMSCRIPTEN__)
|
||||
xe.xkey.keycode = XKeysymToKeycode(info.info.x11.display, XK_Scroll_Lock);
|
||||
|
||||
// Simulate a key press
|
||||
@ -5014,7 +5020,7 @@ void utyToggleKeyStatesRestore(void)
|
||||
|
||||
// Simulate a key release
|
||||
keybd_event( VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
|
||||
#elif !defined(_MACOSX)
|
||||
#elif !defined(_MACOSX) && !defined(__EMSCRIPTEN__)
|
||||
xe.xkey.keycode = XKeysymToKeycode(info.info.x11.display, XK_Num_Lock);
|
||||
|
||||
// Simulate a key press
|
||||
|
||||
@ -145,12 +145,12 @@ scriptStructEntry LIStaticScriptTable[] =
|
||||
{ "flightmanEvasiveBehind", (void(*)(char *,char *,void*))scriptSetFlightManEvasiveBehindCB, &(GenericInterceptorStatic.flightmanProb), &(GenericInterceptorStatic) },
|
||||
{ "flightmanEvasiveFront", (void(*)(char *,char *,void*))scriptSetFlightManEvasiveFrontCB, &(GenericInterceptorStatic.flightmanProb), &(GenericInterceptorStatic) },
|
||||
{ "flightmanEvasivePure", (void(*)(char *,char *,void*))scriptSetFlightManEvasivePureCB, &(GenericInterceptorStatic.flightmanProb), &(GenericInterceptorStatic) },
|
||||
{ "maxFlyAwayDist", (void(*)(char *,char *,void*))scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.maxFlyAwayDist), &(GenericInterceptorStatic) },
|
||||
{ "breakRange", (void(*)(char *,char *,void*))scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.breakRange), &(GenericInterceptorStatic) },
|
||||
{ "flyPastDist", (void(*)(char *,char *,void*))scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.flyPastDist), &(GenericInterceptorStatic) },
|
||||
{ "triggerHappy", (void(*)(char *,char *,void*))scriptSetCosAngCB_ARRAY, &(GenericInterceptorStatic.triggerHappy), &(GenericInterceptorStatic) },
|
||||
{ "faceTargetAccuracy", (void(*)(char *,char *,void*))scriptSetCosAngCB_ARRAY, &(GenericInterceptorStatic.faceTargetAccuracy), &(GenericInterceptorStatic) },
|
||||
{ "maxAttackTime", (void(*)(char *,char *,void*))scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.maxAttackTime), &(GenericInterceptorStatic) },
|
||||
{ "maxFlyAwayDist", scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.maxFlyAwayDist), &(GenericInterceptorStatic) },
|
||||
{ "breakRange", scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.breakRange), &(GenericInterceptorStatic) },
|
||||
{ "flyPastDist", scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.flyPastDist), &(GenericInterceptorStatic) },
|
||||
{ "triggerHappy", scriptSetCosAngCB_ARRAY, &(GenericInterceptorStatic.triggerHappy), &(GenericInterceptorStatic) },
|
||||
{ "faceTargetAccuracy", scriptSetCosAngCB_ARRAY, &(GenericInterceptorStatic.faceTargetAccuracy), &(GenericInterceptorStatic) },
|
||||
{ "maxAttackTime", scriptSetReal32CB_ARRAY, &(GenericInterceptorStatic.maxAttackTime), &(GenericInterceptorStatic) },
|
||||
|
||||
END_SCRIPT_STRUCT_ENTRY
|
||||
};
|
||||
|
||||
@ -18,6 +18,7 @@ exe_tools_kas2c = executable('kas2c',
|
||||
src_tools_kas2c,
|
||||
gen_output_parser,
|
||||
gen_output_lexer,
|
||||
native: true,
|
||||
implicit_include_directories: true,
|
||||
dependencies: dep_sdl,
|
||||
c_args: c_args)
|
||||
c_args: c_base_args)
|
||||
|
||||
1326
wasm/index.html
Normal file
1326
wasm/index.html
Normal file
File diff suppressed because one or more lines are too long
14
wasm32-emscripten.meson-cross-build-definition.txt
Normal file
14
wasm32-emscripten.meson-cross-build-definition.txt
Normal file
@ -0,0 +1,14 @@
|
||||
[binaries]
|
||||
c = 'emcc'
|
||||
cpp = 'em++'
|
||||
ar = 'emar'
|
||||
strip = 'emstrip'
|
||||
pkg-config = 'pkg-config'
|
||||
|
||||
[host_machine]
|
||||
system = 'emscripten'
|
||||
cpu_family = 'wasm32'
|
||||
cpu = 'wasm32'
|
||||
endian = 'little'
|
||||
|
||||
[properties]
|
||||
Loading…
x
Reference in New Issue
Block a user