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);
ps this is a complicated way to draw an image – I wonder if you can do this? (I don’t have a lot of experience with mipmaps, but just thinking of a simpler way)
The npot texture (w/ mipmapping enabled) displays fine on my system in an empty app with a default main(). Therefore, I think this issue has to do with your window settings and more specifically iOS/GLES2. Did you try disabling mipmaps for the npot texture? This post might shed some light on the issue. (I’m on Windows so I don’t know if this still holds true)
for non power of two textures, when you disable ARB they have will have padding since they are stored in in a the smallest power of 2 which can hold the data, which means the rectMesh needs to be fixed to account for that. For example, an image which is 100x200 will be stored in a texture which is 128x256, so some padding (28 pixels in x, 56 pixels in y). Right now, the rectMesh assumes that your texture is full of data since it sets the texture coordinate to (1 or h) for height and (1 or w) for width.
That’s why I recommend using a function like this:
Thanks for the responses, that’s really useful information to know. I’m starting to dust off my old OpenGL knowledge and making some good progress on my app. Thanks for the pointing me in the right direction with the textures.