Hello forum,
I am trying to draw a simple plane primitive but having a trouble to get the same effect in OF as i got with raw OpenGL.
Here goes the snapshot of the raw OpenGL plane:
Now i am using the ofPlanePrimitive to generate the same scenario with OF. Here goes the snapshot of it:
As you can see that the OF plane is not as wide as the former one. Even the mipmap seems not to be working properly.
Lets go down to the code to show how i am trying to create the plane using OF.
-
Inside the setup() function i am initializing the mipmap texture and generate the size of the plane primitive.
loadMipMapTexture( &floorTexture, “floortile.ppm”, 16 );
//initialize the plane primitive
planePrimitive.set(ofGetWidth()4.5, ofGetHeight()4.5,100,100);
//planePrimitive.setPosition(ofGetWidth().9, ofGetHeight().9, 0);
planePrimitive.mapTexCoordsFromTexture( floorTexture );
And inside the draw function i am doing the following:
void ofApp::draw()
{
camera.begin();
floorTexture.bind();
planePrimitive.draw();
floorTexture.unbind();
camera.end();
}
What am i missing in the process ?
By the way here goes the snippet for the mipmap generation as well:
void ofApp::loadMipMapTexture(ofTexture *inTex,string inPath, float inAnisotropy)
{
ofPixels pix;
bool loaded = ofLoadImage(*inTex, inPath );
if(loaded)
{
//bind the texture object
inTex->bind();
int textureTarget = inTex->getTextureData().textureTarget;
glTexParameteri( textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri( textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
glGenerateMipmap(textureTarget);
// 1 means it does nothing //
if( inAnisotropy >= 1 )
{
glTexParameterf( textureTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, (GLfloat)inAnisotropy);
}
inTex->unbind();
}
else
{
std::cerr << "Mip map texture generation is not successful." << std::endl;
exit();
}
}
Any hint folks ?
Thanks