Feature/renderer (#29)
* Adds first cut of GL renderer * Adds harness: where we add modern code to interface with the original game code
This commit is contained in:
parent
60309ba905
commit
0246c1de7f
|
@ -7,6 +7,8 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install deps
|
||||
run: make install-deps
|
||||
- name: build
|
||||
run: make build
|
||||
- name: test
|
||||
|
|
11
Makefile
11
Makefile
|
@ -1,17 +1,17 @@
|
|||
.PHONY: build clean test run
|
||||
.PHONY: build clean test install-deps run
|
||||
|
||||
all: build test
|
||||
|
||||
build:
|
||||
@echo "Building fw"
|
||||
@$(MAKE) -C src/framework build
|
||||
@echo "Building harness"
|
||||
@$(MAKE) -C src/harness build
|
||||
@echo "Building brender"
|
||||
@$(MAKE) -C src/BRSRC13 build
|
||||
@echo "Building dethrace"
|
||||
@$(MAKE) -C src/DETHRACE build
|
||||
|
||||
clean:
|
||||
@$(MAKE) -C src/framework clean
|
||||
@$(MAKE) -C src/harness clean
|
||||
@$(MAKE) -C src/BRSRC13 clean
|
||||
@$(MAKE) -C src/DETHRACE clean
|
||||
@$(MAKE) -C test clean
|
||||
|
@ -22,6 +22,9 @@ test: build
|
|||
@cp -r test/assets/DATA test/build
|
||||
@(cd test/build && ./c1tests $$DR_TEST_ARGS)
|
||||
|
||||
install-deps:
|
||||
sudo apt-get install libsdl2-dev
|
||||
|
||||
run: build
|
||||
@echo "Running dethrace"
|
||||
@./run.sh
|
||||
|
|
|
@ -4,6 +4,15 @@
|
|||
|
||||
 [Discord Chat Channel](https://discord.gg/f5StsuP)
|
||||
|
||||
## Install dependencies
|
||||
|
||||
### SDL2
|
||||
|
||||
OSX:
|
||||
```sh
|
||||
brew install SDL2
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```sh
|
||||
|
|
|
@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
### July 6 2020
|
||||
- OpenGL renderer added. Shows nothing but a black screen then exits.
|
||||
|
||||
### November 25, 2019
|
||||
- First unit tests added and hooked up to the CI build pipeline
|
||||
|
||||
|
|
2
run.sh
2
run.sh
|
@ -9,4 +9,4 @@ set -eu
|
|||
|
||||
CODE_DIR=$(pwd)
|
||||
cd ${DETHRACE_ROOT_DIR}
|
||||
${CODE_DIR}/src/DETHRACE/build/c1
|
||||
${CODE_DIR}/src/DETHRACE/build/c1 -lomem
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "dosio.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "pixelmap.h"
|
||||
#include <stddef.h>
|
||||
|
||||
br_pixelmap* DOSGfxBegin(char* setup_string) {
|
||||
LOG_TRACE("(\"%s\")", setup_string);
|
||||
// Original implementation replaced with SDL...
|
||||
|
||||
return BrPixelmapAllocate(BR_PMT_INDEX_8, 640, 480, NULL, BR_PMAF_NORMAL);
|
||||
Harness_Hook_DOSGfxBegin();
|
||||
return BrPixelmapAllocate(BR_PMT_INDEX_8, 320, 240, NULL, BR_PMAF_NORMAL);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "eventq.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
int _DOSEventQEnabled;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "readmse.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
host_real_memory mouseMemory;
|
||||
host_regs regs;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "assocarr.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
// Offset: 27
|
||||
// Size: 145
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brbegin.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include "CORE/HOST/himage.h"
|
||||
#include "CORE/PIXELMAP/pmsetup.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brbhook.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[49];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brlists.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brprintf.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "bswap.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[47];
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "CORE/FW/fwsetup.h"
|
||||
#include "CORE/FW/resource.h"
|
||||
#include "CORE/STD/brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "file.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -193,7 +193,7 @@ int TextReadLine(br_datafile* df, char** ident, char** data) {
|
|||
// EAX: df
|
||||
// EDX: t
|
||||
br_uint_16 scalarTypeConvert(br_datafile* df, br_uint_16 t) {
|
||||
LOG_TRACE("(%p, %d)", df, t);
|
||||
LOG_TRACE9("(%p, %d)", df, t);
|
||||
|
||||
if (df->scalar_type < BRT_FIXED) {
|
||||
goto LABEL_20;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "devlist.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[53];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "devsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -73,7 +73,7 @@ void BrDevEndOld() {
|
|||
// Offset: 1988
|
||||
// Size: 57
|
||||
void BrDevPaletteSetOld(br_pixelmap* pm) {
|
||||
LOG_WARN("TODO: capture palette");
|
||||
Harness_Hook_BrDevPaletteSetOld(pm);
|
||||
}
|
||||
|
||||
// Offset: 2069
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "diag.h"
|
||||
#include "CORE/STD/brstdlib.h"
|
||||
#include "brprintf.h"
|
||||
#include "debug.h"
|
||||
#include "fwsetup.h"
|
||||
#include "harness.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
// Global variables
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "error.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[47];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "CORE/FW/fwsetup.h"
|
||||
#include "CORE/FW/resource.h"
|
||||
#include "CORE/STD/brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "CORE/STD/brstddiag.h"
|
||||
#include "CORE/STD/brstdfile.h"
|
||||
#include "CORE/STD/brstdmem.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "genfile.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
br_file_struct_member file_info_FM[2];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "image.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[50];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "lexer.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
// Offset: 11
|
||||
// Size: 30
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "loader.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[49];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "CORE/FW/fwsetup.h"
|
||||
#include "CORE/STD/brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[45];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "object.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "objectc.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[49];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "pattern.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <ctype.h>
|
||||
|
||||
char rscid[49];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "register.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include "brlists.h"
|
||||
#include "fwsetup.h"
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "brlists.h"
|
||||
#include "brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "file.h"
|
||||
#include "fwsetup.h"
|
||||
#include "harness.h"
|
||||
#include "mem.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "resreg.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include "CORE/FW/fwsetup.h"
|
||||
#include "CORE/FW/register.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "scratch.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char scratchString[512];
|
||||
char rscid[49];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "sys_conf.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_token valid_system_config_tokens[5];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "token.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_token_entry predefinedTokens[457];
|
||||
char rscid[48];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "tokenval.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "resource.h"
|
||||
|
||||
char rscid[50];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "himage.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
// Offset: 14
|
||||
// Size: 40
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "hook.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
// Offset: 18
|
||||
// Size: 168
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "hostcfg.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
// Offset: 18
|
||||
// Size: 40
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "hstsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
host_info hostInfo;
|
||||
void* functionPointers_BRHOST1[50];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "memmgmt.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "angles.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
order_info OrderAxes[32];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "matrix23.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_matrix23 mattmp1;
|
||||
br_matrix23 mattmp2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "matrix34.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_matrix34 mattmp1;
|
||||
br_matrix34 mattmp2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "matrix4.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[51];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "plane.h"
|
||||
#include "brmath.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <math.h>
|
||||
|
||||
char rscid[49];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "quat.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "transfrm.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[52];
|
||||
br_uint_8 _CombineTransforms[7][7];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "vector.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[50];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "genclip.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[49];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "gencopy.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[49];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "pixelmap.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "pmmem.h"
|
||||
|
||||
char rscid[50];
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include "pmdsptch.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "pmmem.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char rscid[65];
|
||||
|
||||
|
@ -102,7 +103,17 @@ br_pixelmap* BrPixelmapClone(br_pixelmap* src) {
|
|||
// Offset: 2147
|
||||
// Size: 57
|
||||
void BrPixelmapFill(br_pixelmap* dst, br_uint_32 colour) {
|
||||
NOT_IMPLEMENTED();
|
||||
br_uint_8 linear_wholepixels; //added JeffH
|
||||
LOG_TRACE("(%p, %d)", dst, colour);
|
||||
|
||||
linear_wholepixels = BR_PMF_LINEAR | BR_PMF_ROW_WHOLEPIXELS;
|
||||
if ((dst->flags & linear_wholepixels) == linear_wholepixels) {
|
||||
if (dst->row_bytes > 0) {
|
||||
memset(dst->pixels, colour, dst->row_bytes * dst->height);
|
||||
} else {
|
||||
LOG_PANIC("Not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Offset: 2224
|
||||
|
@ -152,7 +163,39 @@ br_error DispatchRectangleStretchCopy(br_device_pixelmap* self, br_rectangle* r,
|
|||
void BrPixelmapRectangleCopy(br_pixelmap* dst, br_int_32 dx, br_int_32 dy, br_pixelmap* src, br_int_32 sx, br_int_32 sy, br_int_32 w, br_int_32 h) {
|
||||
br_rectangle r;
|
||||
br_point p;
|
||||
NOT_IMPLEMENTED();
|
||||
|
||||
// Taken from Errol's brender
|
||||
|
||||
br_uint_8* src_pix = (br_uint_8*)src->pixels;
|
||||
br_uint_8* dst_pix = (br_uint_8*)dst->pixels;
|
||||
|
||||
if (src->type != dst->type) {
|
||||
LOG_PANIC("src and dst types don't match! src is %d and dst is %d", src->type, dst->type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (src->type != BR_PMT_INDEX_8) {
|
||||
LOG_PANIC("only 8 bit surfaces supported");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = 0; x < w; x++) {
|
||||
if (dx + x < 0 || dx + x >= dst->width) {
|
||||
continue;
|
||||
}
|
||||
if (sx + x >= src->width)
|
||||
continue;
|
||||
|
||||
for (int y = 0; y < h; y++) {
|
||||
if (dy + y < 0 || dy + y >= dst->height) {
|
||||
continue;
|
||||
}
|
||||
if (sy + y >= src->height)
|
||||
continue;
|
||||
|
||||
dst_pix[(y + dy) * dst->row_bytes + (x + dx)] = src_pix[(sy + y) * src->row_bytes + (x + sx)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Offset: 3297
|
||||
|
@ -226,7 +269,7 @@ void BrPixelmapLine(br_pixelmap* dst, br_int_32 x1, br_int_32 y1, br_int_32 x2,
|
|||
// Offset: 4629
|
||||
// Size: 65
|
||||
void BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src) {
|
||||
NOT_IMPLEMENTED();
|
||||
Harness_Hook_BrPixelmapDoubleBuffer(dst, src);
|
||||
}
|
||||
|
||||
// Offset: 4709
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "pmfile.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include "CORE/FW/datafile.h"
|
||||
#include "CORE/FW/genfile.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "pmgen.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[48];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "pmmem.h"
|
||||
#include "debug.h"
|
||||
#include "genclip.h"
|
||||
#include "harness.h"
|
||||
#include "pmsetup.h"
|
||||
#include "resource.h"
|
||||
#include "tokenval.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "pmnull.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[51];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "CORE/FW/resource.h"
|
||||
#include "CORE/FW/resreg.h"
|
||||
#include "CORE/STD/brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "image.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brexcept.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
void* exceptionValue;
|
||||
br_exception_handler* _BrExceptionHandler;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brmath.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <math.h>
|
||||
|
||||
char rscid[46];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brstddiag.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_diaghandler BrStdioDiagHandler;
|
||||
br_diaghandler* _BrDefaultDiagHandler;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "brstdfile.h"
|
||||
|
||||
#include "CORE/FW/diag.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brstdlib.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "brstdmem.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "logwrite.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[50];
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CORE/V1DB/dbsetup.h"
|
||||
#include "CORE/V1DB/enables.h"
|
||||
#include "actsupt.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[53];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "custsupt.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[52];
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "CORE/STD/brstdlib.h"
|
||||
#include "CORE/V1DB/def_mat.h"
|
||||
#include "CORE/V1DB/def_mdl.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "def_mat.h"
|
||||
#include "dbsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "matrix23.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "enables.h"
|
||||
#include "dbsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stddef.h>
|
||||
|
||||
char rscid[51];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "matsupt.h"
|
||||
#include "dbsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "resource.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "modrend.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_colour bounds_colours[12];
|
||||
fmt_vertex bounds_vertices[8];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "modsupt.h"
|
||||
#include "CORE/FW/resource.h"
|
||||
#include "CORE/V1DB/dbsetup.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[50];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "otable.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[50];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "prepmap.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[51];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "prepmatl.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[52];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "CORE/FW/diag.h"
|
||||
#include "CORE/MATH/plane.h"
|
||||
#include "CORE/STD/brmath.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
br_model* compareModel;
|
||||
char* pm_edge_scratch;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "preptab.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include "prepmap.h"
|
||||
|
||||
char rscid[51];
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "CORE/V1DB/prepmesh.h"
|
||||
#include "CORE/V1DB/preptab.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[51];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "render.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
char rscid[55];
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "CORE/V1DB/matsupt.h"
|
||||
#include "CORE/V1DB/modsupt.h"
|
||||
#include "CORE/V1DB/regsupt.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -2,14 +2,14 @@ TARGET_EXEC ?= c1
|
|||
|
||||
BUILD_DIR ?= ./build
|
||||
SRC_DIR ?= .
|
||||
FW_SRC_DIR ?= ../framework
|
||||
HARNESS_SRC_DIR ?= "../harness"
|
||||
|
||||
SRCS := $(shell find $(SRC_DIR) -name "*.c")
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
OBJS += $(shell find $(FW_SRC_DIR) -name "*.o")
|
||||
OBJS += $(shell find $(HARNESS_SRC_DIR) -name "*.o")
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(FW_SRC_DIR)
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(HARNESS_SRC_DIR)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CFLAGS ?= $(INC_FLAGS) -g -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
|
|
|
@ -3,26 +3,35 @@ TARGET_EXEC ?= c1
|
|||
BUILD_DIR ?= ./build
|
||||
SRC_DIR ?= .
|
||||
BR_SRC_DIR ?= ../BRSRC13
|
||||
FW_SRC_DIR ?= ../framework
|
||||
HARNESS_SRC_DIR ?= ../harness
|
||||
|
||||
OS = $(shell uname -s)
|
||||
SRCS := $(shell find $(SRC_DIR) -name "*.c")
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
OBJS += $(shell find $(BR_SRC_DIR) -name "*.o")
|
||||
OBJS += $(shell find $(FW_SRC_DIR) -name "*.o")
|
||||
OBJS += $(shell find $(HARNESS_SRC_DIR) -name "*.o")
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(BR_SRC_DIR) $(FW_SRC_DIR)
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(BR_SRC_DIR) $(HARNESS_SRC_DIR)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CFLAGS ?= $(INC_FLAGS) -g -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
LDFLAGS ?= -lm -fno-pie
|
||||
|
||||
SDL_LDFLAGS = `sdl2-config --libs`
|
||||
|
||||
ifeq ($(OS),Darwin)
|
||||
OPENGL_LDFLAGS = -framework OpenGL
|
||||
else
|
||||
OPENGL_LDFLAGS = -lGL
|
||||
endif
|
||||
LDFLAGS ?= -lm -fno-pie $(SDL_LDFLAGS) $(OPENGL_LDFLAGS)
|
||||
|
||||
.PHONY: clean build test
|
||||
|
||||
build: $(BUILD_DIR)/$(TARGET_EXEC)
|
||||
|
||||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
||||
@$(CC) $(OBJS) -o $@ $(LDFLAGS)
|
||||
@$(CC) $(OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
# c source
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
|
|
|
@ -405,7 +405,7 @@ void InitializePalettes() {
|
|||
if (!gFlic_palette) {
|
||||
FatalError(10);
|
||||
}
|
||||
DRSetPalette2(gFlic_palette, 1);
|
||||
DRSetPalette2(gRender_palette, 1);
|
||||
gScratch_pixels = BrMemAllocate(0x400u, 0x98u);
|
||||
gScratch_palette = DRPixelmapAllocate(BR_PMT_RGBX_888, 1u, 256, gScratch_pixels, 0);
|
||||
gPalette_conversion_table = BrTableFind("FLC2REND.TAB");
|
||||
|
@ -424,7 +424,13 @@ void SwitchToPalette(char* pPal_name) {
|
|||
// Offset: 4948
|
||||
// Size: 104
|
||||
void ClearEntireScreen() {
|
||||
NOT_IMPLEMENTED();
|
||||
LOG_TRACE("()");
|
||||
|
||||
if (gScreen) {
|
||||
BrPixelmapFill(gScreen, gGraf_specs[gGraf_spec_index].black_value);
|
||||
}
|
||||
BrPixelmapFill(gBack_screen, gGraf_specs[gGraf_spec_index].black_value);
|
||||
PDScreenBufferSwap(0);
|
||||
}
|
||||
|
||||
// Offset: 5052
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "common/replay.h"
|
||||
#include "common/skidmark.h"
|
||||
#include "common/sound.h"
|
||||
#include "common/utility.h"
|
||||
#include "common/world.h"
|
||||
#include "pc-dos/dossys.h"
|
||||
|
||||
|
@ -191,7 +192,24 @@ void InitBRFonts() {
|
|||
// Offset: 2576
|
||||
// Size: 196
|
||||
void AustereWarning() {
|
||||
NOT_IMPLEMENTED();
|
||||
LOG_TRACE("()");
|
||||
|
||||
ClearEntireScreen();
|
||||
|
||||
if (gAusterity_mode) {
|
||||
LoadFont(10);
|
||||
TransDRPixelmapText(gBack_screen,
|
||||
(gBack_screen->width - DRTextWidth(&gFonts[10], GetMiscString(193))) / 2,
|
||||
0,
|
||||
&gFonts[10],
|
||||
GetMiscString(193),
|
||||
gBack_screen->width);
|
||||
PDScreenBufferSwap(0);
|
||||
gAustere_time = PDGetTotalTime();
|
||||
DisposeFont(10);
|
||||
} else {
|
||||
gAustere_time = gAusterity_mode;
|
||||
}
|
||||
}
|
||||
|
||||
// Offset: 2772
|
||||
|
|
|
@ -405,12 +405,17 @@ br_pixelmap* PurifiedPixelmap(br_pixelmap* pSrc) {
|
|||
br_pixelmap* DRPixelmapLoad(char* pFile_name) {
|
||||
br_pixelmap* the_map;
|
||||
LOG_TRACE("(\"%s\")", pFile_name);
|
||||
br_int_8 lobyte;
|
||||
|
||||
the_map = BrPixelmapLoad(pFile_name);
|
||||
if (the_map) {
|
||||
the_map->origin_x = 0;
|
||||
the_map->origin_y = 0;
|
||||
the_map->row_bytes = (the_map->row_bytes + 3) & 0xFC;
|
||||
|
||||
lobyte = the_map->row_bytes & 0xff;
|
||||
lobyte += 3;
|
||||
lobyte &= 0xfc;
|
||||
the_map->row_bytes = (the_map->row_bytes & 0xff00) | lobyte;
|
||||
}
|
||||
return the_map;
|
||||
}
|
||||
|
@ -425,11 +430,15 @@ br_uint_32 DRPixelmapLoadMany(char* pFile_name, br_pixelmap** pPixelmaps, br_uin
|
|||
int number_loaded;
|
||||
int i;
|
||||
LOG_TRACE("(\"%s\", %p, %d)", pFile_name, pPixelmaps, pNum);
|
||||
br_uint_8 lobyte;
|
||||
|
||||
number_loaded = BrPixelmapLoadMany(pFile_name, pPixelmaps, pNum);
|
||||
for (i = 0; i < number_loaded; i++) {
|
||||
the_map = pPixelmaps[i];
|
||||
the_map->row_bytes = (the_map->row_bytes + 3) & 0xFC;
|
||||
lobyte = the_map->row_bytes & 0xff;
|
||||
lobyte += 3;
|
||||
lobyte &= 0xfc;
|
||||
the_map->row_bytes = (the_map->row_bytes & 0xff00) | lobyte;
|
||||
the_map->base_x = 0;
|
||||
the_map->base_y = 0;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define DR_TYPES_H
|
||||
|
||||
#include "br_types.h"
|
||||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include "harness.h"
|
||||
#include "pc-dos/dossys.h"
|
||||
#include "renderers/gl_renderer.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int original_main(int pArgc, char* pArgv[]);
|
||||
|
||||
int _argc;
|
||||
char** _argv;
|
||||
|
||||
int run_original_game_func(void* args);
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
_argc = argc;
|
||||
_argv = argv;
|
||||
|
||||
Harness_Init(argv[0], &OpenGLRenderer);
|
||||
Harness_RunWindowLoop(&run_original_game_func, NULL);
|
||||
}
|
||||
|
||||
int run_original_game_func(void* args) {
|
||||
return original_main(_argc, _argv);
|
||||
}
|
|
@ -10,6 +10,8 @@
|
|||
#include "common/car.h"
|
||||
#include "common/drdebug.h"
|
||||
#include "common/globvars.h"
|
||||
#include "common/grafdata.h"
|
||||
#include "common/graphics.h"
|
||||
#include "common/loadsave.h"
|
||||
#include "common/main.h"
|
||||
#include "common/sound.h"
|
||||
|
@ -418,7 +420,17 @@ void CopyBackScreen(int pRendering_area_only) {
|
|||
// Size: 92
|
||||
// EAX: pRendering_area_only
|
||||
void PDScreenBufferSwap(int pRendering_area_only) {
|
||||
NOT_IMPLEMENTED();
|
||||
LOG_TRACE("(%d)", pRendering_area_only);
|
||||
if (pRendering_area_only) {
|
||||
BrPixelmapRectangleCopy(gScreen, gY_offset, gX_offset, gRender_screen, 0, 0, gWidth, gHeight);
|
||||
} else {
|
||||
if (gReal_graf_data_index == gGraf_data_index) {
|
||||
BrPixelmapDoubleBuffer(gScreen, gBack_screen);
|
||||
} else {
|
||||
DRPixelmapDoubledCopy(gTemp_screen, gBack_screen, 320, 200, 0, 40);
|
||||
BrPixelmapDoubleBuffer(gScreen, gTemp_screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Offset: 5020
|
||||
|
@ -646,8 +658,8 @@ void Usage(char* pProgpath) {
|
|||
// Size: 722
|
||||
// EAX: pArgc
|
||||
// EDX: pArgv
|
||||
// Renamed from "main" to "_main" to allow for unit testing
|
||||
int _main(int pArgc, char** pArgv) {
|
||||
// Renamed from "main" to "original_main" to allow for harness + unit testing
|
||||
int original_main(int pArgc, char** pArgv) {
|
||||
int arg;
|
||||
int i;
|
||||
float f;
|
||||
|
@ -688,6 +700,7 @@ int _main(int pArgc, char** pArgv) {
|
|||
Usage(pArgv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
GameMain(pArgc, pArgv);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#include "dr_types.h"
|
||||
#include "pc-dos/dossys.h"
|
||||
#include "stack_trace_handler.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int _main(int pArgc, char* pArgv[]);
|
||||
|
||||
// EAX: pArgc
|
||||
// EDX: pArgv
|
||||
// Moved from pc-dos/dossys.c to enable unit testing
|
||||
int main(int argc, char* argv[]) {
|
||||
set_signal_handler(argv[0]);
|
||||
return _main(argc, argv);
|
||||
}
|
|
@ -1,14 +1,16 @@
|
|||
BUILD_DIR ?= ./build
|
||||
SRC_DIR ?= .
|
||||
BR_SRC_DIR ?= ../BRSRC13
|
||||
SDL_CLFAGS = `sdl2-config --cflags`
|
||||
|
||||
SRCS := $(shell find $(SRC_DIR) -name "*.c")
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d)
|
||||
INC_DIRS := $(shell find $(SRC_DIR) -type d) $(BR_SRC_DIR)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CFLAGS ?= $(INC_FLAGS) -g -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
CFLAGS ?= $(INC_FLAGS) $(SDL_CLFAGS) -g -Wno-return-type -Wno-missing-declarations -Werror=implicit-function-declaration
|
||||
|
||||
.PHONY: clean build
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "debug.h"
|
||||
#include "harness.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
|
@ -0,0 +1,83 @@
|
|||
|
||||
#include "harness.h"
|
||||
#include "stack_trace_handler.h"
|
||||
|
||||
SDL_Window* window;
|
||||
SDL_Thread* game_thread;
|
||||
renderer* current_renderer;
|
||||
br_pixelmap* palette;
|
||||
uint32_t* screen_buffer;
|
||||
|
||||
void Harness_Init(char* name, renderer* renderer) {
|
||||
install_signal_handler(name);
|
||||
current_renderer = renderer;
|
||||
screen_buffer = NULL;
|
||||
}
|
||||
|
||||
void Harness_RunWindowLoop(harness_game_func* game_func, void* arg) {
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
|
||||
LOG_PANIC("SDL_Init Error: %s", SDL_GetError());
|
||||
}
|
||||
window = SDL_CreateWindow("Dethrace",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
680, 480,
|
||||
current_renderer->get_window_flags());
|
||||
|
||||
if (!window) {
|
||||
LOG_PANIC("Failed to create window");
|
||||
}
|
||||
|
||||
current_renderer->init(window);
|
||||
|
||||
game_thread = SDL_CreateThread(game_func, "game_thread", arg);
|
||||
|
||||
SDL_Event event;
|
||||
int keep_pumping = 1;
|
||||
while (keep_pumping) {
|
||||
if (SDL_WaitEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
keep_pumping = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_PANIC("leaving loop");
|
||||
}
|
||||
|
||||
void Harness_Hook_DOSGfxBegin() {
|
||||
current_renderer->activate(window);
|
||||
}
|
||||
|
||||
void Harness_Hook_BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src) {
|
||||
uint8_t palette_index = 0;
|
||||
int inc = 0;
|
||||
uint8_t* data = src->pixels;
|
||||
uint32_t* colors = palette->pixels;
|
||||
uint32_t true_color;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
if (screen_buffer == NULL) {
|
||||
screen_buffer = malloc(src->width * src->height * sizeof(uint32_t));
|
||||
memset(screen_buffer, 0, src->width * src->height * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
LOG_DEBUG("%d %d, %d", src->width, src->height, src->row_bytes);
|
||||
|
||||
// generate 32 bit texture from src + palette
|
||||
for (y = 0; y < src->height; y++) {
|
||||
inc = 0;
|
||||
for (x = 0; x < src->width; x++) {
|
||||
|
||||
palette_index = (data[y * src->row_bytes + x]);
|
||||
true_color = colors[palette_index];
|
||||
screen_buffer[y * src->width + x] = true_color;
|
||||
}
|
||||
}
|
||||
current_renderer->doubleBuffer(screen_buffer, window);
|
||||
}
|
||||
void Harness_Hook_BrDevPaletteSetOld(br_pixelmap* pm) {
|
||||
palette = pm;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef HARNESS_H
|
||||
#define HARNESS_H
|
||||
|
||||
#include "br_types.h"
|
||||
#include "debug.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
typedef int harness_game_func(void*);
|
||||
|
||||
typedef struct renderer {
|
||||
int (*get_window_flags)();
|
||||
void (*init)(SDL_Window* window);
|
||||
void (*activate)(SDL_Window* window);
|
||||
void (*doubleBuffer)(uint32_t* src, SDL_Window* window);
|
||||
} renderer;
|
||||
|
||||
void Harness_Init(char* name, renderer* renderer);
|
||||
void Harness_RunWindowLoop(harness_game_func* game_func, void* arg);
|
||||
|
||||
// Hooks are called from original game code.
|
||||
void Harness_Hook_DOSGfxBegin();
|
||||
void Harness_Hook_BrDevPaletteSetOld(br_pixelmap* pm);
|
||||
void Harness_Hook_BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,142 @@
|
|||
#include "gl_renderer.h"
|
||||
#include "harness.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <gl/gl.h>
|
||||
#elif defined __unix__
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <GL/gl.h>
|
||||
#elif defined __APPLE__
|
||||
#include <OpenGL/gl3.h>
|
||||
#endif
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
|
||||
renderer OpenGLRenderer = {
|
||||
Harness_GLRenderer_GetWindowFlags,
|
||||
Harness_GLRenderer_Init,
|
||||
Harness_GLRenderer_Activate,
|
||||
Harness_GLRenderer_DoubleBuffer,
|
||||
};
|
||||
|
||||
SDL_GLContext context;
|
||||
GLuint VBO, VAO, EBO;
|
||||
GLuint screen_texture;
|
||||
GLuint shader_program;
|
||||
|
||||
int Harness_GLRenderer_GetWindowFlags() {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
return SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
void Harness_GLRenderer_Init(SDL_Window* window) {
|
||||
|
||||
context = SDL_GL_CreateContext(window);
|
||||
if (!context) {
|
||||
LOG_PANIC("Failed to create context");
|
||||
}
|
||||
}
|
||||
|
||||
void CompileShader(GLuint shader_id, const GLchar* source) {
|
||||
int success;
|
||||
char log[512];
|
||||
glShaderSource(shader_id, 1, &source, NULL);
|
||||
glCompileShader(shader_id);
|
||||
glGetShaderiv(shader_id, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetShaderInfoLog(shader_id, 512, NULL, log);
|
||||
LOG_PANIC("shader %d failed. %s", shader_id, log);
|
||||
}
|
||||
}
|
||||
|
||||
void Harness_GLRenderer_Activate(SDL_Window* window) {
|
||||
GLuint vs, fs;
|
||||
|
||||
SDL_GL_MakeCurrent(window, context);
|
||||
|
||||
const char* vs_source = "#version 330 core\n"
|
||||
"layout (location = 0) in vec3 aPos;\n"
|
||||
"layout (location = 1) in vec3 aColor;\n"
|
||||
"layout (location = 2) in vec2 aTexCoord;\n"
|
||||
"out vec2 TexCoord;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
|
||||
" TexCoord = aTexCoord;\n"
|
||||
"}\0";
|
||||
const char* fs_source = "#version 330 core\n"
|
||||
"out vec4 FragColor;\n"
|
||||
"in vec2 TexCoord;\n"
|
||||
"uniform sampler2D ourTexture;\n"
|
||||
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" FragColor = texture(ourTexture, TexCoord);\n"
|
||||
"}\n\0";
|
||||
vs = glCreateShader(GL_VERTEX_SHADER);
|
||||
CompileShader(vs, vs_source);
|
||||
fs = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
CompileShader(fs, fs_source);
|
||||
|
||||
shader_program = glCreateProgram();
|
||||
glAttachShader(shader_program, vs);
|
||||
glAttachShader(shader_program, fs);
|
||||
glLinkProgram(shader_program);
|
||||
glDeleteShader(vs);
|
||||
glDeleteShader(fs);
|
||||
|
||||
float vertices[] = {
|
||||
// positions // colors // texture coords
|
||||
1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top right
|
||||
1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom right
|
||||
-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom left
|
||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left
|
||||
};
|
||||
unsigned int indices[] = {
|
||||
0, 1, 3, // first triangle
|
||||
1, 2, 3 // second triangle
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glGenBuffers(1, &VBO);
|
||||
glGenBuffers(1, &EBO);
|
||||
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
|
||||
|
||||
// position attribute
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
// color attribute
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(1);
|
||||
// texture coord attribute
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
glGenTextures(1, &screen_texture);
|
||||
}
|
||||
|
||||
void Harness_GLRenderer_DoubleBuffer(uint32_t* screen_buffer, SDL_Window* window) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, screen_texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
// TODO: remove fixed 320x200
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 320, 200, 0, GL_BGRA, GL_UNSIGNED_BYTE, screen_buffer);
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glUseProgram(shader_program);
|
||||
glBindVertexArray(VAO);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
SDL_Delay(5000);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef HARNESS_GL_RENDERER
|
||||
#define HARNESS_GL_RENDERER
|
||||
|
||||
#include "harness.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
extern renderer OpenGLRenderer;
|
||||
|
||||
int Harness_GLRenderer_GetWindowFlags();
|
||||
void Harness_GLRenderer_Init(SDL_Window* window);
|
||||
void Harness_GLRenderer_Activate(SDL_Window* window);
|
||||
void Harness_GLRenderer_DoubleBuffer(uint32_t* dst, SDL_Window* window);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,15 @@
|
|||
#include "null_renderer.h"
|
||||
|
||||
int Harness_NullRenderer_GetWindowFlags() {
|
||||
return 0;
|
||||
}
|
||||
void Harness_NullRenderer_Init(SDL_Window* window) {}
|
||||
void Harness_NullRenderer_Activate(SDL_Window* window) {}
|
||||
void Harness_NullRenderer_DoubleBuffer(uint32_t* src, SDL_Window* window) {}
|
||||
|
||||
renderer NullRenderer = {
|
||||
Harness_NullRenderer_GetWindowFlags,
|
||||
Harness_NullRenderer_Init,
|
||||
Harness_NullRenderer_Activate,
|
||||
Harness_NullRenderer_DoubleBuffer
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef HARNESS_NULL_RENDERER
|
||||
#define HARNESS_NULL_RENDERER
|
||||
|
||||
#include "harness.h"
|
||||
|
||||
extern renderer NullRenderer;
|
||||
|
||||
#endif
|
|
@ -144,7 +144,7 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS* ExceptionInfo) {
|
|||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void set_signal_handler(char* program_name) {
|
||||
void install_signal_handler(char* program_name) {
|
||||
strcpy(_program_name, program_name);
|
||||
SetUnhandledExceptionFilter(windows_exception_handler);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ void posix_signal_handler(int sig, siginfo_t* siginfo, void* context) {
|
|||
}
|
||||
|
||||
static uint8_t alternate_stack[SIGSTKSZ];
|
||||
void set_signal_handler(char* program_name) {
|
||||
void install_signal_handler(char* program_name) {
|
||||
|
||||
strcpy(_program_name, program_name);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue