//
// Written by Harald JOHNSEN, started May 2005.
//
-// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
+// Copyright (C) 2005 Harald JOHNSEN
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <plib/ssg.h>
#include <simgear/screen/extensions.hxx>
#include <simgear/screen/RenderTexture.h>
void FGODGauge::endCapture(GLuint texID) {
glBindTexture(GL_TEXTURE_2D, texID);
+ // don't use mimaps if we don't update them
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureWH, textureWH);
if(rtAvailable)
rt->EndCapture();
else
set3D();
+ glBindTexture(GL_TEXTURE_2D, 0);
}
void FGODGauge::setSize(int viewSize) {
/**
* Locate a texture SSG node in a branch.
*/
-static ssgTexture *
+static const char *strip_path(const char *name) {
+ /* Remove all leading path information. */
+ const char* seps = "\\/" ;
+ const char* fn = & name [ strlen ( name ) - 1 ] ;
+ for ( ; fn != name && strchr(seps,*fn) == NULL ; fn-- )
+ /* Search back for a seperator */ ;
+ if ( strchr(seps,*fn) != NULL )
+ fn++ ;
+ return fn ;
+}
+
+static ssgSimpleState *
find_texture_node (ssgEntity * node, const char * name)
{
- if( node->isA( ssgTypeTexture() ) ) {
- ssgTexture *tex = (ssgTexture *) node;
- char * texture_name = tex->getFilename();
- if (texture_name != 0 && !strcmp(name, texture_name))
- return tex;
+ if( node->isAKindOf( ssgTypeLeaf() ) ) {
+ ssgLeaf *leaf = (ssgLeaf *) node;
+ ssgSimpleState *state = (ssgSimpleState *) leaf->getState();
+ if( state ) {
+ ssgTexture *tex = state->getTexture();
+ if( tex ) {
+ const char * texture_name = tex->getFilename();
+ if (texture_name) {
+ texture_name = strip_path( texture_name );
+ if ( !strcmp(name, texture_name) )
+ return state;
+ }
+ }
+ }
}
- else if (node->isAKindOf(ssgTypeBranch())) {
+ else {
int nKids = node->getNumKids();
for (int i = 0; i < nKids; i++) {
- ssgTexture * result =
+ ssgSimpleState * result =
find_texture_node(((ssgBranch*)node)->getKid(i), name);
if (result != 0)
return result;
void FGODGauge::set_texture(const char * name, GLuint new_texture) {
ssgEntity * root = globals->get_scenery()->get_aircraft_branch();
- ssgTexture * node = find_texture_node( root, name );
+ name = strip_path( name );
+ ssgSimpleState * node = find_texture_node( root, name );
if( node )
- node->setHandle( new_texture );
+ node->setTexture( new_texture );
}
void FGODGauge::set2D() {