-// Reinitialize the panel.
-void FGPanel::ReInit( int x, int y, int finx, int finy){
- GLint buffer;
- float Xzoom, Yzoom;
-
- xglDisable(GL_DEPTH_TEST);
-
- Xzoom = (float)((float)(current_view.get_winWidth())/1024);
- Yzoom = (float)((float)(current_view.get_winHeight())/768);
-
- // save the current buffer state
- xglGetIntegerv(GL_DRAW_BUFFER, &buffer);
-
- // and enable both buffers for writing
- xglDrawBuffer(GL_FRONT_AND_BACK);
-
- xglMatrixMode(GL_PROJECTION);
- xglPushMatrix();
- xglLoadIdentity();
- xglViewport(0, 0, 640, 480);
- xglOrtho(0, 640, 0, 480, 1, -1);
- xglMatrixMode(GL_MODELVIEW);
- xglPushMatrix();
- xglLoadIdentity();
- xglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- xglPixelZoom(Xzoom, Yzoom);
- xglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024);
- xglPixelStorei(GL_UNPACK_SKIP_PIXELS, x);
- xglPixelStorei(GL_UNPACK_SKIP_ROWS, y);
- xglRasterPos2i(x, y);
- xglPixelZoom(Xzoom, Yzoom);
- xglDrawPixels(finx - x, finy - y, GL_RGB, GL_UNSIGNED_BYTE,
- (GLvoid *)(background));
-
- // restore original buffer state
- xglDrawBuffer( (GLenum)buffer );
- xglEnable(GL_DEPTH_TEST);
-}
-
-
-// Update the panel.
-void FGPanel::Update ( void ) {
- xglMatrixMode(GL_PROJECTION);
- xglPushMatrix();
- xglLoadIdentity();
- xglOrtho(0, 640, 0, 480, 10, -10);
- xglMatrixMode(GL_MODELVIEW);
- xglPushMatrix();
- xglLoadIdentity();
- xglDisable(GL_DEPTH_TEST);
- xglEnable(GL_LIGHTING);
- xglEnable(GL_TEXTURE_2D);
- xglDisable(GL_BLEND);
-
- xglMatrixMode(GL_MODELVIEW);
- xglPopMatrix();
- xglPushMatrix();
-
- xglDisable(GL_LIGHTING);
- airspeedIndicator->Render();
- verticalSpeedIndicator->Render();
- altimeter->Render();
- altimeter2->Render();
-
- xglPopMatrix();
- xglPushMatrix();
-
- turnCoordinator->Render();
- rpmIndicator->Render();
-
- xglEnable(GL_LIGHTING);
-
- horizonIndicator->Render();
-
-
- xglDisable(GL_TEXTURE_2D);
- xglPopMatrix();
- xglEnable(GL_DEPTH_TEST);
- xglEnable(GL_LIGHTING);
- xglDisable(GL_TEXTURE_2D);
- xglDisable(GL_BLEND);
- xglMatrixMode(GL_PROJECTION);
- xglPopMatrix();
- xglMatrixMode(GL_MODELVIEW);
- xglPopMatrix();
-}
-
-
-// fgEraseArea - 'Erases' a drawn Polygon by overlaying it with a textured
-// area. Shall be a method of a panel class once.
-// This should migrate into FGPanel somehow.
-void fgEraseArea(GLfloat *array, int NumVerti, GLfloat texXPos, GLfloat texYPos, GLfloat XPos, GLfloat YPos, int Texid, float ScaleFactor){
- int i, j;
- int n;
- float a;
- float ififth;
-
- xglEnable(GL_TEXTURE_2D);
- xglEnable(GL_TEXTURE_GEN_S);
- xglEnable(GL_TEXTURE_GEN_T);
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
- xglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- xglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- xglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- xglMatrixMode(GL_TEXTURE);
- xglLoadIdentity();
-
-#ifdef GL_VERSION_1_1
- xglBindTexture(GL_TEXTURE_2D, FGPanel::OurPanel->panel_tex_id[Texid]);
-#elif GL_EXT_texture_object
- xglBindTextureEXT(GL_TEXTURE_2D, FGPanel::OurPanel->panel_tex_id[Texid]);
-#else
-# error port me
-#endif
-
- xglMatrixMode(GL_TEXTURE);
- xglLoadIdentity();
- xglTranslatef(-((float)((XPos/0.625)/256)), -((float)((YPos/0.625)/256)), 0.0);
- xglTranslatef(texXPos/256 , texYPos/256, 0.0);
- xglScalef(0.00625, 0.00625, 1.0);
-
- xglBegin(GL_POLYGON);
- for(n=0;n<NumVerti;n += 2){
- xglVertex2f(array[n] * ScaleFactor, array[n + 1] * ScaleFactor);
- }
- xglEnd();
-
- xglLoadIdentity();
- xglMatrixMode(GL_MODELVIEW);
- xglPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- xglPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- xglDisable(GL_TEXTURE_2D);
- xglDisable(GL_TEXTURE_GEN_S);
- xglDisable(GL_TEXTURE_GEN_T);
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGCropped Texture.
+////////////////////////////////////////////////////////////////////////
+
+
+FGCroppedTexture::FGCroppedTexture ()
+ : _path(""), _texture(0),
+ _minX(0.0), _minY(0.0), _maxX(1.0), _maxY(1.0)
+{
+}
+
+
+FGCroppedTexture::FGCroppedTexture (const string &path,
+ float minX, float minY,
+ float maxX, float maxY)
+ : _path(path), _texture(0),
+ _minX(minX), _minY(minY), _maxX(maxX), _maxY(maxY)
+{
+}
+
+
+FGCroppedTexture::~FGCroppedTexture ()
+{
+}
+
+
+ssgTexture *
+FGCroppedTexture::getTexture ()
+{
+ if (_texture == 0) {
+ _texture = FGTextureManager::createTexture(_path);
+ }
+ return _texture;