roc/files.py
cecilkorik deaa55d535 working textures!
completely overhauled models framework...
now loads Model, Mesh, Material, and Texture (plus TextureFile)

fixed a number of bugs/inflexibilities in gamedata xml parser

refactored the various modules to use "init" functions to better control when they get loaded (ie, before or after OpenGL init)
which it turns out is *very important*, because if the shaders and textures get loaded before OpenGL does, they don't work. go figure.
2011-06-17 19:54:49 -06:00

35 lines
653 B
Python
Executable file

import os
import sys
import pygame
def get_basedir():
execpath = sys.argv[0]
execpath = os.path.split(execpath)[0]
if not execpath:
return '.'
return execpath
class filemanager(object):
def __init__(self):
self.basepath = get_basedir()
self.datapath = "data"
def path(self, *args):
return os.path.join(self.basepath, self.datapath, *args)
def open(self, *args):
filename = self.path(*args)
return open(filename, 'rb')
def png(self, *args):
filename = self.path(*args)
return pygame.image.load(filename)
def canonize_path(self, path):
return path.lower()
def init():
global mgr
mgr = filemanager()
mgr = None