Permalink
Browse files

moved around status icon assets and modified install script

  • Loading branch information...
1 parent 128f559 commit 8a8cb3f9c4121e2862fbc0a074979368cd2571c9 alexcb committed Jun 6, 2008
View
@@ -16,7 +16,8 @@ MESSAGE (STATUS "${PROJECT_NAME} version ${VERSION}")
# define some preprocessor strings that the code is expecting
ADD_DEFINITIONS( -DPROJECT=\"${PROJECT_NAME}\"
- -DVERSION=\"${VERSION}\" )
+ -DINSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"
+ -DVERSION=\"${VERSION}\" )
include(FindPkgConfig)
pkg_check_modules( GLIB glib-2.0 )
@@ -34,7 +35,7 @@ include_directories( .
${GLIB_INCLUDE_DIRS}
${FLTK_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
- /opt/local/include
+ ${CMAKE_INCLUDE_PATH}
)
@@ -57,7 +58,12 @@ ADD_SUBDIRECTORY(libstageplugin)
ENDIF( PLAYER_FOUND )
INSTALL(FILES rgb.txt stagelogo.png
- DESTINATION share
+ DESTINATION share/stage
+)
+
+FILE( GLOB assets "assets/*.png" )
+INSTALL(FILES ${assets}
+ DESTINATION share/stage/assets
)
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
View
@@ -370,21 +370,10 @@ void StgCanvas::draw()
//TODO find a better home for loading textures
if( loaded_texture == false ) {
- char* tmp = strdup( world->GetWorldFile()->filename );
- char* fullpath = (char*) malloc(PATH_MAX);
-
- //find path of images relative to the
- getcwd(fullpath, PATH_MAX);
- strcat( fullpath, "/" );
- strcat( fullpath, dirname(tmp));
- strcat( fullpath, "/assets/stall.png" );
-
- GLuint stall_id = TextureManager::getInstance().loadTexture( fullpath );
+ GLuint stall_id = TextureManager::getInstance().loadTexture( "assets/stall.png" );
TextureManager::getInstance()._stall_texture_id = stall_id;
loaded_texture = true;
- free( tmp );
- free( fullpath );
}
// install a font
View
@@ -48,6 +48,7 @@ int main( int argc, char* argv[] )
// arguments at index optindex and later are not options, so they
// must be world file names
+ bool loaded_world_file = false;
while( optindex < argc )
{
if( optindex > 0 )
@@ -56,9 +57,16 @@ int main( int argc, char* argv[] )
StgWorldGui* world = new StgWorldGui( 400, 300, worldfilename );
world->Load( worldfilename );
world->Start();
+ loaded_world_file = true;
}
optindex++;
}
+
+ if( loaded_world_file == false ) {
+ printf( "No world file specified.\n" );
+ }
+
+
StgWorldGui::Run(); // run all the simulations
}
@@ -8,26 +8,47 @@
*/
#include "texture_manager.hh"
+#include <sstream>
+
+//TODO Windows Port
+Fl_Shared_Image* TextureManager::loadImage( const char* filename )
+{
+ if( filename[ 0 ] == '/' || filename[ 0 ] == '~' )
+ return Fl_Shared_Image::get( filename );
+
+ const char* prefixes[] = {
+ ".",
+ INSTALL_PREFIX "/share/stage",
+ NULL
+ };
+
+ Fl_Shared_Image *img = NULL;
+ int i = 0;
+ while( img == NULL && prefixes[ i ] != NULL ) {
+ std::ostringstream oss;
+ oss << prefixes[ i ] << "/" << filename;
+ img = Fl_Shared_Image::get( oss.str().c_str() );
+ std::cout << "loading from: " << oss.str() << std::endl;
+ i++;
+ }
+ return img;
+}
GLuint TextureManager::loadTexture( const char *filename )
{
GLuint texName;
- Fl_Shared_Image *img = Fl_Shared_Image::get( filename );
+ Fl_Shared_Image *img = loadImage( filename );
if( img == NULL ) {
printf( "unable to open image: %s\n", filename );
return 0;
}
- std::cout << "loading image 1 " << std::endl;
-
//TODO display an error for incorrect depths
if( img->d() != 3 && img->d() != 4 ) {
printf( "unable to open image: %s - incorrect depth - should be 3 or 4\n", filename );
return 0;
}
- std::cout << "loading image 2 " << std::endl;
-
//TODO check for correct width/height - or convert it.
guchar* pixels = (guchar*)(img->data()[0]);
@@ -18,6 +18,9 @@
class TextureManager {
private:
TextureManager( void ) { }
+
+ //try to load filename from relative dir, then install path
+ Fl_Shared_Image* loadImage( const char* filename );
public:

0 comments on commit 8a8cb3f

Please sign in to comment.