~vcs-imports/artoolkit/sf-trunk

« back to all changes in this revision

Viewing changes to artoolkit/lib/SRC/ARvrml/arViewer.cpp

  • Committer: philip_lamb
  • Date: 2007-11-06 20:33:30 UTC
  • Revision ID: svn-v4:d65a7696-613b-0410-ac10-aa9ec39ffaa2:trunk:273
Provide linkage to OpenVRML-0.14.3 for Visual Studio .NET 2003.
Fix usage in libARvrml for openvrml-0.16.6 under Windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        public:
59
59
                explicit file_resource_istream(const std::string & path): resource_istream(&this->buf_)
60
60
                {
61
 
                        if (!this->buf_.open(path.c_str(), ios_base::in)) {
62
 
                                this->setstate(ios_base::failbit);
 
61
                        if (!this->buf_.open(path.c_str(), ios_base::in | ios_base::binary)) {
 
62
                                this->setstate(ios_base::badbit);
63
63
                        }
64
64
                }
65
65
                        
78
78
                {
79
79
                        //
80
80
                        // A real application should use OS facilities for this.  This
81
 
                        // is a crude hack.
 
81
            // is a crude hack because sdl-viewer uses std::filebuf in
 
82
            // order to remain simple and portable.
82
83
                        //
83
84
                        using std::find;
84
85
                        using std::string;
95
96
                                find(next(dot_pos.base()), this->url_.end(), '#');
96
97
                        const string ext(dot_pos.base(), hash_pos);
97
98
                        if (iequals(ext, "wrl")) {
98
 
                                media_type = "model/vrml";
 
99
                media_type = openvrml::vrml_media_type;
99
100
                        } else if (iequals(ext, "x3dv")) {
100
 
                                media_type = "model/x3d+vrml";
 
101
                media_type = openvrml::x3d_vrml_media_type;
101
102
                        } else if (iequals(ext, "png")) {
102
103
                                media_type = "image/png";
103
104
                        } else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
120
121
        // file://
121
122
        //        ^
122
123
        // 01234567
123
 
        //
124
 
        string path = uri.substr(uri.find_first_of('/', 7));
 
124
        static const string::size_type authority_start_index = 7;
 
125
 
 
126
        //
 
127
        // On Windows we want to start at the drive letter, which is after the
 
128
        // first slash in the path.
 
129
        //
 
130
        // We ignore the content of the authority; a smarter implementation
 
131
        // should confirm that it is localhost, the machine name, or zero
 
132
        // length.
 
133
        //
 
134
        string::size_type path_start_index =
 
135
# ifdef _WIN32
 
136
                uri.find_first_of('/', authority_start_index) + 1;
 
137
# else
 
138
                uri.find_first_of('/', authority_start_index);
 
139
# endif
 
140
        string path = uri.substr(path_start_index);
125
141
        
126
142
        auto_ptr<resource_istream> in(new file_resource_istream(path));
127
143
        static_cast<file_resource_istream *>(in.get())->url(uri);
130
146
}
131
147
 
132
148
 
133
 
arVrmlViewer::arVrmlViewer() : gl::viewer::viewer()
 
149
arVrmlViewer::arVrmlViewer()
134
150
{
135
151
    internal_light = true;
136
152