aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--examples/render-bsp/data/newtest.bspbin0 -> 66488 bytes
-rw-r--r--examples/render-bsp/data/newtest.map110
-rw-r--r--examples/render-bsp/data/test.map116
-rw-r--r--examples/render-bsp/src/main.rs6
-rw-r--r--stockton-render/src/draw/buffer.rs5
-rw-r--r--stockton-render/src/draw/context.rs150
-rw-r--r--stockton-render/src/draw/data/stockton.frag2
-rw-r--r--stockton-render/src/draw/texture/loader.rs4
-rw-r--r--stockton-render/src/lib.rs7
10 files changed, 331 insertions, 73 deletions
diff --git a/.gitignore b/.gitignore
index 58a3b01..59d9154 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,3 +57,7 @@ GitHub.sublime-settings
# Game data. Used for testing, but not sure about license yet
textures/
+
+# Intermediate BSP files.
+*.srf
+*.prt \ No newline at end of file
diff --git a/examples/render-bsp/data/newtest.bsp b/examples/render-bsp/data/newtest.bsp
new file mode 100644
index 0000000..a89f408
--- /dev/null
+++ b/examples/render-bsp/data/newtest.bsp
Binary files differ
diff --git a/examples/render-bsp/data/newtest.map b/examples/render-bsp/data/newtest.map
new file mode 100644
index 0000000..8ad8889
--- /dev/null
+++ b/examples/render-bsp/data/newtest.map
@@ -0,0 +1,110 @@
+// entity 0
+{
+"classname" "worldspawn"
+"_q3map2_cmdline" "-meta; -vis -saveprt; -light -fast -filter"
+"_q3map2_version" "2.5.17n-git-7d2c6f1a"
+// brush 0
+{
+( -192 0 0 ) ( -192 256 0 ) ( -192 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 192 0 0 ) ( 192 -256 0 ) ( 192 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -208 0 ) ( 0 -208 -256 ) ( -256 -208 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 176 0 ) ( 0 176 256 ) ( -256 176 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -192 176 256 ) ( -192 -208 256 ) ( 192 -208 256 ) skies/toxicskydim 0 0 0 0.5 0.5 0 0 0
+( 0 0 320 ) ( 256 0 320 ) ( 0 -256 320 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 1
+{
+( 192 -208 256 ) ( 192 -208 192 ) ( 192 176 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -208 0 ) ( 0 -208 -256 ) ( -256 -208 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 176 0 ) ( 0 176 256 ) ( -256 176 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 192 176 192 ) ( 192 -208 192 ) ( 256 -208 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( 0 0 256 ) ( 256 0 256 ) ( 0 -256 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 2
+{
+( -192 0 0 ) ( -192 256 0 ) ( -192 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -272 0 ) ( 0 -272 -256 ) ( -256 -272 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -192 -208 256 ) ( -192 -208 192 ) ( 256 -208 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( -192 -208 192 ) ( -192 -272 192 ) ( 256 -272 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( 0 0 256 ) ( 256 0 256 ) ( 0 -256 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 3
+{
+( -256 0 0 ) ( -256 256 0 ) ( -256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -192 176 256 ) ( -192 176 192 ) ( -192 -272 192 ) base_floor/concrete 0 0 -0 0.5 0.5 0 0 0
+( 0 -272 0 ) ( 0 -272 -256 ) ( -256 -272 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 176 0 ) ( 0 176 256 ) ( -256 176 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -256 176 192 ) ( -256 -272 192 ) ( -192 -272 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( 0 0 256 ) ( 256 0 256 ) ( 0 -256 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 4
+{
+( -256 0 0 ) ( -256 256 0 ) ( -256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 176 256 ) ( 256 176 192 ) ( -256 176 192 ) base_floor/concrete 0 0 -0 0.5 0.5 0 0 0
+( 0 240 0 ) ( 0 240 256 ) ( -256 240 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -256 240 192 ) ( -256 176 192 ) ( 256 176 192 ) base_floor/concrete 0 0 0 0.5 0.5 0 0 0
+( 0 0 256 ) ( 256 0 256 ) ( 0 -256 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 5
+{
+( -256 0 0 ) ( -256 256 0 ) ( -256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -336 0 ) ( 0 -336 -256 ) ( -256 -336 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -256 -272 192 ) ( -256 -272 -256 ) ( 256 -272 -256 ) base_wall/bluemetal2 0 0 0 0.5 0.5 0 0 0
+( 0 0 -256 ) ( -256 0 -256 ) ( 0 -256 -256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 192 ) ( 256 0 192 ) ( 0 -256 192 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 6
+{
+( -256 0 0 ) ( -256 256 0 ) ( -256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 240 192 ) ( 256 240 -256 ) ( -256 240 -256 ) base_wall/bluemetal2 0 0 -0 0.5 0.5 0 0 0
+( 0 304 0 ) ( 0 304 256 ) ( -256 304 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 -256 ) ( -256 0 -256 ) ( 0 -256 -256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 192 ) ( 256 0 192 ) ( 0 -256 192 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 7
+{
+( -320 0 0 ) ( -320 256 0 ) ( -320 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -256 240 192 ) ( -256 240 -256 ) ( -256 -272 -256 ) base_wall/bluemetal2 0 0 -0 0.5 0.5 0 0 0
+( 0 -272 0 ) ( 0 -272 -256 ) ( -256 -272 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 240 0 ) ( 0 240 256 ) ( -256 240 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 -256 ) ( -256 0 -256 ) ( 0 -256 -256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 192 ) ( 256 0 192 ) ( 0 -256 192 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 8
+{
+( 256 -272 192 ) ( 256 -272 -256 ) ( 256 240 -256 ) base_wall/bluemetal2 0 0 0 0.5 0.5 0 0 0
+( 320 0 0 ) ( 320 -256 0 ) ( 320 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -272 0 ) ( 0 -272 -256 ) ( -256 -272 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 240 0 ) ( 0 240 256 ) ( -256 240 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 -256 ) ( -256 0 -256 ) ( 0 -256 -256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 192 ) ( 256 0 192 ) ( 0 -256 192 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+}
+// brush 9
+{
+( -256 0 0 ) ( -256 256 0 ) ( -256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 256 0 0 ) ( 256 -256 0 ) ( 256 0 256 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 -272 0 ) ( 0 -272 -256 ) ( -256 -272 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 240 0 ) ( 0 240 256 ) ( -256 240 0 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( 0 0 -320 ) ( -256 0 -320 ) ( 0 -256 -320 ) common/caulk 0 0 0 0.25 0.25 0 0 0
+( -256 -272 -256 ) ( -256 240 -256 ) ( 256 240 -256 ) base_floor/clang_floor2 0 0 -0 0.5 0.5 0 0 0
+}
+// brush 10
+{
+( 192 64 64 ) ( 192 0 64 ) ( 128 64 64 ) gothic_trim/gothgrate2 0 0 0 0.5 0.5 0 0 0
+( 192 64 64 ) ( 128 64 64 ) ( 192 64 -576 ) gothic_trim/newskull 0 -0 0 0.5 0.5 0 0 0
+( 192 64 56 ) ( 192 64 -584 ) ( 192 0 56 ) gothic_trim/tower_top 0 496 0 0.5 0.5 0 0 0
+( 144 0 0 ) ( 208 0 0 ) ( 144 64 0 ) gothic_trim/pitted_rust3_dkred 480 0 0 0.5 0.5 0 0 0
+( 128 0 -576 ) ( 128 0 64 ) ( 192 0 -576 ) gothic_trim/metalsupport4b 0 -0 0 0.5 0.5 0 0 0
+( 128 0 -576 ) ( 128 64 -576 ) ( 128 0 64 ) gothic_trim/metalsupport4i_bit 0 -0 0 0.5 0.5 0 0 0
+}
+}
+// entity 1
+{
+"classname" "info_player_start"
+"origin" "-8.000000 -6.000000 15.000000"
+}
diff --git a/examples/render-bsp/data/test.map b/examples/render-bsp/data/test.map
new file mode 100644
index 0000000..9f4915f
--- /dev/null
+++ b/examples/render-bsp/data/test.map
@@ -0,0 +1,116 @@
+// Generated by Q3Map2 (ydnar) -convert -format map
+// entity 0
+{
+ "classname" "worldspawn"
+ "_q3map2_cmdline" "-meta; -vis -saveprt; -light -fast -filter"
+ "_q3map2_version" "2.5.17n-git-7d2c6f1a"
+
+ // brush 0
+ {
+ ( -192.000 0.000 0.000 ) ( -192.000 256.000 0.000 ) ( -192.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 192.000 0.000 0.000 ) ( 192.000 -256.000 0.000 ) ( 192.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -208.000 0.000 ) ( 0.000 -208.000 -256.000 ) ( -256.000 -208.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 176.000 0.000 ) ( 0.000 176.000 256.000 ) ( -256.000 176.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -192.000 176.000 256.000 ) ( -192.000 -208.000 256.000 ) ( 192.000 -208.000 256.000 ) skies/toxicskydim 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 320.000 ) ( 256.000 0.000 320.000 ) ( 0.000 -256.000 320.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 1
+ {
+ ( 192.000 -208.000 256.000 ) ( 192.000 -208.000 192.000 ) ( 192.000 176.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -208.000 0.000 ) ( 0.000 -208.000 -256.000 ) ( -256.000 -208.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 176.000 0.000 ) ( 0.000 176.000 256.000 ) ( -256.000 176.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 192.000 176.000 192.000 ) ( 192.000 -208.000 192.000 ) ( 256.000 -208.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 256.000 ) ( 256.000 0.000 256.000 ) ( 0.000 -256.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 2
+ {
+ ( -192.000 0.000 0.000 ) ( -192.000 256.000 0.000 ) ( -192.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -272.000 0.000 ) ( 0.000 -272.000 -256.000 ) ( -256.000 -272.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -192.000 -208.000 256.000 ) ( -192.000 -208.000 192.000 ) ( 256.000 -208.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( -192.000 -208.000 192.000 ) ( -192.000 -272.000 192.000 ) ( 256.000 -272.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 256.000 ) ( 256.000 0.000 256.000 ) ( 0.000 -256.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 3
+ {
+ ( -256.000 0.000 0.000 ) ( -256.000 256.000 0.000 ) ( -256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -192.000 176.000 256.000 ) ( -192.000 176.000 192.000 ) ( -192.000 -272.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 -0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 -272.000 0.000 ) ( 0.000 -272.000 -256.000 ) ( -256.000 -272.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 176.000 0.000 ) ( 0.000 176.000 256.000 ) ( -256.000 176.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -256.000 176.000 192.000 ) ( -256.000 -272.000 192.000 ) ( -192.000 -272.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 256.000 ) ( 256.000 0.000 256.000 ) ( 0.000 -256.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 4
+ {
+ ( -256.000 0.000 0.000 ) ( -256.000 256.000 0.000 ) ( -256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 176.000 256.000 ) ( 256.000 176.000 192.000 ) ( -256.000 176.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 -0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 240.000 0.000 ) ( 0.000 240.000 256.000 ) ( -256.000 240.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -256.000 240.000 192.000 ) ( -256.000 176.000 192.000 ) ( 256.000 176.000 192.000 ) base_floor/concrete 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 256.000 ) ( 256.000 0.000 256.000 ) ( 0.000 -256.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 5
+ {
+ ( -256.000 0.000 0.000 ) ( -256.000 256.000 0.000 ) ( -256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -336.000 0.000 ) ( 0.000 -336.000 -256.000 ) ( -256.000 -336.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -256.000 -272.000 192.000 ) ( -256.000 -272.000 -256.000 ) ( 256.000 -272.000 -256.000 ) base_wall/bluemetal2 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 0.000 -256.000 ) ( -256.000 0.000 -256.000 ) ( 0.000 -256.000 -256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 192.000 ) ( 256.000 0.000 192.000 ) ( 0.000 -256.000 192.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 6
+ {
+ ( -256.000 0.000 0.000 ) ( -256.000 256.000 0.000 ) ( -256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 240.000 192.000 ) ( 256.000 240.000 -256.000 ) ( -256.000 240.000 -256.000 ) base_wall/bluemetal2 0.00000000 0.00000000 -0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 304.000 0.000 ) ( 0.000 304.000 256.000 ) ( -256.000 304.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 -256.000 ) ( -256.000 0.000 -256.000 ) ( 0.000 -256.000 -256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 192.000 ) ( 256.000 0.000 192.000 ) ( 0.000 -256.000 192.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 7
+ {
+ ( -320.000 0.000 0.000 ) ( -320.000 256.000 0.000 ) ( -320.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -256.000 240.000 192.000 ) ( -256.000 240.000 -256.000 ) ( -256.000 -272.000 -256.000 ) base_wall/bluemetal2 0.00000000 0.00000000 -0.00000000 0.50000000 0.50000000 0 0 0
+ ( 0.000 -272.000 0.000 ) ( 0.000 -272.000 -256.000 ) ( -256.000 -272.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 240.000 0.000 ) ( 0.000 240.000 256.000 ) ( -256.000 240.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 -256.000 ) ( -256.000 0.000 -256.000 ) ( 0.000 -256.000 -256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 192.000 ) ( 256.000 0.000 192.000 ) ( 0.000 -256.000 192.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 8
+ {
+ ( 256.000 -272.000 192.000 ) ( 256.000 -272.000 -256.000 ) ( 256.000 240.000 -256.000 ) base_wall/bluemetal2 0.00000000 0.00000000 0.00000000 0.50000000 0.50000000 0 0 0
+ ( 320.000 0.000 0.000 ) ( 320.000 -256.000 0.000 ) ( 320.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -272.000 0.000 ) ( 0.000 -272.000 -256.000 ) ( -256.000 -272.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 240.000 0.000 ) ( 0.000 240.000 256.000 ) ( -256.000 240.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 -256.000 ) ( -256.000 0.000 -256.000 ) ( 0.000 -256.000 -256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 192.000 ) ( 256.000 0.000 192.000 ) ( 0.000 -256.000 192.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ }
+
+ // brush 9
+ {
+ ( -256.000 0.000 0.000 ) ( -256.000 256.000 0.000 ) ( -256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 256.000 0.000 0.000 ) ( 256.000 -256.000 0.000 ) ( 256.000 0.000 256.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 -272.000 0.000 ) ( 0.000 -272.000 -256.000 ) ( -256.000 -272.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 240.000 0.000 ) ( 0.000 240.000 256.000 ) ( -256.000 240.000 0.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( 0.000 0.000 -320.000 ) ( -256.000 0.000 -320.000 ) ( 0.000 -256.000 -320.000 ) common/caulk 0.00000000 0.00000000 0.00000000 0.25000000 0.25000000 0 0 0
+ ( -256.000 -272.000 -256.000 ) ( -256.000 240.000 -256.000 ) ( 256.000 240.000 -256.000 ) base_floor/clang_floor2 0.00000000 0.00000000 -0.00000000 0.50000000 0.50000000 0 0 0
+ }
+
+}
+
+// entity 1
+{
+ "classname" "info_player_start"
+ "origin" "-8.000000 -6.000000 15.000000"
+
+}
+
diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs
index 92b7c3f..cab492f 100644
--- a/examples/render-bsp/src/main.rs
+++ b/examples/render-bsp/src/main.rs
@@ -1,4 +1,4 @@
-// Copyright (C) Oscar Shrimpton 2019
+// Copyright (C) Oscar Shrimpton 2019
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
@@ -110,11 +110,11 @@ fn main() {
window.set_cursor_visible(false);
// Parse the map file and swizzle the co-ords
- let data = include_bytes!("../data/test.bsp").to_vec().into_boxed_slice();
+ let data = include_bytes!("../data/newtest.bsp").to_vec().into_boxed_slice();
let bsp: Result<Q3BSPFile<Q3System>, stockton_levels::types::ParseError> = Q3BSPFile::parse_file(&data);
let bsp: Q3BSPFile<Q3System> = bsp.unwrap();
let bsp: Q3BSPFile<VulkanSystem> = bsp.swizzle_to();
-
+
// Load into a world and create the new renderer
let world = World::new(bsp);
let mut renderer = Renderer::new(world, &window).unwrap();
diff --git a/stockton-render/src/draw/buffer.rs b/stockton-render/src/draw/buffer.rs
index f59431e..006a37b 100644
--- a/stockton-render/src/draw/buffer.rs
+++ b/stockton-render/src/draw/buffer.rs
@@ -60,6 +60,7 @@ pub(crate) fn create_buffer(device: &mut Device,
}
pub trait ModifiableBuffer: IndexMut<usize> {
+ fn get_buffer<'a>(&'a mut self) -> &'a Buffer;
fn commit<'a>(&'a mut self, device: &Device,
command_queue: &mut CommandQueue,
command_pool: &mut CommandPool) -> &'a Buffer;
@@ -116,6 +117,10 @@ impl<'a, T: Sized> StagedBuffer<'a, T> {
}
impl <'a, T: Sized> ModifiableBuffer for StagedBuffer<'a, T> {
+ fn get_buffer<'b>(&'b mut self) -> &'b Buffer {
+ &self.buffer
+ }
+
fn commit<'b>(&'b mut self, device: &Device,
command_queue: &mut CommandQueue,
command_pool: &mut CommandPool) -> &'b Buffer {
diff --git a/stockton-render/src/draw/context.rs b/stockton-render/src/draw/context.rs
index b76bed7..dc7703d 100644
--- a/stockton-render/src/draw/context.rs
+++ b/stockton-render/src/draw/context.rs
@@ -620,7 +620,7 @@ impl<'a> RenderingContext<'a> {
}
/// Draw all vertices in the buffer
- pub fn draw_vertices(&mut self) -> Result<(), &'static str> {
+ pub fn draw_vertices<M: MinBSPFeatures<VulkanSystem>>(&mut self, file: &M,faces: &Vec<u32>) -> Result<(), &'static str> {
let get_image = &self.get_image[self.current_frame];
let render_complete = &self.render_complete[self.current_frame];
@@ -662,18 +662,10 @@ impl<'a> RenderingContext<'a> {
// Commit from staging buffers
let (vbufs, ibuf) = {
- let vbufref: &<back::Backend as hal::Backend>::Buffer = self.vert_buffer.commit(
- &self.device,
- &mut self.queue_group.queues[0],
- &mut self.cmd_pool
- );
+ let vbufref: &<back::Backend as hal::Backend>::Buffer = self.vert_buffer.get_buffer();
let vbufs: ArrayVec<[_; 1]> = [(vbufref, SubRange::WHOLE)].into();
- let ibuf = self.index_buffer.commit(
- &self.device,
- &mut self.queue_group.queues[0],
- &mut self.cmd_pool
- );
+ let ibuf = self.index_buffer.get_buffer();
(vbufs, ibuf)
};
@@ -689,16 +681,6 @@ impl<'a> RenderingContext<'a> {
);
buffer.bind_graphics_pipeline(&self.pipeline);
- let mut descriptor_sets: ArrayVec<[_; 1]> = ArrayVec::new();
- descriptor_sets.push(self.texture_store.get_chunk_descriptor_set(0));
-
- buffer.bind_graphics_descriptor_sets(
- &self.pipeline_layout,
- 0,
- descriptor_sets,
- &[]
- );
-
let vp = self.camera.get_matrix().as_slice();
let vp = std::mem::transmute::<&[f32], &[u32]>(vp);
@@ -714,12 +696,94 @@ impl<'a> RenderingContext<'a> {
range: SubRange::WHOLE,
index_type: hal::IndexType::U16
});
- buffer.draw_indexed(0..((self.index_buffer.highest_used as u32 + 1) * 3), 0, 0..1);
+
+ let mut current_chunk = file.get_face(0).texture_idx as usize / 8;
+ let mut chunk_start = 0;
+
+ let mut curr_vert_idx: usize = 0;
+ let mut curr_idx_idx: usize = 0;
+
+ for face in faces.into_iter().map(|idx| file.get_face(*idx)) {
+ if current_chunk != face.texture_idx as usize / 8 {
+ let mut descriptor_sets: ArrayVec<[_; 1]> = ArrayVec::new();
+ descriptor_sets.push(self.texture_store.get_chunk_descriptor_set(current_chunk));
+
+ buffer.bind_graphics_descriptor_sets(
+ &self.pipeline_layout,
+ 0,
+ descriptor_sets,
+ &[]
+ );
+
+ buffer.draw_indexed(chunk_start as u32 * 3..(curr_idx_idx as u32 * 3) + 1, 0, 0..1);
+
+ chunk_start = curr_idx_idx;
+ current_chunk = face.texture_idx as usize / 8;
+ }
+
+ if face.face_type == FaceType::Polygon || face.face_type == FaceType::Mesh {
+ let base = face.vertices_idx.start;
+
+ for idx in face.meshverts_idx.clone().step_by(3) {
+ let start_idx: u16 = curr_vert_idx.try_into().unwrap();
+
+ for idx2 in idx..idx+3 {
+ let vert = &file.resolve_meshvert(idx2 as u32, base);
+ let uv = Vector2::new(vert.tex.u[0], vert.tex.v[0]);
+
+ let uvp = UVPoint (vert.position, face.texture_idx.try_into().unwrap(), uv);
+ self.vert_buffer[curr_vert_idx] = uvp;
+
+ curr_vert_idx += 1;
+ }
+
+
+ self.index_buffer[curr_idx_idx] = (start_idx, start_idx + 1, start_idx + 2);
+
+ curr_idx_idx += 1;
+
+ if curr_vert_idx >= INITIAL_VERT_SIZE.try_into().unwrap() || curr_idx_idx >= INITIAL_INDEX_SIZE.try_into().unwrap() {
+ println!("out of vertex buffer space!");
+ break;
+ }
+ }
+ } else {
+ // TODO: Other types of faces
+ }
+
+ if curr_vert_idx >= INITIAL_VERT_SIZE.try_into().unwrap() || curr_idx_idx >= INITIAL_INDEX_SIZE.try_into().unwrap() {
+ break;
+ }
+ }
+
+ let mut descriptor_sets: ArrayVec<[_; 1]> = ArrayVec::new();
+ descriptor_sets.push(self.texture_store.get_chunk_descriptor_set(current_chunk));
+ buffer.bind_graphics_descriptor_sets(
+ &self.pipeline_layout,
+ 0,
+ descriptor_sets,
+ &[]
+ );
+ buffer.draw_indexed(chunk_start as u32 * 3..(curr_idx_idx as u32 * 3) + 1, 0, 0..1);
+
buffer.end_render_pass();
}
buffer.finish();
};
+ // Update our buffers before we actually start drawing
+ self.vert_buffer.commit(
+ &self.device,
+ &mut self.queue_group.queues[0],
+ &mut self.cmd_pool
+ );
+
+ self.index_buffer.commit(
+ &self.device,
+ &mut self.queue_group.queues[0],
+ &mut self.cmd_pool
+ );
+
// Make submission object
let command_buffers = &self.cmd_buffers[image_index..=image_index];
let wait_semaphores: ArrayVec<[_; 1]> = [(get_image, hal::pso::PipelineStage::COLOR_ATTACHMENT_OUTPUT)].into();
@@ -760,48 +824,6 @@ impl<'a> RenderingContext<'a> {
pub fn rotate(&mut self, euler: Vector3) {
self.camera.rotate(euler)
}
-
- /// Load all active faces into the vertex buffers for drawing
- // TODO: This is just a POC, we need to restructure things a lot for actually texturing, etc
- pub fn set_active_faces<M: MinBSPFeatures<VulkanSystem>>(&mut self, faces: &Vec<u32>, file: &M) -> () {
- let mut curr_vert_idx: usize = 0;
- let mut curr_idx_idx: usize = 0;
-
- for face in faces.into_iter().map(|idx| file.get_face(*idx)) {
- if face.face_type == FaceType::Polygon || face.face_type == FaceType::Mesh {
- let base = face.vertices_idx.start;
-
- for idx in face.meshverts_idx.clone().step_by(3) {
- let start_idx: u16 = curr_vert_idx.try_into().unwrap();
-
- for idx2 in idx..idx+3 {
- let vert = &file.resolve_meshvert(idx2 as u32, base);
- let uv = Vector2::new(vert.tex.u[0], vert.tex.v[0]);
-
- let uvp = UVPoint (vert.position, face.texture_idx.try_into().unwrap(), uv);
- self.vert_buffer[curr_vert_idx] = uvp;
-
- curr_vert_idx += 1;
- }
-
-
- self.index_buffer[curr_idx_idx] = (start_idx, start_idx + 1, start_idx + 2);
-
- curr_idx_idx += 1;
-
- if curr_vert_idx >= INITIAL_VERT_SIZE.try_into().unwrap() || curr_idx_idx >= INITIAL_INDEX_SIZE.try_into().unwrap() {
- break;
- }
- }
- } else {
- // TODO: Other types of faces
- }
-
- if curr_vert_idx >= INITIAL_VERT_SIZE.try_into().unwrap() || curr_idx_idx >= INITIAL_INDEX_SIZE.try_into().unwrap() {
- break;
- }
- }
- }
}
impl<'a> core::ops::Drop for RenderingContext<'a> {
diff --git a/stockton-render/src/draw/data/stockton.frag b/stockton-render/src/draw/data/stockton.frag
index 5c6e1d7..336d9fe 100644
--- a/stockton-render/src/draw/data/stockton.frag
+++ b/stockton-render/src/draw/data/stockton.frag
@@ -11,5 +11,5 @@ layout (location = 0) out vec4 color;
void main()
{
- color = texture(sampler2D(tex[frag_tex], samp[frag_tex]), frag_uv);
+ color = texture(sampler2D(tex[frag_tex % 8], samp[frag_tex % 8]), frag_uv);
} \ No newline at end of file
diff --git a/stockton-render/src/draw/texture/loader.rs b/stockton-render/src/draw/texture/loader.rs
index 017030f..b3aa3ae 100644
--- a/stockton-render/src/draw/texture/loader.rs
+++ b/stockton-render/src/draw/texture/loader.rs
@@ -155,6 +155,10 @@ impl TextureStore {
}
}
+ pub fn get_n_chunks(&self) -> usize {
+ self.chunks.len()
+ }
+
pub fn get_chunk_descriptor_set<'a>(&'a self, idx: usize) -> &'a DescriptorSet {
&self.chunks[idx].descriptor_set
}
diff --git a/stockton-render/src/lib.rs b/stockton-render/src/lib.rs
index c282967..0db4b76 100644
--- a/stockton-render/src/lib.rs
+++ b/stockton-render/src/lib.rs
@@ -65,15 +65,12 @@ impl<'a, T: MinBSPFeatures<VulkanSystem>> Renderer<'a, T> {
// Get visible faces
let faces = get_visible_faces(self.context.camera_pos(), &self.world.map);
- // Load them in
- self.context.set_active_faces(&faces, &self.world.map);
-
// Then draw them
- if let Err(_) = self.context.draw_vertices() {
+ if let Err(_) = self.context.draw_vertices(&self.world.map, &faces) {
unsafe {self.context.handle_surface_change().unwrap()};
// If it fails twice, then error
- self.context.draw_vertices().map_err(|_| FrameError::PresentError)?;
+ self.context.draw_vertices(&self.world.map, &faces).map_err(|_| FrameError::PresentError)?;
}
Ok(())