1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| void loadtxtpng(GLuint &txt,int data,char *filename)
{
if (txt==0)
{
WORD resx,resy;
void *p= loaddatapng(data,filename,&resx,&resy,1);
if (p!=NULL)
{
GLenum err;
GLuint ntxt;
x_glBindTexture(GL_TEXTURE_2D, 0);
err=glGetError();
// ntxt=0;
x_glGenTextures(1,&ntxt);
err=glGetError();
x_glBindTexture(GL_TEXTURE_2D,ntxt);
err=glGetError();
x_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST ); //NEAREST
err=glGetError();
x_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST );
err=glGetError();
x_glTexImage2D(GL_TEXTURE_2D, 0, 4,resx,resy, 0, GL_RGBA, GL_UNSIGNED_BYTE,p);
err=glGetError();
err=glGetError();
x_glBindTexture(GL_TEXTURE_2D, 0);
err=glGetError();
txt=ntxt;
freepicture(p);
}
}
} |
Partager