From 9eb2e337d32b41c873e5eeda6d538032ab89f9f4 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 24 Oct 2011 12:25:59 +0100 Subject: [PATCH] Minor additions to ValueTree, Time. OpenGL work. Update to introjucer MSVC .sln file generation. --- .../jucer_ProjectExport_Android.h | 2 +- .../Project Saving/jucer_ProjectExport_MSVC.h | 10 +- .../Builds/VisualStudio2010/Juce Demo.sln | 1 + .../Builds/VisualStudio2010/juce.sln | 1 + .../Builds/VisualStudio2010/Jucer.sln | 1 + modules/juce_core/time/juce_Time.cpp | 1 + modules/juce_core/time/juce_Time.h | 7 +- .../values/juce_ValueTree.cpp | 4 +- .../values/juce_ValueTree.h | 3 +- .../juce_graphics/colour/juce_FillType.cpp | 6 + modules/juce_graphics/colour/juce_FillType.h | 5 + .../juce_LowLevelGraphicsSoftwareRenderer.h | 36 ++- .../opengl/juce_OpenGLFrameBuffer.cpp | 13 +- .../juce_opengl/opengl/juce_OpenGLHelpers.cpp | 206 ++---------------- .../juce_opengl/opengl/juce_OpenGLHelpers.h | 16 +- 15 files changed, 72 insertions(+), 240 deletions(-) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index 4ee8474f5d..28fbd649c1 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -58,7 +58,7 @@ public: getSDKPath() = "${user.home}/SDKs/android-sdk-mac_x86"; if (getNDKPath().toString().isEmpty()) - getNDKPath() = "${user.home}/SDKs/android-ndk-r5"; + getNDKPath() = "${user.home}/SDKs/android-ndk-r6b"; if (getInternetNeeded().toString().isEmpty()) getInternetNeeded() = true; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 1bbfed47eb..63478acafd 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -156,9 +156,13 @@ protected: } //============================================================================== - void writeSolutionFile (OutputStream& out, const String& versionString, const File& vcProject) + void writeSolutionFile (OutputStream& out, const String& versionString, String commentString, const File& vcProject) { + if (commentString.isNotEmpty()) + commentString += newLine; + out << "Microsoft Visual Studio Solution File, Format Version " << versionString << newLine + << commentString << "Project(\"" << createGUID (projectName + "sln_guid") << "\") = \"" << projectName << "\", \"" << vcProject.getFileName() << "\", \"" << projectGUID << '"' << newLine << "EndProject" << newLine @@ -395,7 +399,7 @@ public: { MemoryOutputStream mo; - writeSolutionFile (mo, getSolutionVersionString(), getVCProjFile()); + writeSolutionFile (mo, getSolutionVersionString(), String::empty, getVCProjFile()); overwriteFileIfDifferentOrThrow (getSLNFile(), mo); } @@ -1037,7 +1041,7 @@ public: { MemoryOutputStream mo; - writeSolutionFile (mo, "11.00", getVCProjFile()); + writeSolutionFile (mo, "11.00", "# Visual Studio 2010", getVCProjFile()); overwriteFileIfDifferentOrThrow (getSLNFile(), mo); } diff --git a/extras/JuceDemo/Builds/VisualStudio2010/Juce Demo.sln b/extras/JuceDemo/Builds/VisualStudio2010/Juce Demo.sln index 505d840882..ed5bc76051 100644 --- a/extras/JuceDemo/Builds/VisualStudio2010/Juce Demo.sln +++ b/extras/JuceDemo/Builds/VisualStudio2010/Juce Demo.sln @@ -1,4 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{B49533A3-E69B-E288-783B-47C939C7FB33}") = "Juce Demo", "Juce Demo.vcxproj", "{E9F746BA-9271-B101-E5E2-1615849AF13D}" EndProject Global diff --git a/extras/static library/Builds/VisualStudio2010/juce.sln b/extras/static library/Builds/VisualStudio2010/juce.sln index e355f9063c..f9a63feace 100644 --- a/extras/static library/Builds/VisualStudio2010/juce.sln +++ b/extras/static library/Builds/VisualStudio2010/juce.sln @@ -1,4 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{BA4B9728-10E7-5D2D-B621-D98C8C6069F5}") = "juce", "juce.vcxproj", "{6C6FE871-80B5-5611-1C8D-17A6CCA9ADFA}" EndProject Global diff --git a/extras/the jucer/Builds/VisualStudio2010/Jucer.sln b/extras/the jucer/Builds/VisualStudio2010/Jucer.sln index 088b275677..87e930c8da 100644 --- a/extras/the jucer/Builds/VisualStudio2010/Jucer.sln +++ b/extras/the jucer/Builds/VisualStudio2010/Jucer.sln @@ -1,4 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{564A18DF-F8DA-8D8F-D473-CFFE700460BA}") = "Jucer", "Jucer.vcxproj", "{47850045-7AC4-D12B-6F23-A2E7E3B3617A}" EndProject Global diff --git a/modules/juce_core/time/juce_Time.cpp b/modules/juce_core/time/juce_Time.cpp index 81b9007522..b20e415b2a 100644 --- a/modules/juce_core/time/juce_Time.cpp +++ b/modules/juce_core/time/juce_Time.cpp @@ -375,6 +375,7 @@ String Time::formatted (const String& format) const //============================================================================== int Time::getYear() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900; } int Time::getMonth() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon; } +int Time::getDayOfYear() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_yday; } int Time::getDayOfMonth() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday; } int Time::getDayOfWeek() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday; } int Time::getHours() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour; } diff --git a/modules/juce_core/time/juce_Time.h b/modules/juce_core/time/juce_Time.h index edaf2eb8dd..a56c421b09 100644 --- a/modules/juce_core/time/juce_Time.h +++ b/modules/juce_core/time/juce_Time.h @@ -132,17 +132,20 @@ public: String getMonthName (bool threeLetterVersion) const; /** Returns the day of the month. - The value returned is in the range 1 to 31. */ int getDayOfMonth() const noexcept; /** Returns the number of the day of the week. - The value returned is in the range 0 to 6 (0 = sunday, 1 = monday, etc). */ int getDayOfWeek() const noexcept; + /** Returns the number of the day of the year. + The value returned is in the range 0 to 365. + */ + int getDayOfYear() const noexcept; + /** Returns the name of the weekday. @param threeLetterVersion if true, it'll return a 3-letter abbreviation, e.g. "Tue"; if diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 6cf095ed94..2037bfa7b9 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -684,12 +684,14 @@ var ValueTree::getProperty (const Identifier& name, const var& defaultReturnValu return object == nullptr ? defaultReturnValue : object->getProperty (name, defaultReturnValue); } -void ValueTree::setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager) +ValueTree& ValueTree::setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager) { jassert (name.toString().isNotEmpty()); if (object != nullptr && name.toString().isNotEmpty()) object->setProperty (name, newValue, undoManager); + + return *this; } bool ValueTree::hasProperty (const Identifier& name) const diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 480f06b635..7cd73f15ba 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -167,8 +167,9 @@ public: If the undoManager parameter is non-null, its UndoManager::perform() method will be used, so that this change can be undone. @see var, getProperty, removeProperty + @returns a reference to the value tree, so that you can daisy-chain calls to this method. */ - void setProperty (const Identifier& name, const var& newValue, UndoManager* undoManager); + ValueTree& setProperty (const Identifier& name, const var& newValue, UndoManager* undoManager); /** Returns true if the node contains a named property. */ bool hasProperty (const Identifier& name) const; diff --git a/modules/juce_graphics/colour/juce_FillType.cpp b/modules/juce_graphics/colour/juce_FillType.cpp index 2a03c3ed28..66ce54ce58 100644 --- a/modules/juce_graphics/colour/juce_FillType.cpp +++ b/modules/juce_graphics/colour/juce_FillType.cpp @@ -144,5 +144,11 @@ bool FillType::isInvisible() const noexcept return colour.isTransparent() || (gradient != nullptr && gradient->isInvisible()); } +FillType FillType::transformed (const AffineTransform& t) const +{ + FillType f (*this); + f.transform = f.transform.followedBy (t); + return f; +} END_JUCE_NAMESPACE diff --git a/modules/juce_graphics/colour/juce_FillType.h b/modules/juce_graphics/colour/juce_FillType.h index ce8c09d6c9..3e5bef48a2 100644 --- a/modules/juce_graphics/colour/juce_FillType.h +++ b/modules/juce_graphics/colour/juce_FillType.h @@ -112,6 +112,11 @@ public: /** Returns true if this fill type is completely transparent. */ bool isInvisible() const noexcept; + /** Returns a copy of this fill, adding the specified transform applied to the + existing transform. + */ + FillType transformed (const AffineTransform& transform) const; + //============================================================================== /** The solid colour being used. diff --git a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h index 41b18e8469..acc0a77eb3 100644 --- a/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h +++ b/modules/juce_graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h @@ -49,19 +49,15 @@ public: ~LowLevelGraphicsSoftwareRenderer(); bool isVectorDevice() const; - - //============================================================================== void setOrigin (int x, int y); - void addTransform (const AffineTransform& transform); + void addTransform (const AffineTransform&); float getScaleFactor(); - - bool clipToRectangle (const Rectangle& r); - bool clipToRectangleList (const RectangleList& clipRegion); - void excludeClipRectangle (const Rectangle& r); - void clipToPath (const Path& path, const AffineTransform& transform); - void clipToImageAlpha (const Image& sourceImage, const AffineTransform& transform); - - bool clipRegionIntersects (const Rectangle& r); + bool clipToRectangle (const Rectangle&); + bool clipToRectangleList (const RectangleList&); + void excludeClipRectangle (const Rectangle&); + void clipToPath (const Path&, const AffineTransform&); + void clipToImageAlpha (const Image&, const AffineTransform&); + bool clipRegionIntersects (const Rectangle&); Rectangle getClipBounds() const; bool isClipEmpty() const; @@ -71,29 +67,25 @@ public: void beginTransparencyLayer (float opacity); void endTransparencyLayer(); - //============================================================================== - void setFill (const FillType& fillType); + void setFill (const FillType&); void setOpacity (float opacity); - void setInterpolationQuality (Graphics::ResamplingQuality quality); + void setInterpolationQuality (Graphics::ResamplingQuality); - //============================================================================== - void fillRect (const Rectangle& r, bool replaceExistingContents); - void fillPath (const Path& path, const AffineTransform& transform); + void fillRect (const Rectangle&, bool replaceExistingContents); + void fillPath (const Path&, const AffineTransform&); - void drawImage (const Image& sourceImage, const AffineTransform& transform); + void drawImage (const Image&, const AffineTransform&); void drawLine (const Line & line); void drawVerticalLine (int x, float top, float bottom); void drawHorizontalLine (int x, float top, float bottom); - //============================================================================== - void setFont (const Font& newFont); + void setFont (const Font&); Font getFont(); void drawGlyph (int glyphNumber, float x, float y); - void drawGlyph (int glyphNumber, const AffineTransform& transform); + void drawGlyph (int glyphNumber, const AffineTransform&); - //============================================================================== #ifndef DOXYGEN class SavedState; #endif diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index b35676c76d..6171702307 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -139,8 +139,6 @@ public: return; #endif - OpenGLHelpers::resetErrorState(); - glGenFramebuffersEXT (1, &frameBufferHandle); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, frameBufferHandle); @@ -302,6 +300,8 @@ bool OpenGLFrameBuffer::initialise (const OpenGLFrameBuffer& other) glColor4f (1.0f, 1.0f, 1.0f, 1.0f); other.drawAt (0, 0); pimpl->unbind(); + + return true; } return false; @@ -384,9 +384,8 @@ bool OpenGLFrameBuffer::readPixels (PixelARGB* target, const Rectangle& are return false; glPixelStorei (GL_PACK_ALIGNMENT, 4); - glReadPixels (area.getX(), area.getY(), area.getWidth(), area.getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, target); + glReadPixels (area.getX(), area.getY(), area.getWidth(), area.getHeight(), GL_BGRA_EXT, GL_UNSIGNED_BYTE, target); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); - return true; } @@ -395,8 +394,6 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle if (! makeCurrentRenderingTarget()) return false; - const int invertedY = pimpl->height - area.getBottom(); - OpenGLHelpers::prepareFor2D (pimpl->width, pimpl->height); glDisable (GL_DEPTH_TEST); glDisable (GL_BLEND); @@ -414,11 +411,11 @@ bool OpenGLFrameBuffer::writePixels (const PixelARGB* data, const Rectangle const GLint cropRect[4] = { 0, 0, area.getWidth(), area.getHeight() }; glTexParameteriv (GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); - glDrawTexiOES (area.getX(), invertedY, 1, area.getWidth(), area.getHeight()); + glDrawTexiOES (area.getX(), area.getY(), 1, area.getWidth(), area.getHeight()); glBindTexture (GL_TEXTURE_2D, 0); } #else - glRasterPos2i (area.getX(), invertedY); + glRasterPos2i (area.getX(), area.getY()); glBindTexture (GL_TEXTURE_2D, 0); glPixelStorei (GL_UNPACK_ALIGNMENT, 4); glDrawPixels (area.getWidth(), area.getHeight(), GL_BGRA_EXT, GL_UNSIGNED_BYTE, data); diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index 2b81e8d9e4..b2f8ad6afd 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -163,6 +163,12 @@ void OpenGLHelpers::applyTransform (const AffineTransform& t) glMultMatrixf (m); } +void OpenGLHelpers::enableScissorTest (const Rectangle& clip) +{ + glEnable (GL_SCISSOR_TEST); + glScissor (clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight()); +} + void OpenGLHelpers::drawQuad2D (float x1, float y1, float x2, float y2, float x3, float y3, @@ -210,140 +216,6 @@ void OpenGLHelpers::drawQuad3D (float x1, float y1, float z1, } //============================================================================== -namespace OpenGLGradientHelpers -{ - void drawTriangles (GLenum mode, const GLfloat* vertices, const GLfloat* textureCoords, const int numElements) - { - glEnable (GL_TEXTURE_2D); - glEnableClientState (GL_VERTEX_ARRAY); - glEnableClientState (GL_TEXTURE_COORD_ARRAY); - glDisableClientState (GL_COLOR_ARRAY); - glDisableClientState (GL_NORMAL_ARRAY); - - glVertexPointer (2, GL_FLOAT, 0, vertices); - glTexCoordPointer (2, GL_FLOAT, 0, textureCoords); - - glColor4f (1.0f, 1.0f, 1.0f, 1.0f); - glDrawArrays (mode, 0, numElements); - } - - void fillWithLinearGradient (const Rectangle& rect, - const ColourGradient& grad, - const AffineTransform& transform, - const int textureSize) - { - const Point p1 (grad.point1.transformedBy (transform)); - const Point p2 (grad.point2.transformedBy (transform)); - const Point p3 (Point (grad.point1.getX() - (grad.point2.getY() - grad.point1.getY()) / textureSize, - grad.point1.getY() + (grad.point2.getX() - grad.point1.getX()) / textureSize).transformedBy (transform)); - - const AffineTransform textureTransform (AffineTransform::fromTargetPoints (p1.getX(), p1.getY(), 0.0f, 0.0f, - p2.getX(), p2.getY(), 1.0f, 0.0f, - p3.getX(), p3.getY(), 0.0f, 1.0f)); - - const GLfloat l = (GLfloat) rect.getX(); - const GLfloat r = (GLfloat) rect.getRight(); - const GLfloat t = (GLfloat) rect.getY(); - const GLfloat b = (GLfloat) rect.getBottom(); - - const GLfloat vertices[] = { l, t, r, t, l, b, r, b }; - GLfloat textureCoords[] = { l, t, r, t, l, b, r, b }; - - textureTransform.transformPoints (textureCoords[0], textureCoords[1], textureCoords[2], textureCoords[3]); - textureTransform.transformPoints (textureCoords[4], textureCoords[5], textureCoords[6], textureCoords[7]); - - drawTriangles (GL_TRIANGLE_STRIP, vertices, textureCoords, 4); - } - - void fillWithRadialGradient (const Rectangle& rect, - const ColourGradient& grad, - const AffineTransform& transform) - { - const Point centre (grad.point1.transformedBy (transform)); - - const float screenRadius = centre.getDistanceFrom (rect.getCentre().toFloat()) - + Point (rect.getWidth() / 2, - rect.getHeight() / 2).getDistanceFromOrigin() - + 8.0f; - - const AffineTransform inverse (transform.inverted()); - const float sourceRadius = jmax (Point (screenRadius, 0.0f).transformedBy (inverse).getDistanceFromOrigin(), - Point (0.0f, screenRadius).transformedBy (inverse).getDistanceFromOrigin()); - - const int numDivisions = 90; - GLfloat vertices [4 + numDivisions * 2]; - GLfloat textureCoords [4 + numDivisions * 2]; - - { - GLfloat* t = textureCoords; - *t++ = 0.0f; - *t++ = 0.0f; - - const GLfloat texturePos = sourceRadius / grad.point1.getDistanceFrom (grad.point2); - - for (int i = numDivisions + 1; --i >= 0;) - { - *t++ = texturePos; - *t++ = 0.0f; - } - } - - { - GLfloat* v = vertices; - *v++ = centre.getX(); - *v++ = centre.getY(); - - const Point first (grad.point1.translated (0, -sourceRadius) - .transformedBy (transform)); - *v++ = first.getX(); - *v++ = first.getY(); - - for (int i = 1; i < numDivisions; ++i) - { - const float angle = i * (float_Pi * 2.0f / numDivisions); - const Point p (grad.point1.translated (std::sin (angle) * sourceRadius, - std::cos (angle) * -sourceRadius) - .transformedBy (transform)); - *v++ = p.getX(); - *v++ = p.getY(); - } - - *v++ = first.getX(); - *v++ = first.getY(); - } - - glEnable (GL_SCISSOR_TEST); - glScissor (rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); - drawTriangles (GL_TRIANGLE_FAN, vertices, textureCoords, numDivisions + 2); - glDisable (GL_SCISSOR_TEST); - } -} - -void OpenGLHelpers::fillRectWithColourGradient (const Rectangle& rect, - const ColourGradient& gradient, - const AffineTransform& transform) -{ - const int textureSize = 256; - OpenGLTexture texture; - - HeapBlock lookup (textureSize); - gradient.createLookupTable (lookup, textureSize); - texture.load (lookup, textureSize, 1); - texture.bind(); - - if (gradient.point1 == gradient.point2) - { - fillRectWithColour (rect, gradient.getColourAtPosition (1.0)); - } - else - { - if (gradient.isRadial) - OpenGLGradientHelpers::fillWithRadialGradient (rect, gradient, transform); - else - OpenGLGradientHelpers::fillWithLinearGradient (rect, gradient, transform, textureSize); - } -} - void OpenGLHelpers::fillRectWithColour (const Rectangle& rect, const Colour& colour) { glEnableClientState (GL_VERTEX_ARRAY); @@ -365,48 +237,11 @@ void OpenGLHelpers::fillRect (const Rectangle& rect) glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); } -void OpenGLHelpers::fillRectWithTiledTexture (int textureWidth, int textureHeight, - const Rectangle& clip, - const AffineTransform& transform, - float alpha) -{ - glEnable (GL_TEXTURE_2D); - 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_REPEAT); - glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glEnableClientState (GL_VERTEX_ARRAY); - glEnableClientState (GL_TEXTURE_COORD_ARRAY); - glDisableClientState (GL_COLOR_ARRAY); - glDisableClientState (GL_NORMAL_ARRAY); - glColor4f (1.0f, 1.0f, 1.0f, alpha); - - const GLfloat clipX = (GLfloat) clip.getX(); - const GLfloat clipY = (GLfloat) clip.getY(); - const GLfloat clipR = (GLfloat) clip.getRight(); - const GLfloat clipB = (GLfloat) clip.getBottom(); - - const GLfloat vertices[] = { clipX, clipY, clipR, clipY, clipX, clipB, clipR, clipB }; - GLfloat textureCoords[] = { clipX, clipY, clipR, clipY, clipX, clipB, clipR, clipB }; - - { - const AffineTransform t (transform.inverted().scaled (1.0f / textureWidth, - 1.0f / textureHeight)); - t.transformPoints (textureCoords[0], textureCoords[1], textureCoords[2], textureCoords[3]); - t.transformPoints (textureCoords[4], textureCoords[5], textureCoords[6], textureCoords[7]); - } - - glVertexPointer (2, GL_FLOAT, 0, vertices); - glTexCoordPointer (2, GL_FLOAT, 0, textureCoords); - - glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); -} - //============================================================================== struct OpenGLEdgeTableRenderer { - OpenGLEdgeTableRenderer (float r_, float g_, float b_, const Point& origin_) noexcept - : origin (origin_), r (r_), g (g_), b (b_), lastAlpha (-1) + OpenGLEdgeTableRenderer (float r_, float g_, float b_) noexcept + : r (r_), g (g_), b (b_), lastAlpha (-1) { } @@ -421,12 +256,8 @@ struct OpenGLEdgeTableRenderer void setEdgeTableYPos (const int y) noexcept { - const int lineY = y + origin.getY(); - - vertices[1] = (GLfloat) lineY; - vertices[3] = (GLfloat) (lineY + 1); - vertices[5] = (GLfloat) lineY; - vertices[7] = (GLfloat) (lineY + 1); + vertices[1] = vertices[5] = (GLfloat) y; + vertices[3] = vertices[7] = (GLfloat) (y + 1); } void handleEdgeTablePixel (const int x, const int alphaLevel) noexcept @@ -451,18 +282,13 @@ struct OpenGLEdgeTableRenderer private: GLfloat vertices[8]; - const Point origin; const float r, g, b; int lastAlpha; void drawHorizontal (int x, const int w, const int alphaLevel) noexcept { - x += origin.getX(); - - vertices[0] = (GLfloat) x; - vertices[2] = (GLfloat) x; - vertices[4] = (GLfloat) (x + w); - vertices[6] = (GLfloat) (x + w); + vertices[0] = vertices[2] = (GLfloat) x; + vertices[4] = vertices[6] = (GLfloat) (x + w); if (lastAlpha != alphaLevel) { @@ -477,10 +303,9 @@ private: }; void OpenGLHelpers::fillEdgeTable (const EdgeTable& edgeTable, - float red, float green, float blue, - const Point& offset) + float red, float green, float blue) { - OpenGLEdgeTableRenderer etr (red, green, blue, offset); + OpenGLEdgeTableRenderer etr (red, green, blue); etr.draw (edgeTable); } @@ -776,6 +601,7 @@ void TriangulatedPath::draw (const int oversamplingLevel) const { glColor4f (1.0f, 1.0f, 1.0f, 1.0f / (oversamplingLevel * oversamplingLevel)); + glPushMatrix(); glTranslatef (-0.5f, -0.5f, 0.0f); const float inc = 1.0f / oversamplingLevel; @@ -791,6 +617,8 @@ void TriangulatedPath::draw (const int oversamplingLevel) const glTranslatef (-1.0f, inc, 0.0f); } + + glPopMatrix(); } void TriangulatedPath::optimiseStorage() diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h index f04d6e4a94..e1e6aef962 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.h +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.h @@ -57,6 +57,8 @@ public: static void applyTransform (const AffineTransform& t); + static void enableScissorTest (const Rectangle& clip); + /** Draws a 2D quad with the specified corner points. */ static void drawQuad2D (float x1, float y1, float x2, float y2, @@ -76,21 +78,9 @@ public: /** Fills a rectangle with the specified colour. */ static void fillRectWithColour (const Rectangle& rect, const Colour& colour); - - /** Fills a rectangle with the specified gradient. */ - static void fillRectWithColourGradient (const Rectangle& rect, - const ColourGradient& gradient, - const AffineTransform& transform); - - static void fillRectWithTiledTexture (int textureWidth, int textureHeight, - const Rectangle& targetArea, - const AffineTransform& transform, - float alpha); - /** Renders an edge-table into the current context. */ static void fillEdgeTable (const EdgeTable& edgeTable, - float red, float green, float blue, - const Point& offset); + float red, float green, float blue); /** Checks whether the current context supports the specified extension. */ static bool isExtensionSupported (const char* extensionName);