Browse Source

OpenGL work: renamed OpenGLGraphicsContext class, and made it use shaders for rendering where available.

tags/2021-05-28
jules 13 years ago
parent
commit
a56a285e58
9 changed files with 1068 additions and 692 deletions
  1. +3
    -3
      extras/JuceDemo/Source/demos/OpenGLDemo.cpp
  2. +1
    -1
      modules/juce_core/system/juce_PlatformDefs.h
  3. +1
    -0
      modules/juce_opengl/native/juce_OpenGLExtensions.h
  4. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLComponent.cpp
  5. +3
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.h
  6. +1051
    -679
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp
  7. +5
    -5
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h
  8. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLImage.cpp
  9. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h

+ 3
- 3
extras/JuceDemo/Source/demos/OpenGLDemo.cpp View File

@@ -92,7 +92,7 @@ public:
updateTextureImage(); // this will update our dynamically-changing texture image.
drawBackground2DStuff(); // draws some 2D content to demonstrate the OpenGLRenderer class
drawBackground2DStuff(); // draws some 2D content to demonstrate the OpenGLGraphicsContext class
// Having used the juce 2D renderer, it will have messed-up a whole load of GL state, so
// we'll put back any important settings before doing our normal GL 3D drawing..
@@ -142,7 +142,7 @@ public:
void drawBackground2DStuff()
{
OpenGLRenderer glRenderer (*this); // Create an OpenGLRenderer that will draw into this GL window..
OpenGLGraphicsContext glRenderer (*this); // Create an OpenGLGraphicsContext that will draw into this GL window..
Graphics g (&glRenderer); // ..and then wrap it in a normal Graphics object so we can draw with it.
// This stuff just creates a spinning star shape and fills it..
@@ -203,7 +203,7 @@ private:
void drawScrollingMessage (Graphics& g, int y) const
{
g.drawSingleLineText ("The background, foreground and texture are all being drawn using the OpenGLRenderer class, which "
g.drawSingleLineText ("The background, foreground and texture are all being drawn using the OpenGLGraphicsContext class, which "
"lets you use a standard JUCE 2D graphics context to render directly onto an OpenGL window or framebuffer... ",
(int) -std::fmod (textScrollPos, 2500.0f), y);
}


+ 1
- 1
modules/juce_core/system/juce_PlatformDefs.h View File

@@ -68,7 +68,7 @@
*/
#define juce_breakDebugger { assert (false); }
#elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID
#define juce_breakDebugger { kill (0, SIGTRAP); }
#define juce_breakDebugger { ::kill (0, SIGTRAP); }
#elif JUCE_USE_INTRINSICS
#ifndef __INTEL_COMPILER
#pragma intrinsic (__debugbreak)


+ 1
- 0
modules/juce_opengl/native/juce_OpenGLExtensions.h View File

@@ -97,6 +97,7 @@ enum
GL_LINK_STATUS = 0x8B82,
GL_SHADING_LANGUAGE_VERSION = 0x8B8C,
GL_FRAGMENT_SHADER = 0x8B30,
GL_VERTEX_SHADER = 0x8B31,
GL_FRAMEBUFFER = 0x8D40,
GL_RENDERBUFFER = 0x8D41,
GL_FRAMEBUFFER_BINDING = 0x8CA6,


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLComponent.cpp View File

@@ -308,7 +308,7 @@ public:
if (! invalid.isEmpty())
{
OpenGLRenderer g (frameBuffer);
OpenGLGraphicsContext g (frameBuffer);
g.clipToRectangleList (invalid);
g.setFill (Colours::transparentBlack);
@@ -338,7 +338,7 @@ public:
}
private:
void paintOwner (OpenGLRenderer& glRenderer)
void paintOwner (OpenGLGraphicsContext& glRenderer)
{
Graphics g (&glRenderer);


+ 3
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.h View File

@@ -98,6 +98,9 @@ public:
*/
static OpenGLContext* getCurrentContext();
/** This property set allows you to attach persisent values to the context. */
NamedValueSet properties;
protected:
//==============================================================================
OpenGLContext() noexcept;


+ 1051
- 679
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp
File diff suppressed because it is too large
View File


+ 5
- 5
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.h View File

@@ -30,13 +30,13 @@
//==============================================================================
/** A LowLevelGraphicsContext for rendering into an OpenGL framebuffer or window.
*/
class JUCE_API OpenGLRenderer : public LowLevelGraphicsContext
class JUCE_API OpenGLGraphicsContext : public LowLevelGraphicsContext
{
public:
explicit OpenGLRenderer (OpenGLComponent& target);
explicit OpenGLRenderer (OpenGLFrameBuffer& target);
OpenGLRenderer (unsigned int frameBufferID, int width, int height);
~OpenGLRenderer();
explicit OpenGLGraphicsContext (OpenGLComponent& target);
explicit OpenGLGraphicsContext (OpenGLFrameBuffer& target);
OpenGLGraphicsContext (unsigned int frameBufferID, int width, int height);
~OpenGLGraphicsContext();
bool isVectorDevice() const;
void setOrigin (int x, int y);


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLImage.cpp View File

@@ -38,7 +38,7 @@ public:
LowLevelGraphicsContext* createLowLevelContext()
{
return new OpenGLRenderer (frameBuffer);
return new OpenGLGraphicsContext (frameBuffer);
}
ImageType* createType() const { return new OpenGLImageType(); }


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h View File

@@ -55,7 +55,7 @@ public:
If your app is built in debug mode, this method will assert if the program
fails to compile correctly.
The shaderType parameter is GL_VERTEX_SHADER or GL_FRAGMENT_SHADER
The shaderType parameter could be GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc.
*/
void addShader (const char* const shaderSourceCode, GLenum shaderType);


Loading…
Cancel
Save