Exemplo n.º 1
0
void Material::loadMipMapTexture(string inPath, float inAnisotropy ) {
    ofPixels pix;
    ofLoadImage(pix, inPath);

    _tex.allocate( pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix) );

    ofTextureData& texData = _tex.texData;

    if (texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB){
        texData.tex_t = pix.getWidth();
        texData.tex_u = pix.getHeight();
    } else {
        texData.tex_t = (float)(pix.getWidth()) / (float)texData.tex_w;
        texData.tex_u = (float)(pix.getHeight()) / (float)texData.tex_h;
    }

    ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),pix.getNumChannels());

    glBindTexture( texData.textureTarget, texData.textureID);
    glTexImage2D( texData.textureTarget, 0, texData.glTypeInternal, pix.getWidth(), pix.getHeight(), 0, ofGetGlFormat(pix), ofGetGlType(pix), pix.getPixels());
    glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(texData.textureTarget);
    glGenerateMipmap(texData.textureTarget);
    glTexParameteri( texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri( texData.textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

    // 1 means it does nothing
    if( inAnisotropy >= 1 ) {
        glTexParameterf( texData.textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, (GLfloat)inAnisotropy);
    }

    glDisable( texData.textureTarget );
}
Exemplo n.º 2
0
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix, int glFormat){
	ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}
Exemplo n.º 3
0
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix){
	ofSetPixelStorei(pix.getBytesStride());
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
}
Exemplo n.º 4
0
//----------------------------------------------------------
void ofTexture::loadData(const float * data, int w, int h, int glFormat){
	ofSetPixelStorei(w,4,ofGetNumChannelsFromGLFormat(glFormat));
	loadData(data, w, h, glFormat, GL_FLOAT);
}
Exemplo n.º 5
0
//----------------------------------------------------------
void ofTexture::loadData(const unsigned short * data, int w, int h, int glFormat){
	ofSetPixelStorei(w,2,ofGetNumChannelsFromGLFormat(glFormat));
	loadData(data, w, h, glFormat, GL_UNSIGNED_SHORT);
}
Exemplo n.º 6
0
void ofSetPixelStorei(int w, int bpc, int numChannels){
	int stride = w * numChannels * bpc;
	ofSetPixelStorei(stride);
}
Exemplo n.º 7
0
//----------------------------------------------------------
void ofTexture::loadData(const ofShortPixels & pix){
	ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),pix.getNumChannels());
	loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
}