Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Applying a texture to a rectangle

$
0
0

@kemal wrote:

I’m trying to apply a jpg texture to a rectangle.
This is my main code:

    ofiOSWindowSettings settings;
    settings.enableRetina = true; // enables retina resolution if the device supports it.
    settings.enableDepth = true; // enables depth buffer for 3d drawing.
    settings.enableAntiAliasing = true; // enables anti-aliasing which smooths out graphics on the screen.
    settings.numOfAntiAliasingSamples = 2; // number of samples used for anti-aliasing.
    settings.enableHardwareOrientation = false; // enables native view orientation.
    settings.enableHardwareOrientationAnimation = false; // enables native orientation changes to be animated.
    settings.glesVersion = OFXIOS_RENDERER_ES2; // type of renderer to use, ES1, ES2, ES3
    settings.windowControllerType = ofxiOSWindowControllerType::GL_KIT; // Window Controller Type
    settings.colorType = ofxiOSRendererColorFormat::RGBA8888; // color format used default RGBA8888
    settings.depthType = ofxiOSRendererDepthFormat::DEPTH_24; // depth format (16/24) if depth enabled
    settings.stencilType = ofxiOSRendererStencilFormat::STENCIL_NONE; // stencil mode
    settings.windowMode = OF_FULLSCREEN;
    settings.setupOrientation = OF_ORIENTATION_90_RIGHT;
    settings.enableMultiTouch = true; // enables multitouch support and updates touch.id etc.
    ofCreateWindow(settings);

This is how my setup code looks:

ofSetOrientation(OF_ORIENTATION_90_RIGHT);
ofSetFrameRate(60);

ofDisableArbTex();
backgroundTexture.enableMipmap();
ofLoadImage(backgroundTexture, "earth.jpg");
backgroundTexture.generateMipmap();

This is my draw code:

ofPushMatrix();
    
        backgroundTexture.bind();
        ofSetColor(0, 0, 0);
        ofDrawRectangle(10, 10, 700, 700);
        
        backgroundTexture.unbind();

ofPopMatrix();

The only thing I can see drawn is a black rectangle and I’m not sure why.

Thanks for any pointers!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images