mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
Compare commits
3 Commits
sprites
...
9c0200155f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c0200155f | ||
| 09e4fcbf14 | |||
|
|
937ccf60c9 |
@@ -1,21 +0,0 @@
|
|||||||
include "../include/microw8-api.cwa"
|
|
||||||
|
|
||||||
const SPRITE = 0x20000;
|
|
||||||
|
|
||||||
export fn upd() {
|
|
||||||
cls(0);
|
|
||||||
let t = time();
|
|
||||||
let i: i32;
|
|
||||||
loop spriteLoop {
|
|
||||||
let inline x = sin(t * -1.3 + i as f32 / 8_f) * 180_f + 160_f;
|
|
||||||
let inline y = sin(t * 1.7 + i as f32 / 9_f) * 140_f + 120_f;
|
|
||||||
blitSprite(SPRITE, 16, x as i32, y as i32, 0x100);
|
|
||||||
branch_if (i +:= 1) < 200: spriteLoop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start fn start() {
|
|
||||||
printChar('OO');
|
|
||||||
circle(8_f, 8_f, 6_f, 75);
|
|
||||||
grabSprite(SPRITE, 16, 0, 0, 0);
|
|
||||||
}
|
|
||||||
@@ -30,13 +30,11 @@ import "env.printInt" fn printInt(i32);
|
|||||||
import "env.setTextColor" fn setTextColor(i32);
|
import "env.setTextColor" fn setTextColor(i32);
|
||||||
import "env.setBackgroundColor" fn setBackgroundColor(i32);
|
import "env.setBackgroundColor" fn setBackgroundColor(i32);
|
||||||
import "env.setCursorPosition" fn setCursorPosition(i32, i32);
|
import "env.setCursorPosition" fn setCursorPosition(i32, i32);
|
||||||
import "env.rectangleOutline" fn rectangleOutline(f32, f32, f32, f32, i32);
|
import "env.rectangle_outline" fn rectangle_outline(f32, f32, f32, f32, i32);
|
||||||
import "env.circleOutline" fn circleOutline(f32, f32, f32, i32);
|
import "env.circle_outline" fn circle_outline(f32, f32, f32, i32);
|
||||||
import "env.exp" fn exp(f32) -> f32;
|
import "env.exp" fn exp(f32) -> f32;
|
||||||
import "env.playNote" fn playNote(i32, i32);
|
import "env.playNote" fn playNote(i32, i32);
|
||||||
import "env.sndGes" fn sndGes(i32) -> f32;
|
import "env.sndGes" fn sndGes(i32) -> f32;
|
||||||
import "env.blitSprite" fn blitSprite(i32, i32, i32, i32, i32);
|
|
||||||
import "env.grabSprite" fn grabSprite(i32, i32, i32, i32, i32);
|
|
||||||
|
|
||||||
const TIME_MS = 0x40;
|
const TIME_MS = 0x40;
|
||||||
const GAMEPAD = 0x44;
|
const GAMEPAD = 0x44;
|
||||||
|
|||||||
@@ -30,13 +30,11 @@
|
|||||||
(import "env" "setTextColor" (func $setTextColor (param i32)))
|
(import "env" "setTextColor" (func $setTextColor (param i32)))
|
||||||
(import "env" "setBackgroundColor" (func $setBackgroundColor (param i32)))
|
(import "env" "setBackgroundColor" (func $setBackgroundColor (param i32)))
|
||||||
(import "env" "setCursorPosition" (func $setCursorPosition (param i32) (param i32)))
|
(import "env" "setCursorPosition" (func $setCursorPosition (param i32) (param i32)))
|
||||||
(import "env" "rectangleOutline" (func $rectangleOutline (param f32) (param f32) (param f32) (param f32) (param i32)))
|
(import "env" "rectangle_outline" (func $rectangle_outline (param f32) (param f32) (param f32) (param f32) (param i32)))
|
||||||
(import "env" "circleOutline" (func $circleOutline (param f32) (param f32) (param f32) (param i32)))
|
(import "env" "circle_outline" (func $circle_outline (param f32) (param f32) (param f32) (param i32)))
|
||||||
(import "env" "exp" (func $exp (param f32) (result f32)))
|
(import "env" "exp" (func $exp (param f32) (result f32)))
|
||||||
(import "env" "playNote" (func $playNote (param i32) (param i32)))
|
(import "env" "playNote" (func $playNote (param i32) (param i32)))
|
||||||
(import "env" "sndGes" (func $sndGes (param i32) (result f32)))
|
(import "env" "sndGes" (func $sndGes (param i32) (result f32)))
|
||||||
(import "env" "blitSprite" (func $blitSprite (param i32) (param i32) (param i32) (param i32) (param i32)))
|
|
||||||
(import "env" "grabSprite" (func $grabSprite (param i32) (param i32) (param i32) (param i32) (param i32)))
|
|
||||||
|
|
||||||
;; to use defines, include this file with a preprocessor
|
;; to use defines, include this file with a preprocessor
|
||||||
;; like gpp (https://logological.org/gpp).
|
;; like gpp (https://logological.org/gpp).
|
||||||
|
|||||||
6
examples/tinygo/build.sh
Executable file
6
examples/tinygo/build.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
tinygo build -o cart.wasm -target target.json ./main.go
|
||||||
|
uw8 filter-exports cart.wasm cart.wasm && \
|
||||||
|
#wasm-opt -Oz --fast-math --strip-producers -o cart.wasm cart.wasm && \
|
||||||
|
uw8 pack -l 9 cart.wasm cart.uw8
|
||||||
38
examples/tinygo/main.go
Normal file
38
examples/tinygo/main.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:wasm-module env
|
||||||
|
//export atan2
|
||||||
|
func atan2(x, y float32) float32
|
||||||
|
|
||||||
|
//go:wasm-module env
|
||||||
|
//export time
|
||||||
|
func time() float32
|
||||||
|
|
||||||
|
func sqrt(v float32) float32 {
|
||||||
|
return float32(math.Sqrt(float64(v)))
|
||||||
|
}
|
||||||
|
|
||||||
|
var FRAMEBUFFER = (*[320 * 240]byte)(unsafe.Pointer(uintptr(120)))
|
||||||
|
|
||||||
|
//export upd
|
||||||
|
func upd() {
|
||||||
|
var i int
|
||||||
|
for i < 320*240 {
|
||||||
|
t := time() * 63.0
|
||||||
|
x := float32(i%320 - 160)
|
||||||
|
y := float32(i/320 - 120)
|
||||||
|
d := float32(40000.0) / sqrt(x*x+y*y)
|
||||||
|
u := atan2(x, y) * 512.0 / 3.141
|
||||||
|
c := uint8((int(d+t*2.0) ^ int(u+t)) >> 4)
|
||||||
|
FRAMEBUFFER[i] = c
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
}
|
||||||
23
examples/tinygo/target.json
Normal file
23
examples/tinygo/target.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"llvm-target": "wasm32--wasi",
|
||||||
|
"build-tags": [ "tinygo.wasm" ],
|
||||||
|
"goos": "js",
|
||||||
|
"goarch": "wasm",
|
||||||
|
"linker": "wasm-ld",
|
||||||
|
"libc": "wasi-libc",
|
||||||
|
"cflags": [
|
||||||
|
"--target=wasm32--wasi",
|
||||||
|
"--sysroot={root}/lib/wasi-libc/sysroot",
|
||||||
|
"-Oz"
|
||||||
|
],
|
||||||
|
"ldflags": [
|
||||||
|
"--no-entry",
|
||||||
|
"--export-all",
|
||||||
|
"--import-memory",
|
||||||
|
"--initial-memory=262144",
|
||||||
|
"--global-base=81920",
|
||||||
|
"-zstack-size=4096",
|
||||||
|
"--strip-all"
|
||||||
|
],
|
||||||
|
"wasm-abi": "js"
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -171,7 +171,7 @@ export fn rectangle(x: f32, y: f32, w: f32, h: f32, col: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn rectangleOutline(x: f32, y: f32, w: f32, h: f32, col: i32) {
|
export fn rectangle_outline(x: f32, y: f32, w: f32, h: f32, col: i32) {
|
||||||
let xl = nearest(x) as i32;
|
let xl = nearest(x) as i32;
|
||||||
let xr = nearest(x + w) as i32;
|
let xr = nearest(x + w) as i32;
|
||||||
let yt = nearest(y) as i32;
|
let yt = nearest(y) as i32;
|
||||||
@@ -212,7 +212,7 @@ export fn circle(cx: f32, cy: f32, radius: f32, col: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn circleOutline(cx: f32, cy: f32, radius: f32, col: i32) {
|
export fn circle_outline(cx: f32, cy: f32, radius: f32, col: i32) {
|
||||||
let prev_w: f32;
|
let prev_w: f32;
|
||||||
let y = clamp(nearest(cy - radius) as i32, -1, 241);
|
let y = clamp(nearest(cy - radius) as i32, -1, 241);
|
||||||
let maxY = clamp(nearest(cy + radius) as i32, -1, 241);
|
let maxY = clamp(nearest(cy + radius) as i32, -1, 241);
|
||||||
@@ -352,92 +352,6 @@ export fn line(x1: f32, y1: f32, x2: f32, y2: f32, col: i32) {
|
|||||||
setPixel(i32.trunc_sat_f32_s(x1 + f * dx), i32.trunc_sat_f32_s(y1 + f * dy), col);
|
setPixel(i32.trunc_sat_f32_s(x1 + f * dx), i32.trunc_sat_f32_s(y1 + f * dy), col);
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn blitSprite(sprite: i32, size: i32, x: i32, y: i32, control: i32) {
|
|
||||||
let lazy width = size & 65535;
|
|
||||||
let lazy height = select(size >> 16, size >> 16, width);
|
|
||||||
|
|
||||||
let lazy x0 = select(x < 0, -x, 0);
|
|
||||||
let lazy x1 = select(x + width > 320, 320 - x, width);
|
|
||||||
let lazy y0 = select(y < 0, -y, 0);
|
|
||||||
let lazy y1 = select(y + height > 240, 240 - y, height);
|
|
||||||
|
|
||||||
let lazy numRows = y1 - y0;
|
|
||||||
let lazy numCols = x1 - x0;
|
|
||||||
if numRows <= 0 | numCols <= 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let trans = (control & 511) - 256;
|
|
||||||
let lazy flip_x = 1 - ((control >> 8) & 2);
|
|
||||||
let lazy flip_y = 1 - ((control >> 9) & 2);
|
|
||||||
if flip_x < 0 {
|
|
||||||
sprite += width - 1;
|
|
||||||
}
|
|
||||||
if flip_y < 0 {
|
|
||||||
sprite += (height - 1) * width;
|
|
||||||
}
|
|
||||||
|
|
||||||
let spriteRow = sprite + x0 * flip_x + y0 * flip_y * width;
|
|
||||||
let screenRow = x + x0 + (y + y0) * 320;
|
|
||||||
|
|
||||||
loop yloop {
|
|
||||||
let lx = 0;
|
|
||||||
loop xloop {
|
|
||||||
let lazy col = (spriteRow + lx * flip_x)?0;
|
|
||||||
if col != trans {
|
|
||||||
(screenRow + lx)?120 = col;
|
|
||||||
}
|
|
||||||
branch_if (lx +:= 1) < numCols: xloop;
|
|
||||||
}
|
|
||||||
spriteRow += width * flip_y;
|
|
||||||
screenRow += 320;
|
|
||||||
branch_if numRows -:= 1: yloop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export fn grabSprite(sprite: i32, size: i32, x: i32, y: i32, control: i32) {
|
|
||||||
let lazy width = size & 65535;
|
|
||||||
let lazy height = select(size >> 16, size >> 16, width);
|
|
||||||
|
|
||||||
let lazy x0 = select(x < 0, -x, 0);
|
|
||||||
let lazy x1 = select(x + width > 320, 320 - x, width);
|
|
||||||
let lazy y0 = select(y < 0, -y, 0);
|
|
||||||
let lazy y1 = select(y + height > 240, 240 - y, height);
|
|
||||||
|
|
||||||
let lazy numRows = y1 - y0;
|
|
||||||
let lazy numCols = x1 - x0;
|
|
||||||
if numRows <= 0 | numCols <= 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let trans = (control & 511) - 256;
|
|
||||||
let lazy flip_x = 1 - ((control >> 8) & 2);
|
|
||||||
let lazy flip_y = 1 - ((control >> 9) & 2);
|
|
||||||
if flip_x < 0 {
|
|
||||||
sprite += width - 1;
|
|
||||||
}
|
|
||||||
if flip_y < 0 {
|
|
||||||
sprite += (height - 1) * width;
|
|
||||||
}
|
|
||||||
|
|
||||||
let spriteRow = sprite + x0 * flip_x + y0 * flip_y * width;
|
|
||||||
let screenRow = x + x0 + (y + y0) * 320;
|
|
||||||
|
|
||||||
loop yloop {
|
|
||||||
let lx = 0;
|
|
||||||
loop xloop {
|
|
||||||
let lazy col = (screenRow + lx)?120;
|
|
||||||
if col != trans {
|
|
||||||
(spriteRow + lx * flip_x)?0 = col;
|
|
||||||
}
|
|
||||||
branch_if (lx +:= 1) < numCols: xloop;
|
|
||||||
}
|
|
||||||
spriteRow += width * flip_y;
|
|
||||||
screenRow += 320;
|
|
||||||
branch_if numRows -:= 1: yloop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// TEXT //
|
// TEXT //
|
||||||
//////////
|
//////////
|
||||||
|
|||||||
@@ -146,13 +146,13 @@ Fills the circle at `cx, cy` and with `radius` with the given color index.
|
|||||||
|
|
||||||
(Sets all pixels where the pixel center lies inside the circle.)
|
(Sets all pixels where the pixel center lies inside the circle.)
|
||||||
|
|
||||||
### fn rectangleOutline(x: f32, y: f32, w: f32, h: f32, color: i32)
|
### fn rectangle_outline(x: f32, y: f32, w: f32, h: f32, color: i32)
|
||||||
|
|
||||||
Draws a one pixel outline on the inside of the given rectangle.
|
Draws a one pixel outline on the inside of the given rectangle.
|
||||||
|
|
||||||
(Draws the outermost pixels that are still inside the rectangle area.)
|
(Draws the outermost pixels that are still inside the rectangle area.)
|
||||||
|
|
||||||
### fn circleOutline(cx: f32, cy: f32, radius: f32, color: i32)
|
### fn circle_outline(cx: f32, cy: f32, radius: f32, color: i32)
|
||||||
|
|
||||||
Draws a one pixel outline on the inside of the given circle.
|
Draws a one pixel outline on the inside of the given circle.
|
||||||
|
|
||||||
@@ -162,21 +162,6 @@ Draws a one pixel outline on the inside of the given circle.
|
|||||||
|
|
||||||
Draws a line from `x1,y1` to `x2,y2` in the given color index.
|
Draws a line from `x1,y1` to `x2,y2` in the given color index.
|
||||||
|
|
||||||
### fn blitSprite(spriteData: i32, size: i32, x: i32, y: i32, control: i32)
|
|
||||||
|
|
||||||
Copies the pixel data at `spriteData` onto the screen at `x`, `y`. The size of the sprite is passed as `width | (height << 16)`.
|
|
||||||
If the height is given as 0, the sprite is is treated as square (width x width).
|
|
||||||
|
|
||||||
The control parameter controls masking and flipping of the sprite:
|
|
||||||
* bits 0-7: color mask index
|
|
||||||
* bit 8: switch on masked blit (pixel with color mask index are treated as transparent)
|
|
||||||
* bit 9: flip sprite x
|
|
||||||
* bit 10: flip sprite y
|
|
||||||
|
|
||||||
### fn grabSprite(spriteData: i32, size: i32, x: i32, y: i32, control: i32)
|
|
||||||
|
|
||||||
Copies the pixel data on the screen at `x`, `y` to `spriteData`. Parameters are exactly the same as `blitSprite`.
|
|
||||||
|
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
MicroW8 provides input from a gamepad with one D-Pad and 4 buttons, or a keyboard emulation thereof.
|
MicroW8 provides input from a gamepad with one D-Pad and 4 buttons, or a keyboard emulation thereof.
|
||||||
|
|||||||
@@ -152,14 +152,14 @@ impl BaseModule {
|
|||||||
add_function(
|
add_function(
|
||||||
&mut functions,
|
&mut functions,
|
||||||
&type_map,
|
&type_map,
|
||||||
"rectangleOutline",
|
"rectangle_outline",
|
||||||
&[F32, F32, F32, F32, I32],
|
&[F32, F32, F32, F32, I32],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
add_function(
|
add_function(
|
||||||
&mut functions,
|
&mut functions,
|
||||||
&type_map,
|
&type_map,
|
||||||
"circleOutline",
|
"circle_outline",
|
||||||
&[F32, F32, F32, I32],
|
&[F32, F32, F32, I32],
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
@@ -169,21 +169,6 @@ impl BaseModule {
|
|||||||
add_function(&mut functions, &type_map, "playNote", &[I32, I32], None);
|
add_function(&mut functions, &type_map, "playNote", &[I32, I32], None);
|
||||||
add_function(&mut functions, &type_map, "sndGes", &[I32], Some(F32));
|
add_function(&mut functions, &type_map, "sndGes", &[I32], Some(F32));
|
||||||
|
|
||||||
add_function(
|
|
||||||
&mut functions,
|
|
||||||
&type_map,
|
|
||||||
"blitSprite",
|
|
||||||
&[I32, I32, I32, I32, I32],
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
add_function(
|
|
||||||
&mut functions,
|
|
||||||
&type_map,
|
|
||||||
"grabSprite",
|
|
||||||
&[I32, I32, I32, I32, I32],
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
for i in functions.len()..64 {
|
for i in functions.len()..64 {
|
||||||
add_function(
|
add_function(
|
||||||
&mut functions,
|
&mut functions,
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ impl Window {
|
|||||||
async fn create(window_config: WindowConfig) -> Result<Window> {
|
async fn create(window_config: WindowConfig) -> Result<Window> {
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let window = WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_inner_size(PhysicalSize::new(640u32, 480))
|
.with_inner_size(PhysicalSize::new(
|
||||||
|
(320. * window_config.scale).round() as u32,
|
||||||
|
(240. * window_config.scale).round() as u32,
|
||||||
|
))
|
||||||
.with_min_inner_size(PhysicalSize::new(320u32, 240))
|
.with_min_inner_size(PhysicalSize::new(320u32, 240))
|
||||||
.with_title("MicroW8")
|
.with_title("MicroW8")
|
||||||
.with_fullscreen(if window_config.fullscreen {
|
.with_fullscreen(if window_config.fullscreen {
|
||||||
@@ -72,7 +75,13 @@ impl Window {
|
|||||||
|
|
||||||
let surface_config = wgpu::SurfaceConfiguration {
|
let surface_config = wgpu::SurfaceConfiguration {
|
||||||
present_mode: wgpu::PresentMode::AutoNoVsync,
|
present_mode: wgpu::PresentMode::AutoNoVsync,
|
||||||
..surface.get_default_config(&adapter, window.inner_size().width, window.inner_size().height).expect("Surface incompatible with adapter")
|
..surface
|
||||||
|
.get_default_config(
|
||||||
|
&adapter,
|
||||||
|
window.inner_size().width,
|
||||||
|
window.inner_size().height,
|
||||||
|
)
|
||||||
|
.expect("Surface incompatible with adapter")
|
||||||
};
|
};
|
||||||
|
|
||||||
let filter: Box<dyn Filter> = create_filter(
|
let filter: Box<dyn Filter> = create_filter(
|
||||||
@@ -354,7 +363,7 @@ impl PaletteScreenMode {
|
|||||||
format: wgpu::TextureFormat::R8Uint,
|
format: wgpu::TextureFormat::R8Uint,
|
||||||
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
||||||
label: None,
|
label: None,
|
||||||
view_formats: &[]
|
view_formats: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let palette_texture = device.create_texture(&wgpu::TextureDescriptor {
|
let palette_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
@@ -369,7 +378,7 @@ impl PaletteScreenMode {
|
|||||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||||
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
||||||
label: None,
|
label: None,
|
||||||
view_formats: &[]
|
view_formats: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let screen_texture = device.create_texture(&wgpu::TextureDescriptor {
|
let screen_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
@@ -384,7 +393,7 @@ impl PaletteScreenMode {
|
|||||||
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
format: wgpu::TextureFormat::Rgba8UnormSrgb,
|
||||||
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::RENDER_ATTACHMENT,
|
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||||
label: None,
|
label: None,
|
||||||
view_formats: &[]
|
view_formats: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let framebuffer_texture_view =
|
let framebuffer_texture_view =
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct FpsCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
pub fn new(config: WindowConfig) -> Result<Window> {
|
pub fn new(mut config: WindowConfig) -> Result<Window> {
|
||||||
let fps_counter = if config.fps_counter {
|
let fps_counter = if config.fps_counter {
|
||||||
Some(FpsCounter {
|
Some(FpsCounter {
|
||||||
start: Instant::now(),
|
start: Instant::now(),
|
||||||
@@ -24,6 +24,7 @@ impl Window {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
config.scale = config.scale.max(1.).min(20.);
|
||||||
if config.enable_gpu {
|
if config.enable_gpu {
|
||||||
match gpu::Window::new(config) {
|
match gpu::Window::new(config) {
|
||||||
Ok(window) => {
|
Ok(window) => {
|
||||||
@@ -71,6 +72,7 @@ pub struct WindowConfig {
|
|||||||
filter: u32,
|
filter: u32,
|
||||||
fullscreen: bool,
|
fullscreen: bool,
|
||||||
fps_counter: bool,
|
fps_counter: bool,
|
||||||
|
scale: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowConfig {
|
impl Default for WindowConfig {
|
||||||
@@ -80,6 +82,7 @@ impl Default for WindowConfig {
|
|||||||
filter: 5,
|
filter: 5,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
fps_counter: false,
|
fps_counter: false,
|
||||||
|
scale: 2.,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +105,10 @@ impl WindowConfig {
|
|||||||
}
|
}
|
||||||
self.fullscreen = args.contains("--fullscreen");
|
self.fullscreen = args.contains("--fullscreen");
|
||||||
self.fps_counter = args.contains("--fps");
|
self.fps_counter = args.contains("--fps");
|
||||||
|
self.scale = args
|
||||||
|
.opt_value_from_str("--scale")
|
||||||
|
.unwrap()
|
||||||
|
.unwrap_or(self.scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user