mirror of
https://github.com/mattrberry/crab.git
synced 2024-12-31 10:23:42 +01:00
add optional interframe blending with m key
This commit is contained in:
parent
09481ae54d
commit
6f7f10d292
3 changed files with 15 additions and 1 deletions
|
@ -10,6 +10,8 @@ class Display
|
||||||
@last_time = Time.utc
|
@last_time = Time.utc
|
||||||
@seconds : Int32 = Time.utc.second
|
@seconds : Int32 = Time.utc.second
|
||||||
|
|
||||||
|
@blend : Bool = false
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@window = SDL::Window.new(window_title(59.7), WIDTH * SCALE, HEIGHT * SCALE, flags: SDL::Window::Flags::OPENGL)
|
@window = SDL::Window.new(window_title(59.7), WIDTH * SCALE, HEIGHT * SCALE, flags: SDL::Window::Flags::OPENGL)
|
||||||
setup_gl
|
setup_gl
|
||||||
|
@ -22,6 +24,15 @@ class Display
|
||||||
update_draw_count
|
update_draw_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def toggle_blending : Nil
|
||||||
|
if @blend
|
||||||
|
LibGL.disable(LibGL::BLEND)
|
||||||
|
else
|
||||||
|
LibGL.enable(LibGL::BLEND)
|
||||||
|
end
|
||||||
|
@blend = !@blend
|
||||||
|
end
|
||||||
|
|
||||||
private def window_title(fps : Float) : String
|
private def window_title(fps : Float) : String
|
||||||
"crab - #{fps.round(1)} fps"
|
"crab - #{fps.round(1)} fps"
|
||||||
end
|
end
|
||||||
|
@ -79,6 +90,8 @@ class Display
|
||||||
puts "OpenGL version: #{String.new(LibGL.get_string(LibGL::VERSION))}"
|
puts "OpenGL version: #{String.new(LibGL.get_string(LibGL::VERSION))}"
|
||||||
puts "Shader language version: #{String.new(LibGL.get_string(LibGL::SHADING_LANGUAGE_VERSION))}"
|
puts "Shader language version: #{String.new(LibGL.get_string(LibGL::SHADING_LANGUAGE_VERSION))}"
|
||||||
|
|
||||||
|
LibGL.blend_func(LibGL::SRC_ALPHA, LibGL::ONE_MINUS_SRC_ALPHA)
|
||||||
|
|
||||||
vert_shader_id = compile_shader(File.read("src/crab/shaders/gba_colors.vert"), LibGL::VERTEX_SHADER)
|
vert_shader_id = compile_shader(File.read("src/crab/shaders/gba_colors.vert"), LibGL::VERTEX_SHADER)
|
||||||
frag_shader_id = compile_shader(File.read("src/crab/shaders/gba_colors.frag"), LibGL::FRAGMENT_SHADER)
|
frag_shader_id = compile_shader(File.read("src/crab/shaders/gba_colors.frag"), LibGL::FRAGMENT_SHADER)
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ class Keypad
|
||||||
when .r? then @keyinput.r = bit
|
when .r? then @keyinput.r = bit
|
||||||
# Extras
|
# Extras
|
||||||
when .tab? then @gba.apu.toggle_sync if event.pressed?
|
when .tab? then @gba.apu.toggle_sync if event.pressed?
|
||||||
|
when .m? then @gba.display.toggle_blending if event.pressed?
|
||||||
else nil
|
else nil
|
||||||
end
|
end
|
||||||
when SDL::Event::JoyHat
|
when SDL::Event::JoyHat
|
||||||
|
|
|
@ -15,5 +15,5 @@ void main() {
|
||||||
30 * color.b + 230 * color.g + 10 * color.r,
|
30 * color.b + 230 * color.g + 10 * color.r,
|
||||||
220 * color.b + 10 * color.g + 50 * color.r) / 255,
|
220 * color.b + 10 * color.g + 50 * color.r) / 255,
|
||||||
vec3(1.0 / outGamma));
|
vec3(1.0 / outGamma));
|
||||||
frag_color.a = 1.0;
|
frag_color.a = 0.5;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue