mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
OpenGL: Added method OpenGLContext::setTextureMagnificationFilter to change GL's texture magnification filter
This commit is contained in:
parent
7854ca74f0
commit
159ffb5fb9
3 changed files with 27 additions and 1 deletions
|
|
@ -836,6 +836,11 @@ void OpenGLContext::setPixelFormat (const OpenGLPixelFormat& preferredPixelForma
|
|||
openGLPixelFormat = preferredPixelFormat;
|
||||
}
|
||||
|
||||
void OpenGLContext::setTextureMagnificationFilter (OpenGLContext::TextureMagnificationFilter magFilterMode) noexcept
|
||||
{
|
||||
texMagFilter = magFilterMode;
|
||||
}
|
||||
|
||||
void OpenGLContext::setNativeSharedContext (void* nativeContextToShareWith) noexcept
|
||||
{
|
||||
// This method must not be called when the context has already been attached!
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
class OpenGLTexture;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Creates an OpenGL context, which can be attached to a component.
|
||||
|
|
@ -97,6 +99,20 @@ public:
|
|||
*/
|
||||
void setPixelFormat (const OpenGLPixelFormat& preferredPixelFormat) noexcept;
|
||||
|
||||
/** Texture magnification filters, used by setTextureMagnificationFilter(). */
|
||||
enum TextureMagnificationFilter
|
||||
{
|
||||
nearest,
|
||||
linear
|
||||
};
|
||||
|
||||
/** Sets the texture magnification filter. By default the texture magnification
|
||||
filter is linear. However, for faster rendering you may want to use the
|
||||
'nearest' magnification filter. This option will not affect any textures
|
||||
created before this function was called. */
|
||||
void setTextureMagnificationFilter (TextureMagnificationFilter magFilterMode) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Provides a context with which you'd like this context's resources to be shared.
|
||||
The object passed-in here is a platform-dependent native context object, and
|
||||
must not be deleted while this context may still be using it! To turn off sharing,
|
||||
|
|
@ -298,6 +314,8 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
friend class OpenGLTexture;
|
||||
|
||||
class CachedImage;
|
||||
class Attachment;
|
||||
NativeContext* nativeContext = nullptr;
|
||||
|
|
@ -309,6 +327,7 @@ private:
|
|||
OpenGLVersion versionRequired = defaultGLVersion;
|
||||
size_t imageCacheMaxSize = 8 * 1024 * 1024;
|
||||
bool renderComponents = true, useMultisampling = false, continuousRepaint = false, overrideCanAttach = false;
|
||||
TextureMagnificationFilter texMagFilter = linear;
|
||||
|
||||
//==============================================================================
|
||||
struct AsyncWorker : public ReferenceCountedObject
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ void OpenGLTexture::create (const int w, const int h, const void* pixels, GLenum
|
|||
glGenTextures (1, &textureID);
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
auto glMagFilter = (ownerContext->texMagFilter == OpenGLContext::linear ? GL_LINEAR : GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glMagFilter);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue