I need help :(.
I’m trying to draw multiple textures, align them together & draw a decent view. The textures themselves are like rectangle prism (ie 3D like);
With different fixed widths, but with variable heights. The edges of the prism need to align to others along pink left & pink bottom/right face.
*Following is extract of what I’m currently using following;
glClearColor(1, 1, 1, 1);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
LoadTextures()
{
glBindTexture(GL_TEXTURE_2D, pGLUINT[iItem]);
glTexImage2D(GL_TEXTURE_2D, 0, 4, Imgwidth, Imgheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, Imgrgba);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
}
void DrawScene()
{
CRect rWnd;
GetClientRect(&rWnd);
glViewport(0,0,rWnd.Width(),rWnd.Height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-20, 80, -20, 60, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-14.50, 14.5f, 0.0f);
DrawPrisms();
}
void DrawPrisms()
{
std::list<Textures>::iterator itText = m_Textures.begin();
for (; itText != m_Textures.end(); ++itText)
{
//subsequent textures need to align with previous one.
glPushMatrix();
const float Prism = itText->mSize;
float fL = itText->LocX;
float fR = fL + Prism;
float fB = itText->LocY;
float fT = fB + Prism;
fT = fT * -1;
fB = fB * -1;
glBindTexture(GL_TEXTURE_2D, itText->mNum);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);//TL
glVertex3f(fL, fT, 0);
glTexCoord2f(0, 1);//BL
glVertex3f(fL, fB, 0);
glTexCoord2f(1, 1);//BR
glVertex3f(fR, fB, 0);
glTexCoord2f(1, 0);//TR
glVertex3f(fR, fT, 0);
glEnd();
glPopMatrix();
}
}
Main problems I’m having;
-aligning textures together properly.
-texture overlapping.
Would appreciate any help :).
Thank you.
ps I understand this is depreciated code.