Skip to content

Commit

Permalink
Remembered to initialize @previous_program
Browse files Browse the repository at this point in the history
  • Loading branch information
bil-bas committed Sep 6, 2013
1 parent 6c171d3 commit 9f1f935
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/texture_render_example.rb
Expand Up @@ -51,4 +51,4 @@ def button_down(id)
end

window = GameWindow.new
window.show
window.show
11 changes: 6 additions & 5 deletions lib/ashton/shader.rb
Expand Up @@ -19,8 +19,8 @@ class Shader
attr_reader :vertex_source, :fragment_source

# Is the shader currently in use?
def enabled?; defined?(@previous_program) ? @previous_program : false end
def enabled?; !!@previous_program end

# Is this the currently activated shader program?
def current?; glGetIntegerv(GL_CURRENT_PROGRAM) == @program end

Expand Down Expand Up @@ -48,6 +48,7 @@ def initialize(options = {})
@uniform_locations = {}
@attribute_locations = {}
@program = nil
@previous_program = nil
@image = nil
@color = [1, 1, 1, 1]

Expand All @@ -67,7 +68,7 @@ def initialize(options = {})
# GL_TEXTURE0 will be activated later. This is the main image texture.
set_uniform uniform_location("in_Texture", required: false), 0

# For multi-textured shaders, we use in_Texture<NUM> instead.
# For multi-textured shaders, we use in_Texture<NUM> instead.
set_uniform uniform_location("in_Texture0", required: false), 0
set_uniform uniform_location("in_Texture1", required: false), 1

Expand Down Expand Up @@ -234,7 +235,7 @@ def uniform_location(name, options = {})
options = {
required: true
}.merge! options

location = @uniform_locations[name]
if location
location
Expand Down Expand Up @@ -378,4 +379,4 @@ def replace_include(source)
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/ashton/version.rb
@@ -1,3 +1,3 @@
module Ashton
VERSION = "0.0.3alpha"
end
VERSION = "0.0.4alpha"
end

0 comments on commit 9f1f935

Please sign in to comment.