00001
00002
00003
00004
00005 #ifndef CAJUN_DRAW_STATIC_TRIANGLES_H
00006 #define CAJUN_DRAW_STATIC_TRIANGLES_H
00007
00008 #include "data_queue.H"
00009 #include "conf.H"
00010 #include "component_interface.H"
00011 #include <vector>
00012 #include <fstream>
00013
00014 #include "GL/glx.h"
00015
00016 #ifdef VR_JUGGLER
00017 #include <vrj/Draw/OGL/GlContextData.h>
00018 #endif
00019
00020 namespace cajun
00021 {
00022 class draw_static_triangles_t : public component_interface_t
00023 {
00024 public:
00025 draw_static_triangles_t (double cbviz_orgin_[3],conf_t &conf,
00026 char const *indices_file_,
00027 char const *vertices_file_);
00028 virtual ~draw_static_triangles_t ();
00029 void update_data (double bot_pos_[3]);
00030 void display (double bot_pos[3]);
00031 void toggle_display ();
00032 void init_data ();
00033
00034 bool load_vertices ();
00035 bool load_indices ();
00036 bool load_triangles ();
00037 private:
00038 struct point_t
00039 {
00040 point_t () {;}
00041 point_t (float pt_x_, float pt_y_, float pt_z_)
00042 : x (pt_x_), y (pt_y_), z (pt_z_)
00043 {}
00044 point_t (double pt_x_, double pt_y_, double pt_z_)
00045 : x (pt_x_), y (pt_y_), z (pt_z_)
00046 {}
00047 float x, y, z;
00048 float normal_x, normal_y, normal_z;
00049 uint8_t r,g,b,a;
00050 };
00051
00052 std::vector<point_t> m_vertex_data;
00053 std::vector<unsigned> m_indices;
00054
00055 size_t m_num_indices;
00056
00057 bool m_triangle_draw;
00058
00059 #ifdef VR_JUGGLER
00060 vrj::GlContextData<GLuint> m_vbo_tri_vert_name;
00061 vrj::GlContextData<GLuint> m_vbo_tri_element_name;
00062 #else
00063 unsigned m_vbo_tri_vert_name;
00064 unsigned m_vbo_tri_element_name;
00065 #endif
00066 unsigned m_vbo_support;
00067
00068 bool m_load_triangles_files;
00069 std::ifstream m_indices_file;
00070 std::ifstream m_vertices_file;
00071
00072 PFNGLGENBUFFERSARBPROC glGenBuffersARB;
00073 PFNGLBINDBUFFERARBPROC glBindBufferARB;
00074 PFNGLBUFFERDATAARBPROC glBufferDataARB;
00075 PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB;
00076 PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;
00077 PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElementsEXT;
00078 };
00079 }
00080 #endif