Here is some 'clearer' source for something different, I still have the same problem NO texturing so I'm baffled. I've had texturing working on some other code a year or two back but lately this is my 'white polygon' in a snow storm days (so I changed the background to grey to see them
).
I'm fairly sure I'm generating the texture correctly NO alpha channel is used on this texture also.
Any ideas? I know I'm doing something wrong (heh) just not sure which thing I'm doing is erroneous. It's that thing thing (makes sense to me).
Polygon Rendering code:
FF8_FACE_OGL() function
Texture Generation code
OGL Render frame code
OGL initialization
First image is the Texture I'm pasting
Then a rotated image of what it looks like textured with my lovely code.
Screen Shots Thread for this post
I'm fairly sure I'm generating the texture correctly NO alpha channel is used on this texture also.
Any ideas? I know I'm doing something wrong (heh) just not sure which thing I'm doing is erroneous. It's that thing thing (makes sense to me).
Polygon Rendering code:
Code:
void TMain::FF8_BMDL_OGL(void)
{
PSX_FF8_MDL_HDR *DIR;
PSX_FF8_MDL_HDR2 *MODEL;
PSX_FF8_FACE *Faces;
PSX_FF7_VERTEX *Verts;
PSX_FF8_SKJ *Skel;
int Index;
DIR = (PSX_FF8_MDL_HDR *)DEC_BAT;
glBindTexture(
GL_TEXTURE_2D,
Textures[0].texID
);
MODEL =(PSX_FF8_MDL_HDR2 *) (DEC_BAT +
DIR->REFS[TextureCount + 1]);
Skel = (PSX_FF8_SKJ *)&MODEL[1];
Verts = (PSX_FF7_VERTEX *)&Skel[MODEL->SKJ];
Faces = (PSX_FF8_FACE *)&Verts[MODEL->Vert];
for(Index = 0; Index < MODEL->Face; Index++)
{
FF8_FACE_OGL(Faces[Index], Verts);
}
}
//---------------------------------------------------------------------------
FF8_FACE_OGL() function
Code:
void TMain::FF8_FACE_OGL(PSX_FF8_FACE & Face, PSX_FF7_VERTEX * Verts)
{
if(Face.Type & 0x08000000)
{ // Quad
glBegin(GL_QUADS);
glTexCoord2f(
Face.UV[0].U/128.0,
Face.UV[0].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[0]]);
glTexCoord2f(
Face.UV[1].U/128.0,
Face.UV[1].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[1]]);
glTexCoord2f(
Face.UV[3].U/128.0,
Face.UV[3].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[3]]);
glTexCoord2f(
Face.UV[2].U/128.0,
Face.UV[2].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[2]]);
glEnd();
}
else
{ // Triangle
glBegin(GL_TRIANGLES);
glTexCoord2f(
Face.UV[0].U/128.0,
Face.UV[0].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[0]]);
glTexCoord2f(
Face.UV[1].U/128.0,
Face.UV[1].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[1]]);
glTexCoord2f(
Face.UV[2].U/128.0,
Face.UV[2].V/128.0
);
FF7_Vert_2_OGL(&Verts[Face.Edge[2]]);
glEnd();
}
}
Texture Generation code
Code:
typedef struct
{
tim_8bpp INFO;
CLUT_8bpp CLUT;
base_tim_img IMAGEDAT;
}
FF8_TIM_TEX;
void TMain::FF8_BMDL_OGL_TEX(void)
{
Graphics::TBitmap *BM;
PSX_FF8_MDL_HDR *DIR;
FF8_TIM_TEX *TEX[4];
int TexCount, Index, Start;
int X, Y;
TColor Color;
UINT8 *Pix, *Store;
DIR = (PSX_FF8_MDL_HDR *)DEC_BAT;
TexCount = 0;
while(DIR->REFS[TexCount] != 0xFFFFFFFF)
{
TEX[TexCount] =(FF8_TIM_TEX *)(DEC_BAT +DIR->REFS[TexCount]);
TexCount++;
}
// FF8 bitmaps are opaque no alpha needed
// so they are R8G8B8 raw bit maps when decoded
*TEX[0];
BM = Image1->Picture->Bitmap;
BM->Width = TEX[0]->IMAGEDAT.Pitch * 2;
BM->Height= 0;
TextureCount = TexCount;
for (Index = 0; Index < TexCount; Index++)
{
Start = BM->Height;
BM->Height += TEX[Index]->IMAGEDAT.Height;
Pix = (UINT8 *)(TEX[Index] + 1);
if (Textures[Index].ImageData != NULL)
delete Textures[Index].ImageData;
Store = new UINT8[BM->Width * BM->Height * 3];
Textures[Index].ImageData = Store;
Textures[Index].Width = BM->Width;
Textures[Index].Height = BM->Height;
for (Y = Start; Y < BM->Height; Y++)
{
for (X= 0; X < BM->Width; X++)
{
Color = BGRTO24BGR(TEX[Index]->CLUT[*Pix++]);
BM->Canvas->Pixels[X][Y] = Color;
*Store++ = GetRValue(Color);
*Store++ = GetGValue(Color);
*Store++ = GetBValue(Color);
}
}
glGenTextures(1, &Textures[Index].texID);
glBindTexture(
GL_TEXTURE_2D,
Textures[Index].texID
);
gluBuild2DMipmaps(
GL_TEXTURE_2D,
3,
Textures[Index].Width,
Textures[Index].Height,
GL_RGB,
GL_UNSIGNED_BYTE,
Textures[Index].ImageData
);
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,
GL_LINEAR_MIPMAP_NEAREST
);
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST
);
}
}
OGL Render frame code
Code:
void __fastcall TMain::OGL_MODELPaint(TObject *Sender)
{
if (MDL_View)
{
glPushMatrix();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslated(0.0, 0.0, ZAxis);
glRotatef(RotX, 1.0, 0.0, 0.0);
glRotatef(RotY, 0.0, 1.0, 0.0);
glRotatef(RotZ, 0.0, 0.0, 1.0);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
if (HEX_OGL_CB->Checked)
{
switch(DEC_BAT_TYPE)
{
case FF7_BAT_DAT:
FF7_BMDL_OGL();
break;
case FF8_BAT_DAT:
FF8_BMDL_OGL();
break;
case FF9_BAT_DAT:
FF9_BMDL_OGL();
break;
}
}
glPopMatrix();
glFlush();
}
}
OGL initialization
Code:
void __fastcall TMain::OGL_MODELInit(TObject *Sender)
{
glShadeModel(GL_SMOOTH);
glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);// GL_DECAL);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glViewport(0,0,(GLsizei)OGL_MODEL->Width,(GLsizei)OGL_MODEL->Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if ( OGL_MODEL->Height==0)
gluPerspective(
45,
(GLdouble)OGL_MODEL->Width,
1.0,
2000.0);
else
gluPerspective(
45,
(GLdouble)OGL_MODEL->Width/
(GLdouble)OGL_MODEL->Height,
1.0,
2000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
}
Then a rotated image of what it looks like textured with my lovely code.
Screen Shots Thread for this post
Last edited: