Hi
can u find out why I cannot see the image? I’m stuck…
Many thanks
Michael----------
/// Texture stuff
#define MAX_TEXTURES 4
#define PANEL_FILENAME “Images/pnl.png”
#define PANEL_TEXTURE 0
…
int LoadGLTexture(char *pFileName, int TextureId)
{
int Stat = FALSE;
char TextureFileName[255];
/// Need to get the actual texture path
/// and append the filename to it.
strcpy(TextureFileName, gPluginDataFile);
strcat(TextureFileName, pFileName);
sprintf(debugStr,"### - LoadGLTexture() - loading: %s\n", TextureFileName);
XPLMDebugString(debugStr);
SDL_Surface *image; // This surface will tell us the details of the image
image = IMG_Load(TextureFileName);
if (image) {
//the XPLM functions are equivalent to OpenGL
XPLMGenerateTextureNumbers(&gTexture[TextureId], 1);
XPLMBindTexture2d(gTexture[TextureId], 0);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
Stat = TRUE;
} else {
XPLMDebugString("### LoadGLTexture(): Error loading texture!\n");
Stat = FALSE;
}
if ( image ) {
SDL_FreeSurface( image );
}
return Stat;
}
/// Draws the textures that make up the gauge
int DrawGLScene(float x1, float y1)
{
glPushMatrix();
XPLMBindTexture2d(gTexture[PANEL_TEXTURE], 0);
glBegin(GL_QUADS);
glTexCoord2f(1, 0.0f); glVertex2f(PanelRight, PanelBottom); // Bottom Right
Of The Texture and Quad
glTexCoord2f(0, 0.0f); glVertex2f(PanelLeft, PanelBottom); // Bottom Left
Of The Texture and Quad
glTexCoord2f(0, 1.0f); glVertex2f(PanelLeft, PanelTop); // Top Left Of The
Texture and Quad
glTexCoord2f(1, 1.0f); glVertex2f(PanelRight, PanelTop); // Top Right Of The
Texture and Quad
glEnd();
glPopMatrix();