Added a large portion of I-MIC-FPS's opengl rendering and model loading systems

This commit is contained in:
2020-07-15 21:19:31 -05:00
parent d7dbcf8511
commit 041cfcccaa
22 changed files with 1724 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
module CyberarmEngine
module ModelCache
CACHE = {}
def self.find_or_cache(manifest:)
model_file = manifest.file_path + "/model/#{manifest.model}"
type = File.basename(model_file).split(".").last.to_sym
if model = load_model_from_cache(type, model_file)
return model
else
model = CyberarmEngine::Model.new(file_path: model_file)
cache_model(type, model_file, model)
return model
end
end
def self.load_model_from_cache(type, model_file)
if CACHE[type].is_a?(Hash)
if CACHE[type][model_file]
return CACHE[type][model_file]
end
end
return false
end
def self.cache_model(type, model_file, model)
CACHE[type] = {} unless CACHE[type].is_a?(Hash)
CACHE[type][model_file] = model
end
end
end