# HG changeset patch # User John Tsiombikas # Date 1385837541 -7200 # Node ID 7d6b667821cf2d748d5052f51451cfba904b8ff2 # Parent 693bb1df955383bc0571bc8d6c5b4e8848b69d36 wrapped everything in the goatgfx namespace diff -r 693bb1df9553 -r 7d6b667821cf Makefile.in --- a/Makefile.in Sat Nov 30 15:15:34 2013 +0200 +++ b/Makefile.in Sat Nov 30 20:52:21 2013 +0200 @@ -30,7 +30,7 @@ CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(cfg_cflags) $(libs_cflags) CXXFLAGS = $(CFLAGS) -LDFLAGS = $(cfg_ldflags) $(libs_ldflags) +LDFLAGS = $(cfg_ldflags) $(libs_ldflags) -lgoat3d .PHONY: all all: $(lib_so) $(lib_a) diff -r 693bb1df9553 -r 7d6b667821cf configure --- a/configure Sat Nov 30 15:15:34 2013 +0200 +++ b/configure Sat Nov 30 20:52:21 2013 +0200 @@ -74,7 +74,7 @@ echo ok fi - LDFLAGS="$LDFLAGS -lovr" + LDFLAGS="$LDFLAGS -lovr -ludev -lXinerama" rm -f $tmpfile_bin $tmpfile_src } diff -r 693bb1df9553 -r 7d6b667821cf src/assload.cc --- a/src/assload.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/assload.cc Sat Nov 30 20:52:21 2013 +0200 @@ -12,8 +12,10 @@ #include "assimp/postprocess.h" #include "texman.h" #include "material.h" +#include "scene.h" using namespace std; +using namespace goatgfx; static bool load_material(Material *mat, const aiMaterial *aimat); static Object *load_node(const aiScene *aiscn, const aiNode *ainode); @@ -428,6 +430,8 @@ #else // !defined USE_ASSIMP +using namespace goatgfx; + bool load_ass(Scene *scn, const char *fname) { error_log("load_ass: assimp support not compiled in\n"); diff -r 693bb1df9553 -r 7d6b667821cf src/assload.h --- a/src/assload.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/assload.h Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,10 @@ #include #include "scene.h" +namespace goatgfx { + bool load_ass(Scene *scn, const char *fname); +} + #endif // ASSLOAD_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/camera.cc --- a/src/camera.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/camera.cc Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "unistate.h" #include "vr.h" +using namespace goatgfx; + Camera::Camera() { roll = 0.0; diff -r 693bb1df9553 -r 7d6b667821cf src/camera.h --- a/src/camera.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/camera.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include +namespace goatgfx { + class Camera { protected: float roll; @@ -95,4 +97,6 @@ void track_vr(); }; +} // namespace goatgfx + #endif // CAMERA_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/curve.cc --- a/src/curve.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/curve.cc Sat Nov 30 20:52:21 2013 +0200 @@ -5,6 +5,8 @@ #include "shader.h" #include "logger.h" +using namespace goatgfx; + #define DEF_THICKNESS 0.075 #define DEF_SEGM_SUB 3 #define DEF_RING_SUB 6 diff -r 693bb1df9553 -r 7d6b667821cf src/curve.h --- a/src/curve.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/curve.h Sat Nov 30 20:52:21 2013 +0200 @@ -6,6 +6,8 @@ #include "vmath/vmath.h" #include "mesh.h" +namespace goatgfx { + class Curve { private: std::string name; @@ -61,4 +63,6 @@ void draw() const; }; +} // namespace goatgfx + #endif // CURVE_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/curveload.cc --- a/src/curveload.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/curveload.cc Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "3dschunks.h" #include "logger.h" +using namespace goatgfx; + #ifndef _MSC_VER #include #else diff -r 693bb1df9553 -r 7d6b667821cf src/curveload.h --- a/src/curveload.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/curveload.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,10 @@ #include "scene.h" +namespace goatgfx { + bool load_curves(Scene *scn, const char *fname); +} + #endif // CURVELOAD_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/datapath.cc --- a/src/datapath.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/datapath.cc Sat Nov 30 20:52:21 2013 +0200 @@ -4,8 +4,12 @@ #include "logger.h" #include "datapath.h" +using namespace goatgfx; + static std::set paths; +namespace goatgfx { + void add_data_path(const char *path) { paths.insert(path); @@ -65,3 +69,5 @@ return std::string(path); } #endif + +} // namespace goatgfx diff -r 693bb1df9553 -r 7d6b667821cf src/datapath.h --- a/src/datapath.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/datapath.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,8 +3,12 @@ #include +namespace goatgfx { + void add_data_path(const char *path); std::string datafile_path(const char *fname); +} // namespace goatgfx + #endif // DATAPATH_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/dataset.h --- a/src/dataset.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/dataset.h Sat Nov 30 20:52:21 2013 +0200 @@ -22,6 +22,8 @@ #include #include +namespace goatgfx { + template class DataSet { protected: @@ -39,6 +41,8 @@ T get(const char *name) const; }; +} // namespace goatgfx + #include "dataset.inl" #endif // DATASET_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/dataset.inl --- a/src/dataset.inl Sat Nov 30 15:15:34 2013 +0200 +++ b/src/dataset.inl Sat Nov 30 20:52:21 2013 +0200 @@ -2,6 +2,8 @@ #include #include "datapath.h" +namespace goatgfx { + template DataSet::DataSet(T (*load_func)(const char*), void (*destr_func)(T)) { @@ -35,7 +37,7 @@ return iter->second; } - std::string path = datafile_path(name); + std::string path = goatgfx::datafile_path(name); if(path.empty()) { fprintf(stderr, "can't find data file: %s\n", name); return 0; @@ -47,3 +49,5 @@ } return res; } + +} // namespace goatgfx diff -r 693bb1df9553 -r 7d6b667821cf src/geom.cc --- a/src/geom.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/geom.cc Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "geom.h" #include "logger.h" +using namespace goatgfx; + GeomObject::~GeomObject() { } diff -r 693bb1df9553 -r 7d6b667821cf src/geom.h --- a/src/geom.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/geom.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "vmath/vmath.h" +namespace goatgfx { + class GeomObject; struct HitPoint { @@ -64,4 +66,6 @@ bool intersect(const Ray &ray, HitPoint *hit = 0) const; }; +} // namespace goatgfx + #endif // GEOMOBJ_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/gfxutil.cc --- a/src/gfxutil.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/gfxutil.cc Sat Nov 30 20:52:21 2013 +0200 @@ -8,6 +8,8 @@ #include "opengl.h" #include "logger.h" +using namespace goatgfx; + void draw_rect(const Vector3 &v1, const Vector3 &v2, Texture2D *tex, ShaderProg *sdr) { static ShaderProg *defsdr; diff -r 693bb1df9553 -r 7d6b667821cf src/gfxutil.h --- a/src/gfxutil.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/gfxutil.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,9 +3,13 @@ #include +namespace goatgfx { + class Texture2D; class ShaderProg; void draw_rect(const Vector3 &v1, const Vector3 &v2, Texture2D *tex = 0, ShaderProg *sdr = 0); +} // namespace goatgfx + #endif // GFXUTIL_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/goat3dgfx.cc --- a/src/goat3dgfx.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/goat3dgfx.cc Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "vr.h" #include "logger.h" +using namespace goatgfx; + bool init_goat_graphics() { info_log("initializing goat3d graphics\n"); diff -r 693bb1df9553 -r 7d6b667821cf src/image.cc --- a/src/image.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/image.cc Sat Nov 30 20:52:21 2013 +0200 @@ -10,6 +10,7 @@ #include "image.h" #include "logger.h" +using namespace goatgfx; static int pixel_elements(Image::Format fmt); static int elem_size(Image::Format fmt); diff -r 693bb1df9553 -r 7d6b667821cf src/image.h --- a/src/image.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/image.h Sat Nov 30 20:52:21 2013 +0200 @@ -1,6 +1,7 @@ #ifndef IMAGE_H_ #define IMAGE_H_ +namespace goatgfx { class Image { public: @@ -41,4 +42,6 @@ bool save(const char *fname) const; }; +} // namespace goatgfx + #endif // IMAGE_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/logger.cc --- a/src/logger.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/logger.cc Sat Nov 30 20:52:21 2013 +0200 @@ -8,6 +8,8 @@ #include #endif +using namespace goatgfx; + enum { LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL, LOG_DEBUG }; static int typecolor(int type); @@ -41,6 +43,8 @@ #endif } +namespace goatgfx { + void info_log(const char *fmt, ...) { va_list ap; @@ -86,6 +90,8 @@ va_end(ap); } +} // namespace goatgfx + enum { BLACK = 0, RED, diff -r 693bb1df9553 -r 7d6b667821cf src/logger.h --- a/src/logger.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/logger.h Sat Nov 30 20:52:21 2013 +0200 @@ -1,10 +1,14 @@ #ifndef LOGGER_H_ #define LOGGER_H_ +namespace goatgfx { + void info_log(const char *fmt, ...); void warning_log(const char *fmt, ...); void error_log(const char *fmt, ...); void fatal_log(const char *fmt, ...); void debug_log(const char *fmt, ...); +} // namespace goatgfx + #endif // LOGGER_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/material.cc --- a/src/material.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/material.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,6 +1,8 @@ #include "material.h" #include "unistate.h" +using namespace goatgfx; + Material::Material() : diffuse(1, 1, 1), specular(0, 0, 0) { diff -r 693bb1df9553 -r 7d6b667821cf src/material.h --- a/src/material.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/material.h Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "vmath/vmath.h" #include "texture.h" +namespace goatgfx { + enum { TEX_DIFFUSE, TEX_SPECULAR, @@ -26,4 +28,6 @@ void setup(bool use_textures = true) const; }; +} // namespace goatgfx + #endif // MATERIAL_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/mesh.cc --- a/src/mesh.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/mesh.cc Sat Nov 30 20:52:21 2013 +0200 @@ -7,6 +7,8 @@ #include "xform_node.h" #include "logger.h" +using namespace goatgfx; + int Mesh::global_sdr_loc[NUM_MESH_ATTR] = { 0, 1, 2, 3, 4, 5 }; unsigned int Mesh::intersect_mode = ISECT_DEFAULT; float Mesh::vertex_sel_dist = 0.01; diff -r 693bb1df9553 -r 7d6b667821cf src/mesh.h --- a/src/mesh.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/mesh.h Sat Nov 30 20:52:21 2013 +0200 @@ -6,6 +6,8 @@ #include #include "geom.h" +namespace goatgfx { + enum { MESH_ATTR_VERTEX, MESH_ATTR_NORMAL, @@ -207,5 +209,6 @@ bool intersect(const Ray &ray, HitPoint *hit = 0) const; }; +} // namespace goatgfx #endif // MESH_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/meshgen.cc --- a/src/meshgen.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/meshgen.cc Sat Nov 30 20:52:21 2013 +0200 @@ -2,6 +2,8 @@ #include "mesh.h" #include "logger.h" +using namespace goatgfx; + // -------- sphere -------- #define SURAD(u) ((u) * 2.0 * M_PI) diff -r 693bb1df9553 -r 7d6b667821cf src/meshgen.h --- a/src/meshgen.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/meshgen.h Sat Nov 30 20:52:21 2013 +0200 @@ -1,6 +1,8 @@ #ifndef MESHGEN_H_ #define MESHGEN_H_ +namespace goatgfx { + class Mesh; void gen_sphere(Mesh *mesh, float rad, int usub, int vsub, float urange = 1.0, float vrange = 1.0); @@ -8,4 +10,6 @@ void gen_cone(Mesh *mesh, float rad, float height, int usub, int vsub, int capsub = 0, float urange = 1.0, float vrange = 1.0); void gen_plane(Mesh *mesh, float width, float height, int usub = 1, int vsub = 1); +} // namespace goatgfx + #endif // MESHGEN_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/object.cc --- a/src/object.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/object.cc Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "unistate.h" #include "logger.h" +using namespace goatgfx; + static void destroy_all_rec(XFormNode *node); static void get_all_meshes_rec(XFormNode *node, std::list *reslist); diff -r 693bb1df9553 -r 7d6b667821cf src/object.h --- a/src/object.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/object.h Sat Nov 30 20:52:21 2013 +0200 @@ -6,6 +6,8 @@ #include "mesh.h" #include "material.h" +namespace goatgfx { + enum DrawMode { DRAW_DEFAULT, DRAW_WIREFRAME, @@ -48,4 +50,6 @@ static DrawMode set_draw_mode(DrawMode mode); }; +} // namespace goatgfx + #endif // OBJECT_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/opengl.cc --- a/src/opengl.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/opengl.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,5 +1,9 @@ #include "opengl.h" +using namespace goatgfx; + +namespace goatgfx { + void init_opengl() { #ifdef __GLEW_H__ @@ -27,3 +31,5 @@ } return errnames[err - GL_INVALID_ENUM]; } + +} // namespace goatgfx diff -r 693bb1df9553 -r 7d6b667821cf src/opengl.h --- a/src/opengl.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/opengl.h Sat Nov 30 20:52:21 2013 +0200 @@ -64,8 +64,12 @@ } \ } while(0) +namespace goatgfx { + void init_opengl(); const char *strglerr(int err); +} // namespace goatgfx + #endif // OPENGL_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/psyspp.cc --- a/src/psyspp.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/psyspp.cc Sat Nov 30 20:52:21 2013 +0200 @@ -8,6 +8,8 @@ #include "texman.h" #include "texgen.h" +using namespace goatgfx; + static void pdraw_start(const psys_emitter *em, void *cls); static void pdraw(const psys_emitter *em, const psys_particle *part, void *cls); static void pdraw_end(const psys_emitter *em, void *cls); @@ -59,7 +61,7 @@ bool ParticleSystemAttributes::load(const char *fname) { psys_texture_loader(psys_load_texture, 0, this); - return psys_load_attr(psattr, datafile_path(fname).c_str()) != -1; + return psys_load_attr(psattr, goatgfx::datafile_path(fname).c_str()) != -1; } bool ParticleSystemAttributes::load(FILE *fp) diff -r 693bb1df9553 -r 7d6b667821cf src/psyspp.h --- a/src/psyspp.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/psyspp.h Sat Nov 30 20:52:21 2013 +0200 @@ -5,6 +5,8 @@ #include "texture.h" #include +namespace goatgfx { + class ParticleSystemAttributes { private: Texture *tex; @@ -76,4 +78,6 @@ void draw() const; }; +} // namespace goatgfx + #endif // PSYSPP_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/rtarg.cc --- a/src/rtarg.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/rtarg.cc Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "texture.h" #include "logger.h" +using namespace goatgfx; + RenderTarget::RenderTarget() { width = height = 0; @@ -220,6 +222,8 @@ struct Viewport { int vp[4]; }; static std::stack vpstack; +namespace goatgfx { + void set_render_target(const RenderTarget *rtarg) { Viewport vp; @@ -257,3 +261,4 @@ return x + 1; } +} // namespace goatgfx diff -r 693bb1df9553 -r 7d6b667821cf src/rtarg.h --- a/src/rtarg.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/rtarg.h Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "vmath/vmath.h" #include "opengl.h" +namespace goatgfx { + class Texture; class RenderTarget { @@ -46,4 +48,6 @@ int next_pow2(int x); +} // namespace goatgfx + #endif // RTARG_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/scene.cc --- a/src/scene.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/scene.cc Sat Nov 30 20:52:21 2013 +0200 @@ -2,6 +2,8 @@ #include "opengl.h" #include "goat3d.h" +using namespace goatgfx; + static Mesh *load_mesh(goat3d_mesh *gmesh); Scene::~Scene() diff -r 693bb1df9553 -r 7d6b667821cf src/scene.h --- a/src/scene.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/scene.h Sat Nov 30 20:52:21 2013 +0200 @@ -5,6 +5,8 @@ #include "object.h" #include "curve.h" +namespace goatgfx { + class Scene { public: std::vector objects; @@ -20,4 +22,6 @@ void draw(long msec = 0) const; }; +} // namespace goatgfx + #endif // SCENE_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/sdrman.cc --- a/src/sdrman.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/sdrman.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,5 +1,9 @@ #include "sdrman.h" +using namespace goatgfx; + +namespace goatgfx { + ShaderSet vsdrset(GL_VERTEX_SHADER); ShaderSet psdrset(GL_FRAGMENT_SHADER); @@ -25,3 +29,5 @@ } return prog; } + +} // namespace goatgfx diff -r 693bb1df9553 -r 7d6b667821cf src/sdrman.h --- a/src/sdrman.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/sdrman.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,9 +3,13 @@ #include "shader.h" +namespace goatgfx { + extern ShaderSet vsdrset; extern ShaderSet psdrset; ShaderProg *get_sdrprog(const char *vname, const char *pname); +} // namespace goatgfx + #endif // SDRMAN_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/shader.cc --- a/src/shader.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/shader.cc Sat Nov 30 20:52:21 2013 +0200 @@ -14,6 +14,8 @@ #include #endif +using namespace goatgfx; + #ifdef __GLEW_H__ #define HAVE_GEOMETRY_SHADER #define HAVE_TESSELATION_SHADER diff -r 693bb1df9553 -r 7d6b667821cf src/shader.h --- a/src/shader.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/shader.h Sat Nov 30 20:52:21 2013 +0200 @@ -6,6 +6,8 @@ #include "opengl.h" #include "dataset.h" +namespace goatgfx { + class Shader { private: unsigned int sdr; @@ -132,4 +134,6 @@ ShaderSet(unsigned int type); }; +} // namespace goatgfx + #endif // SHADER_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/texgen.cc --- a/src/texgen.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texgen.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,8 +1,10 @@ #include "texgen.h" +using namespace goatgfx; + static void intcolor(const Vector4 &color, int *icol); -Image *texgen_solid(int xsz, int ysz, const Vector4 &color) +Image *goatgfx::texgen_solid(int xsz, int ysz, const Vector4 &color) { Image *img = new Image; if(!img->create(xsz, ysz, Image::FMT_RGBA)) { @@ -23,7 +25,7 @@ return img; } -Image *texgen_chess(int xsz, int ysz, int usub, int vsub, const Vector4 &col1, const Vector4 &col2) +Image *goatgfx::texgen_chess(int xsz, int ysz, int usub, int vsub, const Vector4 &col1, const Vector4 &col2) { Image *img = new Image; if(!img->create(xsz, ysz, Image::FMT_RGBA)) { @@ -58,7 +60,7 @@ } -Image *texgen(int xsz, int ysz, float usize, float vsize, Vector4 (*eval)(float, float, void*), void *cls) +Image *goatgfx::texgen(int xsz, int ysz, float usize, float vsize, Vector4 (*eval)(float, float, void*), void *cls) { Image *img = new Image; if(!img->create(xsz, ysz, Image::FMT_RGBA)) { @@ -109,7 +111,7 @@ } -Image *texgen_fbm(int xsz, int ysz, float usize, float vsize, int octaves, const Vector4 &col1, const Vector4 &col2) +Image *goatgfx::texgen_fbm(int xsz, int ysz, float usize, float vsize, int octaves, const Vector4 &col1, const Vector4 &col2) { NoiseArg arg = {octaves, col1, col2}; if(arg.octaves < 1) { @@ -119,7 +121,7 @@ return texgen(xsz, ysz, usize, vsize, fbm_eval, &arg); } -Image *texgen_fbm_abs(int xsz, int ysz, float usize, float vsize, int octaves, const Vector4 &col1, const Vector4 &col2) +Image *goatgfx::texgen_fbm_abs(int xsz, int ysz, float usize, float vsize, int octaves, const Vector4 &col1, const Vector4 &col2) { NoiseArg arg = {octaves, col1, col2}; if(arg.octaves < 1) { diff -r 693bb1df9553 -r 7d6b667821cf src/texgen.h --- a/src/texgen.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texgen.h Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "image.h" #include "vmath/vmath.h" +namespace goatgfx { + Image *texgen_solid(int xsz, int ysz, const Vector4 &color); Image *texgen_chess(int xsz, int ysz, int usub, int vsub, const Vector4 &col1, const Vector4 &col2); Image *texgen_fbm(int xsz, int ysz, float usize, float vsize, int octaves, const Vector4 &col1, const Vector4 &col2); @@ -11,4 +13,6 @@ Image *texgen(int xsz, int ysz, float usize, float vsize, Vector4 (*eval)(float, float, void*), void *cls); +} // namespace goatgfx + #endif // TEXGEN_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/texman.cc --- a/src/texman.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texman.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,3 +1,5 @@ #include "texman.h" -TextureSet texset; +using namespace goatgfx; + +TextureSet goatgfx::texset; diff -r 693bb1df9553 -r 7d6b667821cf src/texman.h --- a/src/texman.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texman.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,10 @@ #include "texture.h" +namespace goatgfx { + extern TextureSet texset; +} + #endif // TEXMAN_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/texture.cc --- a/src/texture.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texture.cc Sat Nov 30 20:52:21 2013 +0200 @@ -6,6 +6,8 @@ #include "logger.h" #include "datapath.h" +using namespace goatgfx; + static int glifmt_from_ifmt(unsigned int ifmt); static int glfmt_from_ifmt(unsigned int ifmt); static int gltype_from_ifmt(unsigned int ifmt); @@ -17,6 +19,8 @@ GL_TEXTURE_2D, GL_TEXTURE_2D, GL_TEXTURE_2D, GL_TEXTURE_2D }; +namespace goatgfx { + void set_texture(Texture *tex, int tunit) { if(tex) { @@ -44,6 +48,7 @@ return 0; } +} // namespace goatgfx Texture::Texture() { diff -r 693bb1df9553 -r 7d6b667821cf src/texture.h --- a/src/texture.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/texture.h Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "dataset.h" #include "opengl.h" +namespace goatgfx { + class Image; class Texture { @@ -77,4 +79,6 @@ TextureSet(); }; +} // namespace goatgfx + #endif // TEXTURE_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/timer.cc --- a/src/timer.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/timer.cc Sat Nov 30 20:52:21 2013 +0200 @@ -1,9 +1,13 @@ #include "timer.h" +using namespace goatgfx; + #if defined(__APPLE__) && !defined(__unix__) #define __unix__ #endif +namespace goatgfx { + #ifdef __unix__ #include #include @@ -70,6 +74,8 @@ } } +} // namespace goatgfx + Timer::Timer() { diff -r 693bb1df9553 -r 7d6b667821cf src/timer.h --- a/src/timer.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/timer.h Sat Nov 30 20:52:21 2013 +0200 @@ -1,6 +1,8 @@ #ifndef TIMER_H_ #define TIMER_H_ +namespace goatgfx { + unsigned long get_time_msec(void); void sleep_msec(unsigned long msec); @@ -26,4 +28,5 @@ double get_sec() const; }; +} // namespace goatgfx #endif // TIMER_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/unistate.cc --- a/src/unistate.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/unistate.cc Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "shader.h" #include "logger.h" +using namespace goatgfx; + struct StateItem { StType type; @@ -19,6 +21,8 @@ static StType float_type(int elem); static StType int_type(int elem); +namespace goatgfx { + std::vector state; std::map stateidx; @@ -582,6 +586,8 @@ #endif } +} // namespace goatgfx + static const char *typestr(StType type) { switch(type) { diff -r 693bb1df9553 -r 7d6b667821cf src/unistate.h --- a/src/unistate.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/unistate.h Sat Nov 30 20:52:21 2013 +0200 @@ -3,6 +3,8 @@ #include "vmath/vmath.h" +namespace goatgfx { + class ShaderProg; enum StType { @@ -101,4 +103,6 @@ // TODO should do a matrix stack at some point ... +} // namespace goatgfx + #endif // UNISTATE_H_ diff -r 693bb1df9553 -r 7d6b667821cf src/vr/vr.cc --- a/src/vr/vr.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/vr/vr.cc Sat Nov 30 20:52:21 2013 +0200 @@ -35,7 +35,10 @@ extern "C" void vr_shutdown(void) { delete [] vr_ctx.info.display; + delete vr_ctx.ovr_sfusion; //System::Destroy(); + + memset(&vr_ctx, 0, sizeof vr_ctx); } static void init_ctx() @@ -144,7 +147,8 @@ printf(" name: %s\n", sinfo.ProductName); } - vr_ctx.ovr_sfusion.AttachToSensor(vr_ctx.ovr_sensor_dev); + vr_ctx.ovr_sfusion = new SensorFusion; + vr_ctx.ovr_sfusion->AttachToSensor(vr_ctx.ovr_sensor_dev); } return true; } @@ -285,12 +289,12 @@ extern "C" void vr_set_prediction_sec(float dt) { - vr_ctx.ovr_sfusion.SetPrediction(dt); + vr_ctx.ovr_sfusion->SetPrediction(dt); } extern "C" float vr_get_prediction_sec(void) { - return vr_ctx.ovr_sfusion.GetPredictionDelta(); + return vr_ctx.ovr_sfusion->GetPredictionDelta(); } extern "C" void vr_get_view_matrix(float *res, int eye) @@ -316,7 +320,7 @@ extern "C" void vr_get_rotation(float *quat) { - Quatf oq = vr_ctx.ovr_sfusion.GetPredictedOrientation(); + Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); quat[0] = oq.x; quat[1] = oq.y; quat[2] = oq.z; @@ -325,7 +329,7 @@ extern "C" void vr_get_rotation_euler(float *euler) { - Quatf oq = vr_ctx.ovr_sfusion.GetPredictedOrientation(); + Quatf oq = vr_ctx.ovr_sfusion->GetPredictedOrientation(); oq.GetEulerAngles(euler + 1, euler, euler + 2); } diff -r 693bb1df9553 -r 7d6b667821cf src/vr/vr_impl.h --- a/src/vr/vr_impl.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/vr/vr_impl.h Sat Nov 30 20:52:21 2013 +0200 @@ -9,7 +9,7 @@ DeviceManager *ovr_devman; HMDDevice *ovr_hmd_dev; SensorDevice *ovr_sensor_dev; - SensorFusion ovr_sfusion; + SensorFusion *ovr_sfusion; struct { char *display; diff -r 693bb1df9553 -r 7d6b667821cf src/xform_node.cc --- a/src/xform_node.cc Sat Nov 30 15:15:34 2013 +0200 +++ b/src/xform_node.cc Sat Nov 30 20:52:21 2013 +0200 @@ -4,6 +4,8 @@ #include "anim/anim.h" #include "anim/track.h" +using namespace goatgfx; + static inline anm_interpolator track_interpolator(Interp in); static inline anm_extrapolator track_extrapolator(Extrap ex); diff -r 693bb1df9553 -r 7d6b667821cf src/xform_node.h --- a/src/xform_node.h Sat Nov 30 15:15:34 2013 +0200 +++ b/src/xform_node.h Sat Nov 30 20:52:21 2013 +0200 @@ -9,12 +9,15 @@ #include "vmath/quat.h" #include "vmath/matrix.h" -enum Interp { INTERP_STEP, INTERP_LINEAR, INTERP_CUBIC }; -enum Extrap { EXTRAP_EXTEND, EXTRAP_CLAMP, EXTRAP_REPEAT }; struct anm_node; struct anm_track; +namespace goatgfx { + +enum Interp { INTERP_STEP, INTERP_LINEAR, INTERP_CUBIC }; +enum Extrap { EXTRAP_EXTEND, EXTRAP_CLAMP, EXTRAP_REPEAT }; + // XXX all time arguments are milliseconds class XFormNode { @@ -131,4 +134,6 @@ Vector3 operator ()(long tmsec = 0) const; }; +} // namespace goatgfx + #endif /* XFORM_NODE_H_ */