How do I import textures? Is there any easy way, does somebody have any kind of xtra libraries or something??? And as a subquestion, whats an arc fillet, and how do I use one???
How do I import textures? Is there any easy way, does somebody have any kind of xtra libraries or something??? And as a subquestion, whats an arc fillet, and how do I use one???
CyBBe
Import textures, just load a bitmap ... it's no harder than that.
Exactly how do I import a bitmap, I asked for an easy way, can U give me some code examples???
CyBBe
hi,
check this out...
www.codeguru.com
nehe.gamedev.net
Someone else, som xtra libraries???
CyBBe
Here you go.. This should tide you over for awhile.Originally posted by CyBBe:
Someone else, som xtra libraries???
///////////////////////////////////////////////////////////////////////////////
// This function loads a 24-bit color (RGB)Windows bitmap and sets it as the current
// texture. The bitmap must be 24-bit color, and the dimensions must be powers
// of 2 (no additional checks are performed).
///////////////////////////////////////////////////////////////////////////////
loadBitmap(char* filename)
{
FILE* bmpfile;
BITMAPFILEHEADER bmfileheader;
BITMAPINFOHEADER bminfoheader;
RGBTRIPLE rgb;
int nTextureWidth;
int nTextureHeight;
int i,j,texpos = 0;
BYTE *pBitmapData;
bmpfile = fopen(filename, "rb");
if (!bmpfile)
exit(1);
fread(&bmfileheader, sizeof(BITMAPFILEHEADER), 1, bmpfile);
fread(&bminfoheader, sizeof(BITMAPINFOHEADER), 1, bmpfile);
nTextureWidth = bminfoheader.biWidth;
nTextureHeight = bminfoheader.biHeight;
pBitmapData = (GLubyte*)malloc(nTextureWidth * nTextureHeight *3);
// read color
for (i = 0; i < nTextureWidth; i++)
{
for(j = nTextureHeight - 1; j>=0 ; j--) //start with the height because the first data you read in the color array of the bitmap
{ // is coord (1.0).
fread(&rgb, sizeof(RGBTRIPLE),1,bmpfile);
pBitmapData[texpos] = rgb.rgbtRed ;
pBitmapData[texpos+1] = rgb.rgbtGreen;
pBitmapData[texpos+2] = rgb.rgbtBlue;
}
}
fclose(bmpfile);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nTextureWidth, nTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pBitmapData);
return TRUE;
}
[This message has been edited by dans (edited 03-27-2000).]