Hi,
I am trying to scale an image to larger than its original size when rendering. I am using the below code but it is blurring the image. My scale is set in the ci::mat4 returned by GetTransform().
ci::gl::enableAlphaBlending(m_bPremultiplied);
ci::gl::pushModelView();
ci::gl::multModelMatrix(m_pPosition->GetTransform());
ci::gl::color(m_Color);
ci::gl::draw(m_pTexture, m_pPosition->GetRect());
ci::gl::popModelView();
ci::gl::disableAlphaBlending();
For comparison, I can load my image in photoshop/gimp and zoom in to view individual pixels. I would like to recreate that level of zoom.
Hi SuperRockG,
you should set you m_pTexture to GL_NEAREST instead of GL_LINEAR.
assuming that you m_pTexture is a gl::Texture2dRef, something like:
gl::Texture2d::Format format;
format.setMagFilter( GL_LINEAR );
format.setMinFilter( GL_LINEAR );
m_pTexture = Texture2d::create(width, height, format);
Edit (just to be correct):
gl::Texture2d::Format format;
format.setMagFilter( GL_NEAREST );
m_pTexture = Texture2d::create(width, height, format);
I hope this will solve your issue.
L
To be more precise: change your magFilter()
to GL_NEAREST
to disable linear interpolation when zooming in (magnifying your texture).
paul.houx:
magFilter()
Ops I wrote exactly the opposite than what SuperRockG needed…
True, for zooming just the magFilter is involved.
L