quote:Original post by DerAnged
before you call the textured object you have to set the color to white glColor3f( 1, 1, 1);
Well that just sort of makes it white
I''ve updated the texture generating part etc. Somehow I think the texture isn''t being MADE or isn''t being applied.
Now comes the more interesting question from me, what should I get when I use glGenTextures() in the second parameter?
I''m just curious where I am going wrong.
Initialization
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);}
Render ''frame''
//---------------------------------------------------------------------------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) { BMDL_OGL(); } glPopMatrix(); glFlush(); }}
You have already seen what I''m applying the texture too
Construction of Texture
//---------------------------------------------------------------------------bool TMain::TIM4BPP( Graphics::TBitmap *BM, GLubyte *Img, UINT8 *Data, UINT16 X1, UINT16 Y1, UINT16 X2, UINT16 Y2 ){ tim_4bpp *TIM; int y, x, Cnt, Idx; UINT8 *PIX; int PIX1, PIX2, PIX3, PIX4; CLUT_4bpp *PAL; Pallete *PAL2; base_tim_img *IMG; GLubyte *Line; Graphics::TBitmap *BM2; TColor Color; TIM = (tim_4bpp *)Data; if((TIM->INFO.Magic != 16) || (TIM->INFO.Type != 8)) { return false; } Cnt = TIM->CLUT_CNT; BM2 = SP_PAL->Picture->Bitmap; PalCount = TIM->CLUT_CNT; BM2->Width = 16; BM2->Height = PalCount; SP_PAL->Height = 16 *PalCount; for (Idx = 0; Idx < ToolBar1->ButtonCount; Idx++) { ToolBar1->Buttons[Idx]->Enabled = false; } Idx = 0; PAL = (CLUT_4bpp *)&TIM[1]; while (Cnt > 0) { Cnt--; PAL2 = Pallets[Idx]; PAL2->Size = 16; for (x = 0; x < 16; x++) { PAL2->Pal[x] = BGRTO24BGR(PAL[Idx][x]); BM2->Canvas->Pixels[x][Idx] = PAL2->Pal[x]; } if (Idx < 16) { ToolBar1->Buttons[Idx]->Enabled = true; } Idx++; } PAL2 = Pallets[CPal]; IMG = (base_tim_img *)&PAL[TIM->CLUT_CNT]; BM->Width = IMG->Pitch * 4; BM->Height = IMG->Height; for (y = Y1; y < Y2; y++) { PIX = (UINT8 *)&IMG[1] + ((IMG->Pitch*y) << 1); Line = Img + (y * BM->Width + X1) * 4; for (x = X1>>2; x < X2>>2; x++) { Cnt = x << 1; PIX1 = PIX[Cnt]; PIX2 = (PIX1 >>4) & 0xF; PIX1 &= 0xF; PIX3 = PIX[Cnt + 1]; PIX4 = (PIX3 & 0xF0) >> 4; PIX3 &= 0xF; Cnt <<=1; Color = PAL2->Pal[PIX1]; BM->Canvas->Pixels[Cnt + 0][y] = Color; TColor2OGL(Line, Color, (PIX1 > 0)); Color = PAL2->Pal[PIX2]; BM->Canvas->Pixels[Cnt + 1][y] = Color; TColor2OGL(Line, Color, (PIX2 > 0)); Color = PAL2->Pal[PIX3]; BM->Canvas->Pixels[Cnt + 2][y] = Color; TColor2OGL(Line, Color, (PIX3 > 0)); Color = PAL2->Pal[PIX4]; BM->Canvas->Pixels[Cnt + 3][y] = Color; TColor2OGL(Line, Color, (PIX4 > 0)); } } //delete PIX; return true;}//---------------------------------------------------------------------------void TMain::TColor2OGL(GLubyte *Dest, TColor Color, bool Opaque){ Dest[0] = GetRValue(Color); Dest[1] = GetGValue(Color); Dest[2] = GetBValue(Color); Dest[3] = (Opaque)?0xFF:0x00;}//---------------------------------------------------------------------------
It''s complicated because the original data is paletted and I had to convert from that to an RGBA texture .
Is it because I have colored vertex triangles and then try to paste a DECAL texture in the next set of polygons?
Confused and a bit frustrated here
Ith
I disavow having any knowledge other than what I might claim to know in the future but not now. Err wait...