Skip to content

Instantly share code, notes, and snippets.

@tgfrerer
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgfrerer/dae32894b8ef785e6786 to your computer and use it in GitHub Desktop.
Save tgfrerer/dae32894b8ef785e6786 to your computer and use it in GitHub Desktop.
ofTexture::mipmap test project - press key to toggle mipmaps on/off
#include "ofMain.h"
class ofApp : public ofBaseApp{
ofCamera mCam1;
ofTexture mTex1;
public:
void setup() {
//mTex1.enableMipmap(); ///< auto-generate mipmap whenever ofTexture updates it's image data.
ofDisableArbTex();
ofLoadImage(mTex1,"grid.png");
// mTex1.generateMipmap(); ///< alternative: generate mipmap at point of call, and select mipmap based min filter manually:
// mTex1.setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST); ///< activate mipmap filtering once texture has been loaded
ofEnableArbTex();
mCam1.setupPerspective();
};
void draw() {
ofBackground(ofColor::black);
mCam1.begin();
ofPushMatrix();
ofTranslate(0, 0, -500);
ofRotate(60,1,0,0);
mTex1.draw(0, 0);
ofPopMatrix();
mCam1.end();
};
void keyReleased(int key){
static bool toggle = false;
mTex1.setTextureMinMagFilter( (toggle^=true) ? GL_LINEAR : GL_LINEAR_MIPMAP_LINEAR , GL_LINEAR);
};
};
//========================================================================
int main( ){
// ofSetCurrentRenderer(ofGLProgrammableRenderer::TYPE);
// ofSetOpenGLVersion(4, 1);
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment