mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42: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,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
|
||||
|
||||
Reference in New Issue
Block a user