source for my build surface function:
hxSurface *hxBuild(int w, int h)
{
int tID;
hxSurface *workSurface;
workSurface = new hxSurface;
workSurface->w = w;
workSurface->h = h;
workSurface->pixeldata = (unsigned char*)malloc((sizeof(unsigned char)*4)*(w*h));
tID = hxiFindOpenSlot();
workSurface->texID = tID;
hxiTakenList[tID] = true;
return workSurface;
}
and here are the rest of the functions
void hxBeginPixWrite(hxSurface *target)
{
hxiWs = target;
return;
}
void hxWritePix(unsigned int x, unsigned int y, hxColorSet color)
{
unsigned char *pd;
unsigned int offset;
pd = hxiWs->pixeldata;
offset = (y*hxiWs->w)+(x*4);
pd[offset+0] = color.r;
pd[offset+1] = color.g;
pd[offset+2] = color.b;
pd[offset+3] = color.a;
return;
}
void hxEndPixWrite(void)
{
glBindTexture(GL_TEXTURE_2D, hxiTexList[hxiWs->texID]);
glTexImage2D(GL_TEXTURE_2D, 0, 4, hxiWs->w, hxiWs->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, hxiWs->pixeldata);
hxiWs = NULL; //we are done with this...
}
void hxBlitSurface(hxSurface *source, hxBlitRect sRect, hxBlitRect dRect, hxColorSet blendColor)
{
glBindTexture(GL_TEXTURE_2D, hxiTexList[source->texID]);
glColor4ub(blendColor.r, blendColor.g, blendColor.b, blendColor.a);
glBegin(GL_QUADS);
glTexCoord2i(sRect.x, sRect.y); glVertex2i(dRect.x, dRect.y);
glTexCoord2i(sRect.x + sRect.w, sRect.y); glVertex2i(dRect.x + dRect.w, dRect.y);
glTexCoord2i(sRect.x + sRect.w, sRect.y + sRect.h); glVertex2i(dRect.x + dRect.w, dRect.y + dRect.h);
glTexCoord2i(sRect.x, sRect.y + sRect.h); glVertex2i(dRect.x, dRect.y + dRect.h);
glEnd();
return;
}
hxiWs is a global copy of the current surface.
My problem is that essentially, all I am getting is the rectangle. I don't think I am getting any memory leakage. I think the problem might lie in my WritePixel Function. I don't know if I am setting the offset up correctly or not.
[Edited by - PnP Bios on November 24, 2004 11:57:07 PM]