mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Renamed lighting shader to default, shoehorned in glsl 3.30 support for Intel on Linux, removed duplicate handleGlError methods, added OpenGL and GLU to Object namespace, removed redundant includes for OpenGL and GLU, VBO and VAO now render (all be it incorrectly)
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
class IMICFPS
|
||||
class BoundingBoxRenderer
|
||||
include OpenGL
|
||||
include GLU
|
||||
|
||||
attr_reader :bounding_boxes, :vertex_count
|
||||
def initialize(game_state:)
|
||||
@game_state = game_state
|
||||
@@ -11,14 +8,6 @@ class IMICFPS
|
||||
@vertex_count = 0
|
||||
end
|
||||
|
||||
def handleGlError
|
||||
e = glGetError()
|
||||
if e != GL_NO_ERROR
|
||||
$stderr.puts "OpenGL error in: #{gluErrorString(e)} (#{e})\n"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def create_bounding_box(object, box, color = nil, mesh_object_id)
|
||||
|
||||
color ||= object.debug_color
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
class IMICFPS
|
||||
class OpenGLRenderer
|
||||
include CommonMethods
|
||||
include OpenGL
|
||||
include GLU
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
def handleGlError
|
||||
e = glGetError()
|
||||
if e != GL_NO_ERROR
|
||||
$stderr.puts "OpenGL error in: #{gluErrorString(e)} (#{e})\n"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def draw_object(object)
|
||||
handleGlError
|
||||
@@ -28,12 +15,12 @@ class IMICFPS
|
||||
|
||||
handleGlError
|
||||
|
||||
if Shader.available?("lighting")
|
||||
Shader.use("lighting") do |shader|
|
||||
glUniform3f(shader.attribute_location("SunLight"), 1.0, 1.0, 1.0)
|
||||
if Shader.available?("default")
|
||||
Shader.use("default") do |shader|
|
||||
glUniform3f(shader.attribute_location("worldPosition"), object.position.x, object.position.y, object.position.z)
|
||||
|
||||
handleGlError
|
||||
draw_mesh(object.model)
|
||||
draw_model(object.model)
|
||||
object.draw
|
||||
end
|
||||
else
|
||||
@@ -47,6 +34,28 @@ class IMICFPS
|
||||
handleGlError
|
||||
end
|
||||
|
||||
def draw_model(model)
|
||||
glBindVertexArray(model.vertex_array_id)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, model.vertices_buffer_id)
|
||||
glEnableVertexAttribArray(0)
|
||||
glEnableVertexAttribArray(1)
|
||||
glEnableVertexAttribArray(2)
|
||||
glEnableVertexAttribArray(3)
|
||||
glEnableVertexAttribArray(4)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, model.vertices.count)
|
||||
window.number_of_vertices+=model.vertices.size
|
||||
|
||||
glDisableVertexAttribArray(4)
|
||||
glDisableVertexAttribArray(3)
|
||||
glDisableVertexAttribArray(2)
|
||||
glDisableVertexAttribArray(1)
|
||||
glDisableVertexAttribArray(0)
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||
glBindVertexArray(0)
|
||||
end
|
||||
|
||||
def draw_mesh(model)
|
||||
model.objects.each_with_index do |o, i|
|
||||
glEnable(GL_CULL_FACE) if model.entity.backface_culling
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class IMICFPS
|
||||
class Renderer
|
||||
include CommonMethods
|
||||
include OpenGL
|
||||
include GLU
|
||||
|
||||
attr_reader :opengl_renderer, :bounding_box_renderer
|
||||
|
||||
@@ -28,14 +26,6 @@ class IMICFPS
|
||||
# @bounding_box_renderer.bounding_boxes.clear
|
||||
end
|
||||
|
||||
def handleGlError
|
||||
e = glGetError()
|
||||
if e != GL_NO_ERROR
|
||||
$stderr.puts "OpenGL error in: #{gluErrorString(e)} (#{e})\n"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
def finalize # cleanup
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user