#include <Main/options.hxx>
#include "material.hxx"
-
+#include "texload.h"
// global material management class
fgMATERIAL_MGR material_mgr;
fgMATERIAL m;
fgOPTIONS *o;
char material_name[256];
- char path[256], fgpath[256];
+ char mpath[256], fg_mpath[256], tpath[256], fg_tpath[256];
char line[256], *line_ptr;
+ GLubyte *texbuf;
fgFile f;
+ int width, height;
o = ¤t_options;
// build the path name to the material db
- path[0] = '\0';
- strcat(path, o->fg_root);
- strcat(path, "/Scenery/");
- strcat(path, "Materials");
- strcpy(fgpath, path);
- strcat(fgpath, ".gz");
+ mpath[0] = '\0';
+ strcat(mpath, o->fg_root);
+ strcat(mpath, "/Scenery/");
+ strcat(mpath, "Materials");
+ strcpy(fg_mpath, mpath);
+ strcat(fg_mpath, ".gz");
// first try "path.gz"
- if ( (f = fgopen(fgpath, "rb")) == NULL ) {
+ if ( (f = fgopen(fg_mpath, "rb")) == NULL ) {
// next try "path"
- if ( (f = fgopen(path, "rb")) == NULL ) {
- fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", path);
+ if ( (f = fgopen(mpath, "rb")) == NULL ) {
+ fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", mpath);
}
}
}
// printf("texture name = %s\n", line_ptr);
sscanf(line_ptr, "%s\n", m.texture_name);
+
+ // create the texture object and bind it
+ xglGenTextures(1, &m.texture_id);
+ xglBindTexture(GL_TEXTURE_2D, m.texture_id);
+
+ // set the texture parameters for this texture
+ xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
+ xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
+ xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR /* GL_LINEAR_MIPMAP_LINEAR */ ) ;
+ xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
+ xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
+
+ /* load in the texture data */
+ tpath[0] = '\0';
+ strcat(tpath, o->fg_root);
+ strcat(tpath, "/Textures/");
+ strcat(tpath, m.texture_name);
+ strcat(tpath, ".rgb");
+
+ // Try uncompressed
+ if ( (texbuf = read_rgb_texture(tpath, &width, &height)) == NULL ) {
+ // Try compressed
+ strcpy(fg_tpath, tpath);
+ strcat(fg_tpath, ".gz");
+ if ( (texbuf = read_rgb_texture(fg_tpath, &width, &height))
+ == NULL ) {
+ fgPrintf( FG_GENERAL, FG_EXIT,
+ "Error in loading texture %s\n", tpath );
+ return(0);
+ }
+ }
+
+ xglTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, texbuf);
+
} else if ( strncmp(line_ptr, "ambient", 7) == 0 ) {
line_ptr += 7;
while ( ( (line_ptr[0] == ' ') || (line_ptr[0] == '\t') ||
// $Log$
+// Revision 1.5 1998/06/17 21:36:39 curt
+// Load and manage multiple textures defined in the Materials library.
+// Boost max material fagments for each material property to 800.
+// Multiple texture support when rendering.
+//
// Revision 1.4 1998/06/12 00:58:04 curt
// Build only static libraries.
// Declare memmove/memset for Sloaris.
extern "C" void *memset(void *, int, size_t);
#endif
-#include <map> // STL
#include <string> // Standard C++ library
+#include <map> // STL
#include <Debug/fg_debug.h>
#include <Include/fg_constants.h>
fgFile f;
int in_fragment, in_faces, ncount, vncount, n1, n2, n3, n4;
int last1, last2, odd;
- int i;
o = ¤t_options;
// $Log$
+// Revision 1.14 1998/06/17 21:36:40 curt
+// Load and manage multiple textures defined in the Materials library.
+// Boost max material fagments for each material property to 800.
+// Multiple texture support when rendering.
+//
// Revision 1.13 1998/06/12 00:58:05 curt
// Build only static libraries.
// Declare memmove/memset for Sloaris.
#include <Debug/fg_debug.h>
#include <Main/options.hxx>
-#include <Scenery/obj.hxx>
-#include <Scenery/scenery.hxx>
-#include <Scenery/texload.h>
+
+#include "obj.hxx"
+#include "scenery.hxx"
+// #include "texload.h"
/* Temporary hack until we get a better texture management system running */
/* Initialize the Scenery Management system */
int fgSceneryInit( void ) {
fgOPTIONS *o;
- char path[1024], fgpath[1024];
- GLubyte *texbuf;
- int width, height;
+ // char path[1024], fgpath[1024];
+ // GLubyte *texbuf;
+ // int width, height;
o = ¤t_options;
fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n");
+#ifdef 0
/* set the default terrain detail level */
// scenery.terrain_skip = 6;
xglTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, texbuf);
-
+#endif // 0
return(1);
}
* build the proper structures. */
void fgSceneryUpdate(double lon, double lat, double elev) {
fgOPTIONS *o;
- double max_radius;
+ // double max_radius;
char path[1024];
o = ¤t_options;
/* $Log$
-/* Revision 1.4 1998/05/13 18:26:40 curt
-/* Root path info moved to fgOPTIONS.
+/* Revision 1.5 1998/06/17 21:36:41 curt
+/* Load and manage multiple textures defined in the Materials library.
+/* Boost max material fagments for each material property to 800.
+/* Multiple texture support when rendering.
/*
+ * Revision 1.4 1998/05/13 18:26:40 curt
+ * Root path info moved to fgOPTIONS.
+ *
* Revision 1.3 1998/05/07 23:15:20 curt
* Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
* Added support for --tile-radius=n option.