2016-03-27 18:31:57 -04:00
|
|
|
in vec3 aPosition;
|
|
|
|
in vec4 aTextureInfo;
|
|
|
|
in ivec3 aTextureOffset;
|
|
|
|
in vec4 aColor;
|
|
|
|
in int id;
|
|
|
|
|
|
|
|
uniform mat4 perspectiveMatrix;
|
|
|
|
uniform mat4 cameraMatrix;
|
|
|
|
uniform mat4 modelMatrix[10];
|
|
|
|
uniform float lightLevel;
|
|
|
|
uniform float skyOffset;
|
|
|
|
uniform vec2 lighting;
|
|
|
|
|
|
|
|
out vec4 vColor;
|
|
|
|
out vec4 vTextureInfo;
|
|
|
|
out vec2 vTextureOffset;
|
|
|
|
out float vAtlas;
|
|
|
|
out float vID;
|
|
|
|
out vec3 vLighting;
|
|
|
|
|
|
|
|
#include get_light
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
vec3 pos = vec3(aPosition.x, -aPosition.y, aPosition.z);
|
|
|
|
gl_Position = perspectiveMatrix * cameraMatrix * modelMatrix[id] * vec4(pos, 1.0);
|
|
|
|
|
|
|
|
vColor = aColor;
|
|
|
|
vTextureInfo = aTextureInfo;
|
Use web-sys for web backend (#444)
A small step for #446 🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes #171 could not find Context in platform_impl.
winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.
Substantial refactoring to allow reusing the code between web/native:
* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads
* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper
* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2
* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL
* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook, mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web
* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446 🕸️ Web support
2020-12-26 16:42:37 -05:00
|
|
|
vTextureOffset = vec2(aTextureOffset.xy) / 16.0;
|
|
|
|
vAtlas = float(aTextureOffset.z);
|
2016-03-27 18:31:57 -04:00
|
|
|
vID = float(id);
|
|
|
|
|
|
|
|
vLighting = getLight(lighting);
|
|
|
|
}
|