mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Stripped out all the old openGL fixed-function code, and hard-coded the assumption that it'll be running on hardware that's capable of running GLSL.
This commit is contained in:
parent
e7e2abbb5c
commit
80387e8cb5
13 changed files with 7 additions and 437 deletions
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#if JUCE_IOS || JUCE_ANDROID
|
||||
#define JUCE_OPENGL_ES 1
|
||||
#define JUCE_USE_OPENGL_FIXED_FUNCTION 0
|
||||
#endif
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
|
|
@ -65,14 +64,6 @@
|
|||
#include <GLES2/gl2.h>
|
||||
#endif
|
||||
|
||||
#if ! defined (JUCE_USE_OPENGL_SHADERS)
|
||||
#define JUCE_USE_OPENGL_SHADERS 1
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
#define JUCE_USE_OPENGL_FIXED_FUNCTION 1
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
namespace juce
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
/** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux.
|
||||
@see OpenGLExtensionFunctions
|
||||
*/
|
||||
#define JUCE_GL_BASIC_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION) \
|
||||
#define JUCE_GL_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION) \
|
||||
USE_FUNCTION (glActiveTexture, void, (GLenum p1), (p1))\
|
||||
USE_FUNCTION (glBindBuffer, void, (GLenum p1, GLuint p2), (p1, p2))\
|
||||
USE_FUNCTION (glDeleteBuffers, void, (GLsizei p1, const GLuint* p2), (p1, p2))\
|
||||
|
|
@ -54,11 +54,7 @@
|
|||
EXT_FUNCTION (glCheckFramebufferStatus, GLenum, (GLenum p1), (p1))\
|
||||
EXT_FUNCTION (glFramebufferTexture2D, void, (GLenum p1, GLenum p2, GLenum p3, GLuint p4, GLint p5), (p1, p2, p3, p4, p5))\
|
||||
EXT_FUNCTION (glFramebufferRenderbuffer, void, (GLenum p1, GLenum p2, GLenum p3, GLuint p4), (p1, p2, p3, p4))\
|
||||
EXT_FUNCTION (glGetFramebufferAttachmentParameteriv, void, (GLenum p1, GLenum p2, GLenum p3, GLint* p4), (p1, p2, p3, p4))
|
||||
|
||||
#if JUCE_USE_OPENGL_SHADERS
|
||||
#define JUCE_GL_EXTENSION_FUNCTIONS1(USE_FUNCTION, EXT_FUNCTION) \
|
||||
JUCE_GL_BASIC_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION) \
|
||||
EXT_FUNCTION (glGetFramebufferAttachmentParameteriv, void, (GLenum p1, GLenum p2, GLenum p3, GLint* p4), (p1, p2, p3, p4))\
|
||||
USE_FUNCTION (glCreateProgram, GLuint, (), ())\
|
||||
USE_FUNCTION (glDeleteProgram, void, (GLuint p1), (p1))\
|
||||
USE_FUNCTION (glCreateShader, GLuint, (GLenum p1), (p1))\
|
||||
|
|
@ -88,16 +84,6 @@
|
|||
USE_FUNCTION (glUniformMatrix3fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))\
|
||||
USE_FUNCTION (glUniformMatrix4fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))
|
||||
|
||||
#else
|
||||
#define JUCE_GL_EXTENSION_FUNCTIONS1(USE_FUNCTION, EXT_FUNCTION) JUCE_GL_BASIC_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION)
|
||||
#endif
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
#define JUCE_GL_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION) JUCE_GL_EXTENSION_FUNCTIONS1(USE_FUNCTION, EXT_FUNCTION) \
|
||||
USE_FUNCTION (glClientActiveTexture, void, (GLenum p1), (p1))
|
||||
#else
|
||||
#define JUCE_GL_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION) JUCE_GL_EXTENSION_FUNCTIONS1(USE_FUNCTION, EXT_FUNCTION)
|
||||
#endif
|
||||
|
||||
/** This class contains a generated list of OpenGL extension functions, which are either dynamically loaded
|
||||
for a specific GL context, or simply call-through to the appropriate OS function where available.
|
||||
|
|
|
|||
|
|
@ -113,14 +113,6 @@ public:
|
|||
return quaternion;
|
||||
}
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
/** Applies this rotation to the active OpenGL context's matrix. */
|
||||
void applyToOpenGLMatrix() const noexcept
|
||||
{
|
||||
OpenGLHelpers::applyMatrix (getRotationMatrix().mat);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
Rectangle<int> area;
|
||||
float radius;
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ public:
|
|||
context.extensions.initialise();
|
||||
nativeContext->setSwapInterval (1);
|
||||
|
||||
#if JUCE_USE_OPENGL_SHADERS && ! JUCE_OPENGL_ES
|
||||
#if ! JUCE_OPENGL_ES
|
||||
shadersAvailable = OpenGLShaderProgram::getLanguageVersion() > 0;
|
||||
#endif
|
||||
|
||||
|
|
@ -761,7 +761,6 @@ void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
|
|||
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_BLEND);
|
||||
|
||||
#if JUCE_USE_OPENGL_SHADERS
|
||||
if (areShadersAvailable())
|
||||
{
|
||||
struct OverlayShaderProgram : public ReferenceCountedObject
|
||||
|
|
@ -871,40 +870,10 @@ void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
|
|||
extensions.glDisableVertexAttribArray (index);
|
||||
extensions.glDeleteBuffers (1, &vertexBuffer);
|
||||
}
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
{
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
glScissor (targetClipArea.getX(), contextHeight - targetClipArea.getBottom(),
|
||||
targetClipArea.getWidth(), targetClipArea.getHeight());
|
||||
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
OpenGLHelpers::prepareFor2D (contextWidth, contextHeight);
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
|
||||
const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f };
|
||||
glTexCoordPointer (2, GL_FLOAT, 0, textureCoords);
|
||||
|
||||
const GLshort left = (GLshort) anchorPosAndTextureSize.getX();
|
||||
const GLshort right = (GLshort) anchorPosAndTextureSize.getRight();
|
||||
const GLshort top = (GLshort) (contextHeight - anchorPosAndTextureSize.getY());
|
||||
const GLshort bottom = (GLshort) (contextHeight - anchorPosAndTextureSize.getBottom());
|
||||
const GLshort vertices[] = { left, bottom, right, bottom, left, top, right, top };
|
||||
glVertexPointer (2, GL_SHORT, 0, vertices);
|
||||
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
|
||||
glDisable (GL_SCISSOR_TEST);
|
||||
jassertfalse; // Running on an old graphics card!
|
||||
}
|
||||
#endif
|
||||
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,20 +334,6 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle<int>
|
|||
glDisable (GL_BLEND);
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
|
||||
#if JUCE_OPENGL_ES && JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
OpenGLTexture tex;
|
||||
tex.loadARGBFlipped (data, area.getWidth(), area.getHeight());
|
||||
|
||||
const int texH = tex.getHeight();
|
||||
tex.bind();
|
||||
const GLint cropRect[4] = { 0, texH - area.getHeight(), area.getWidth(), area.getHeight() };
|
||||
glTexParameteriv (GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
clearGLError();
|
||||
glColor4f (1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glDrawTexiOES (area.getX(), area.getY(), 1, area.getWidth(), area.getHeight());
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
#else
|
||||
OpenGLTexture tex;
|
||||
tex.loadARGB (data, area.getWidth(), area.getHeight());
|
||||
|
||||
|
|
@ -355,69 +341,7 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle<int>
|
|||
pimpl->context.copyTexture (area, Rectangle<int> (area.getX(), area.getY(),
|
||||
tex.getWidth(), tex.getHeight()),
|
||||
pimpl->width, pimpl->height, true);
|
||||
#endif
|
||||
|
||||
JUCE_CHECK_OPENGL_ERROR
|
||||
return true;
|
||||
}
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
void OpenGLFrameBuffer::draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour) const
|
||||
{
|
||||
if (pimpl != nullptr)
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, pimpl->textureID);
|
||||
OpenGLHelpers::drawQuad2D (x1, y1, x2, y2, x3, y3, x4, y4, colour);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::draw3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour) const
|
||||
{
|
||||
if (pimpl != nullptr)
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, pimpl->textureID);
|
||||
OpenGLHelpers::drawQuad3D (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, colour);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::drawAt (float x1, float y1) const
|
||||
{
|
||||
if (pimpl != nullptr)
|
||||
{
|
||||
#if ! JUCE_ANDROID
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
clearGLError();
|
||||
#endif
|
||||
glBindTexture (GL_TEXTURE_2D, pimpl->textureID);
|
||||
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
|
||||
const GLfloat vertices[] = { x1, y1,
|
||||
x1 + pimpl->width, y1,
|
||||
x1, y1 + pimpl->height,
|
||||
x1 + pimpl->width, y1 + pimpl->height };
|
||||
|
||||
const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (2, GL_FLOAT, 0, vertices);
|
||||
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer (2, GL_FLOAT, 0, textureCoords);
|
||||
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -106,25 +106,6 @@ public:
|
|||
/** Selects the framebuffer as the current target, and clears it to transparent. */
|
||||
void makeCurrentAndClear();
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
/** Draws this framebuffer onto the current context, with the specified corner positions. */
|
||||
void draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour) const;
|
||||
|
||||
/** Draws this framebuffer onto the current context, with the specified corner positions. */
|
||||
void draw3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour) const;
|
||||
|
||||
/** Draws the framebuffer at a given position. */
|
||||
void drawAt (float x1, float y1) const;
|
||||
#endif
|
||||
|
||||
/** Reads an area of pixels from the framebuffer into a 32-bit ARGB pixel array.
|
||||
The lineStride is measured as a number of pixels, not bytes - pass a stride
|
||||
of 0 to indicate a packed array.
|
||||
|
|
|
|||
|
|
@ -230,8 +230,6 @@ struct Target
|
|||
Rectangle<int> bounds;
|
||||
};
|
||||
|
||||
#if JUCE_USE_OPENGL_SHADERS
|
||||
|
||||
//==============================================================================
|
||||
class PositionedTexture
|
||||
{
|
||||
|
|
@ -1660,8 +1658,6 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShaderContext)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class NonShaderContext : public LowLevelGraphicsSoftwareRenderer
|
||||
{
|
||||
public:
|
||||
|
|
@ -1709,10 +1705,8 @@ private:
|
|||
LowLevelGraphicsContext* createOpenGLContext (const Target&);
|
||||
LowLevelGraphicsContext* createOpenGLContext (const Target& target)
|
||||
{
|
||||
#if JUCE_USE_OPENGL_SHADERS
|
||||
if (target.context.areShadersAvailable())
|
||||
return new ShaderContext (target);
|
||||
#endif
|
||||
|
||||
Image tempImage (Image::ARGB, target.bounds.getWidth(), target.bounds.getHeight(), true, SoftwareImageType());
|
||||
return new NonShaderContext (target, tempImage);
|
||||
|
|
|
|||
|
|
@ -71,185 +71,8 @@ void OpenGLHelpers::clear (Colour colour)
|
|||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
void OpenGLHelpers::setColour (Colour colour)
|
||||
{
|
||||
glColor4f (colour.getFloatRed(), colour.getFloatGreen(),
|
||||
colour.getFloatBlue(), colour.getFloatAlpha());
|
||||
}
|
||||
|
||||
void OpenGLHelpers::prepareFor2D (const int width, const int height)
|
||||
{
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
glOrthof (0.0f, (GLfloat) width, 0.0f, (GLfloat) height, 0.0f, 1.0f);
|
||||
#else
|
||||
glOrtho (0.0, width, 0.0, height, 0, 1);
|
||||
#endif
|
||||
|
||||
glViewport (0, 0, width, height);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::setPerspective (double fovy, double aspect, double zNear, double zFar)
|
||||
{
|
||||
glLoadIdentity();
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
const GLfloat ymax = (GLfloat) (zNear * tan (fovy * double_Pi / 360.0));
|
||||
const GLfloat ymin = -ymax;
|
||||
|
||||
glFrustumf (ymin * (GLfloat) aspect, ymax * (GLfloat) aspect, ymin, ymax, (GLfloat) zNear, (GLfloat) zFar);
|
||||
#else
|
||||
const double ymax = zNear * tan (fovy * double_Pi / 360.0);
|
||||
const double ymin = -ymax;
|
||||
|
||||
glFrustum (ymin * aspect, ymax * aspect, ymin, ymax, zNear, zFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLHelpers::applyTransform (const AffineTransform& t)
|
||||
{
|
||||
const GLfloat m[] = { t.mat00, t.mat10, 0, 0,
|
||||
t.mat01, t.mat11, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
t.mat02, t.mat12, 0, 1 };
|
||||
glMultMatrixf (m);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::applyMatrix (const float matrixValues[16])
|
||||
{
|
||||
glMultMatrixf (matrixValues);
|
||||
}
|
||||
|
||||
#if ! JUCE_OPENGL_ES
|
||||
void OpenGLHelpers::applyMatrix (const double matrixValues[16])
|
||||
{
|
||||
glMultMatrixd (matrixValues);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void OpenGLHelpers::enableScissorTest (const Rectangle<int>& clip)
|
||||
{
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
glScissor (clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight());
|
||||
}
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
void OpenGLHelpers::drawQuad2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour)
|
||||
{
|
||||
const GLfloat vertices[] = { x1, y1, x2, y2, x4, y4, x3, y3 };
|
||||
const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
setColour (colour);
|
||||
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (2, GL_FLOAT, 0, vertices);
|
||||
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer (2, GL_FLOAT, 0, textureCoords);
|
||||
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::drawQuad3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour)
|
||||
{
|
||||
const GLfloat vertices[] = { x1, y1, z1, x2, y2, z2, x4, y4, z4, x3, y3, z3 };
|
||||
const GLfloat textureCoords[] = { 0, 0, 1.0f, 0, 0, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
setColour (colour);
|
||||
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (3, GL_FLOAT, 0, vertices);
|
||||
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer (2, GL_FLOAT, 0, textureCoords);
|
||||
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords, const int numVertices) noexcept
|
||||
{
|
||||
#if ! JUCE_ANDROID
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
clearGLError();
|
||||
#endif
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (2, GL_FLOAT, 0, vertices);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer (2, GL_FLOAT, 0, textureCoords);
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, numVertices);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords,
|
||||
const int numVertices, const GLuint textureID) noexcept
|
||||
{
|
||||
jassert (textureID != 0);
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
drawTriangleStrip (vertices, textureCoords, numVertices);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::drawTextureQuad (GLuint textureID, const Rectangle<int>& rect)
|
||||
{
|
||||
const GLfloat l = (GLfloat) rect.getX();
|
||||
const GLfloat t = (GLfloat) rect.getY();
|
||||
const GLfloat r = (GLfloat) rect.getRight();
|
||||
const GLfloat b = (GLfloat) rect.getBottom();
|
||||
|
||||
const GLfloat vertices[] = { l, t, r, t, l, b, r, b };
|
||||
const GLfloat textureCoords[] = { 0, 1.0f, 1.0f, 1.0f, 0, 0, 1.0f, 0 };
|
||||
|
||||
drawTriangleStrip (vertices, textureCoords, 4, textureID);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::fillRectWithTexture (const Rectangle<int>& rect, GLuint textureID, const float alpha)
|
||||
{
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glColor4f (alpha, alpha, alpha, alpha);
|
||||
|
||||
drawTextureQuad (textureID, rect);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::fillRectWithColour (const Rectangle<int>& rect, Colour colour)
|
||||
{
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
setColour (colour);
|
||||
fillRect (rect);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::fillRect (const Rectangle<int>& rect)
|
||||
{
|
||||
const GLfloat vertices[] = { (GLfloat) rect.getX(), (GLfloat) rect.getY(),
|
||||
(GLfloat) rect.getRight(), (GLfloat) rect.getY(),
|
||||
(GLfloat) rect.getX(), (GLfloat) rect.getBottom(),
|
||||
(GLfloat) rect.getRight(), (GLfloat) rect.getBottom() };
|
||||
|
||||
glVertexPointer (2, GL_FLOAT, 0, vertices);
|
||||
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,52 +49,6 @@ public:
|
|||
|
||||
/** Returns the address of a named GL extension function */
|
||||
static void* getExtensionFunction (const char* functionName);
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
/** Sets the current colour using a JUCE colour. */
|
||||
static void setColour (Colour colour);
|
||||
|
||||
/** Gives the current context an orthoganal rendering mode for 2D drawing into the given size. */
|
||||
static void prepareFor2D (int width, int height);
|
||||
|
||||
/** This does the same job as gluPerspective(). */
|
||||
static void setPerspective (double fovy, double aspect, double zNear, double zFar);
|
||||
|
||||
static void applyTransform (const AffineTransform& t);
|
||||
|
||||
static void applyMatrix (const float matrixValues[16]);
|
||||
#if ! JUCE_OPENGL_ES
|
||||
static void applyMatrix (const double matrixValues[16]);
|
||||
#endif
|
||||
|
||||
/** Draws a 2D quad with the specified corner points. */
|
||||
static void drawQuad2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour);
|
||||
|
||||
/** Draws a 3D quad with the specified corner points. */
|
||||
static void drawQuad3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour);
|
||||
static void drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords, const int numVertices) noexcept;
|
||||
|
||||
static void drawTriangleStrip (const GLfloat* const vertices, const GLfloat* const textureCoords,
|
||||
const int numVertices, const GLuint textureID) noexcept;
|
||||
|
||||
static void drawTextureQuad (GLuint textureID, const Rectangle<int>& rect);
|
||||
|
||||
static void fillRectWithTexture (const Rectangle<int>& rect, GLuint textureID, const float alpha);
|
||||
|
||||
/** Fills a rectangle with the specified colour. */
|
||||
static void fillRectWithColour (const Rectangle<int>& rect,
|
||||
Colour colour);
|
||||
|
||||
static void fillRect (const Rectangle<int>& rect);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
#if JUCE_USE_OPENGL_SHADERS
|
||||
|
||||
OpenGLShaderProgram::OpenGLShaderProgram (const OpenGLContext& c) noexcept
|
||||
: context (c)
|
||||
{
|
||||
|
|
@ -148,5 +146,3 @@ void OpenGLShaderProgram::Uniform::set (const GLfloat* values, GLsizei numValues
|
|||
void OpenGLShaderProgram::Uniform::setMatrix2 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix2fv (uniformID, num, trns, v); }
|
||||
void OpenGLShaderProgram::Uniform::setMatrix3 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix3fv (uniformID, num, trns, v); }
|
||||
void OpenGLShaderProgram::Uniform::setMatrix4 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix4fv (uniformID, num, trns, v); }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
class JUCE_API OpenGLShaderProgram
|
||||
{
|
||||
public:
|
||||
OpenGLShaderProgram (const OpenGLContext& context) noexcept;
|
||||
OpenGLShaderProgram (const OpenGLContext&) noexcept;
|
||||
~OpenGLShaderProgram() noexcept;
|
||||
|
||||
/** Returns the version of GLSL that the current context supports.
|
||||
|
|
|
|||
|
|
@ -184,27 +184,3 @@ void OpenGLTexture::unbind() const
|
|||
{
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
void OpenGLTexture::draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour) const
|
||||
{
|
||||
bind();
|
||||
OpenGLHelpers::drawQuad2D (x1, y1, x2, y2, x3, y3, x4, y4, colour);
|
||||
unbind();
|
||||
}
|
||||
|
||||
void OpenGLTexture::draw3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour) const
|
||||
{
|
||||
bind();
|
||||
OpenGLHelpers::drawQuad3D (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, colour);
|
||||
unbind();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -71,28 +71,12 @@ public:
|
|||
/** Frees the texture, if there is one. */
|
||||
void release();
|
||||
|
||||
/** Binds the texture to the currently selected openGL context. */
|
||||
/** Binds the texture to the currently active openGL context. */
|
||||
void bind() const;
|
||||
|
||||
/** Unbinds the texture to the currently selected openGL context. */
|
||||
/** Unbinds the texture to the currently active openGL context. */
|
||||
void unbind() const;
|
||||
|
||||
#if JUCE_USE_OPENGL_FIXED_FUNCTION
|
||||
/** Draws this texture into the current context, with the specified corner positions. */
|
||||
void draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
Colour colour) const;
|
||||
|
||||
/** Draws this texture into the current context, with the specified corner positions. */
|
||||
void draw3D (float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4,
|
||||
Colour colour) const;
|
||||
#endif
|
||||
|
||||
/** Returns the GL texture ID number. */
|
||||
GLuint getTextureID() const noexcept { return textureID; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue