mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
New classes: OpenGLTexture, OpenGLFrameBuffer, OpenGLHelpers.
This commit is contained in:
parent
6b94c7598d
commit
74df644356
30 changed files with 1089 additions and 209 deletions
|
|
@ -859,7 +859,13 @@
|
|||
55AFFB566D49AABFA9C0EE6C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
FE8A9052DF38CAA1BCEE9589 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLComponent.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
1763C4B21169FE19DCB32BBD = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLContext.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLContext.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
F48B07E649829B7DD1B30973 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLFrameBuffer.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
A3DBAB79ACA02B91073A455E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLFrameBuffer.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
41759B5EE970815764327159 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLHelpers.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
92B6936D8E84EAA3D0A7991E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLHelpers.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
E71DA1FF4A1EC5392D753995 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLPixelFormat.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
CC06C483804C31304E6F5C63 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLTexture.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
0AB715CCB75AC3DA98E10E74 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLTexture.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
E4EEF3C8CDB9A7997EF0A71C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_android_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_android_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
60CD67623F8F48E5169CDC3C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_ios_OpenGLComponent.mm"; path = "../../../../modules/juce_opengl/native/juce_ios_OpenGLComponent.mm"; sourceTree = "SOURCE_ROOT"; };
|
||||
6B7A8DD046F87B9E64B36FB0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
|
|
@ -1858,7 +1864,13 @@
|
|||
55AFFB566D49AABFA9C0EE6C,
|
||||
FE8A9052DF38CAA1BCEE9589,
|
||||
1763C4B21169FE19DCB32BBD,
|
||||
E71DA1FF4A1EC5392D753995 ); name = opengl; sourceTree = "<group>"; };
|
||||
F48B07E649829B7DD1B30973,
|
||||
A3DBAB79ACA02B91073A455E,
|
||||
41759B5EE970815764327159,
|
||||
92B6936D8E84EAA3D0A7991E,
|
||||
E71DA1FF4A1EC5392D753995,
|
||||
CC06C483804C31304E6F5C63,
|
||||
0AB715CCB75AC3DA98E10E74 ); name = opengl; sourceTree = "<group>"; };
|
||||
8BACFE9F54494195BA7FF7D8 = { isa = PBXGroup; children = (
|
||||
E4EEF3C8CDB9A7997EF0A71C,
|
||||
60CD67623F8F48E5169CDC3C,
|
||||
|
|
|
|||
|
|
@ -4218,7 +4218,40 @@
|
|||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
</Filter>
|
||||
<Filter Name="native">
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
|
|
|
|||
|
|
@ -4218,7 +4218,40 @@
|
|||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
</Filter>
|
||||
<Filter Name="native">
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
|
|
|
|||
|
|
@ -1133,6 +1133,15 @@
|
|||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
|
@ -1566,7 +1575,10 @@
|
|||
<ClInclude Include="..\..\..\..\modules\juce_gui_extra\juce_gui_extra.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\juce_opengl.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_video\playback\juce_DirectShowComponent.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_video\playback\juce_QuickTimeMovieComponent.h"/>
|
||||
|
|
|
|||
|
|
@ -1489,6 +1489,15 @@
|
|||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\native</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -2760,9 +2769,18 @@
|
|||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\juce_opengl.h">
|
||||
<Filter>Juce Modules\juce_opengl</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
|
|
@ -849,7 +849,13 @@
|
|||
55AFFB566D49AABFA9C0EE6C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
FE8A9052DF38CAA1BCEE9589 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLComponent.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
1763C4B21169FE19DCB32BBD = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLContext.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLContext.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
F48B07E649829B7DD1B30973 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLFrameBuffer.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
A3DBAB79ACA02B91073A455E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLFrameBuffer.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
41759B5EE970815764327159 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLHelpers.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
92B6936D8E84EAA3D0A7991E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLHelpers.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
E71DA1FF4A1EC5392D753995 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLPixelFormat.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
CC06C483804C31304E6F5C63 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLTexture.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
0AB715CCB75AC3DA98E10E74 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLTexture.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
E4EEF3C8CDB9A7997EF0A71C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_android_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_android_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
60CD67623F8F48E5169CDC3C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_ios_OpenGLComponent.mm"; path = "../../../../modules/juce_opengl/native/juce_ios_OpenGLComponent.mm"; sourceTree = "SOURCE_ROOT"; };
|
||||
6B7A8DD046F87B9E64B36FB0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
|
|
@ -1848,7 +1854,13 @@
|
|||
55AFFB566D49AABFA9C0EE6C,
|
||||
FE8A9052DF38CAA1BCEE9589,
|
||||
1763C4B21169FE19DCB32BBD,
|
||||
E71DA1FF4A1EC5392D753995 ); name = opengl; sourceTree = "<group>"; };
|
||||
F48B07E649829B7DD1B30973,
|
||||
A3DBAB79ACA02B91073A455E,
|
||||
41759B5EE970815764327159,
|
||||
92B6936D8E84EAA3D0A7991E,
|
||||
E71DA1FF4A1EC5392D753995,
|
||||
CC06C483804C31304E6F5C63,
|
||||
0AB715CCB75AC3DA98E10E74 ); name = opengl; sourceTree = "<group>"; };
|
||||
8BACFE9F54494195BA7FF7D8 = { isa = PBXGroup; children = (
|
||||
E4EEF3C8CDB9A7997EF0A71C,
|
||||
60CD67623F8F48E5169CDC3C,
|
||||
|
|
|
|||
|
|
@ -27,150 +27,6 @@
|
|||
|
||||
#if JUCE_OPENGL
|
||||
|
||||
//==============================================================================
|
||||
// Simple wrapper for an openGL texture..
|
||||
class OpenGLTexture
|
||||
{
|
||||
public:
|
||||
OpenGLTexture()
|
||||
: textureID (0), width (0), height (0)
|
||||
{
|
||||
}
|
||||
|
||||
~OpenGLTexture()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void load (const Image& image)
|
||||
{
|
||||
release();
|
||||
|
||||
width = image.getWidth();
|
||||
height = image.getHeight();
|
||||
|
||||
jassert (BitArray (width).countNumberOfSetBits() == 1); // these dimensions must be a power-of-two
|
||||
jassert (BitArray (height).countNumberOfSetBits() == 1);
|
||||
|
||||
glGenTextures (1, &textureID);
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#if ! JUCE_OPENGL_ES
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
#endif
|
||||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
Image::BitmapData srcData (image, Image::BitmapData::readOnly);
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, internalFormat,
|
||||
width, height, 0,
|
||||
image.getFormat() == Image::RGB ? GL_RGB : GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE, srcData.data);
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
if (textureID != 0)
|
||||
{
|
||||
glDeleteTextures (1, &textureID);
|
||||
textureID = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void bind() const
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
}
|
||||
|
||||
void draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
float alpha) const
|
||||
{
|
||||
bind();
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alpha);
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
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 };
|
||||
|
||||
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);
|
||||
|
||||
#else
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2i (0, 0); glVertex2f (x1, y1);
|
||||
glTexCoord2i (1, 0); glVertex2f (x2, y2);
|
||||
glTexCoord2i (1, 1); glVertex2f (x3, y3);
|
||||
glTexCoord2i (0, 1); glVertex2f (x4, y4);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
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,
|
||||
float alpha) const
|
||||
{
|
||||
bind();
|
||||
glColor4f (1.0f, 1.0f, 1.0f, alpha);
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
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 };
|
||||
|
||||
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);
|
||||
|
||||
#else
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2i (0, 0); glVertex3f (x1, y1, z1);
|
||||
glTexCoord2i (1, 0); glVertex3f (x2, y2, z2);
|
||||
glTexCoord2i (1, 1); glVertex3f (x3, y3, z3);
|
||||
glTexCoord2i (0, 1); glVertex3f (x4, y4, z4);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
GLuint textureID;
|
||||
int width, height;
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
enum { internalFormat = GL_RGBA };
|
||||
#else
|
||||
enum { internalFormat = 4 };
|
||||
#endif
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLTexture);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class DemoOpenGLCanvas : public OpenGLComponent,
|
||||
public Timer
|
||||
|
|
@ -239,28 +95,22 @@ public:
|
|||
|
||||
void renderOpenGL()
|
||||
{
|
||||
glClearColor (0.25f, 0.25f, 0.25f, 0.0f);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
OpenGLHelpers::clear (Colours::darkgrey.withAlpha (0.0f));
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
OpenGLHelpers::clear (Colours::darkblue);
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
glOrthof (0.0f, (float) getWidth(), 0.0f, (float) getHeight(), 0.0f, 1.0f);
|
||||
#else
|
||||
glOrtho (0.0, getWidth(), 0.0, getHeight(), 0, 1);
|
||||
#endif
|
||||
OpenGLHelpers::prepareFor2D (getWidth(), getHeight());
|
||||
|
||||
texture1.draw2D (50.0f, getHeight() - 50.0f,
|
||||
getWidth() - 50.0f, getHeight() - 50.0f,
|
||||
getWidth() - 50.0f, 50.0f,
|
||||
50.0f, 50.0f,
|
||||
fabsf (::sinf (rotation / 100.0f)));
|
||||
Colours::white.withAlpha (fabsf (::sinf (rotation / 100.0f))));
|
||||
|
||||
glLoadIdentity();
|
||||
glClear (GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
setPerspective (45.0, getWidth() / (double) getHeight(), 0.1, 100.0);
|
||||
OpenGLHelpers::setPerspective (45.0, getWidth() / (double) getHeight(), 0.1, 100.0);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
|
||||
|
|
@ -269,12 +119,12 @@ public:
|
|||
glRotatef (rotation, 0.5f, 1.0f, 0.0f);
|
||||
|
||||
// this draws the sides of our spinning cube..
|
||||
texture1.draw3D (-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f);
|
||||
texture1.draw3D (-1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
|
||||
texture1.draw3D (-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f);
|
||||
texture2.draw3D (-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f);
|
||||
texture2.draw3D ( 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f);
|
||||
texture2.draw3D (-1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f);
|
||||
texture1.draw3D (-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, Colours::white);
|
||||
texture1.draw3D (-1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, Colours::white);
|
||||
texture1.draw3D (-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, Colours::white);
|
||||
texture2.draw3D (-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, Colours::white);
|
||||
texture2.draw3D ( 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, Colours::white);
|
||||
texture2.draw3D (-1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, Colours::white);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
@ -289,19 +139,6 @@ private:
|
|||
OpenGLTexture texture1, texture2;
|
||||
float rotation, delta;
|
||||
|
||||
// Utility function to do the same job as gluPerspective()
|
||||
static void setPerspective (double fovy, double aspect, double zNear, double zFar)
|
||||
{
|
||||
const double ymax = zNear * tan (fovy * double_Pi / 360.0);
|
||||
const double ymin = -ymax;
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
glFrustumf (ymin * aspect, ymax * aspect, ymin, ymax, zNear, zFar);
|
||||
#else
|
||||
glFrustum (ymin * aspect, ymax * aspect, ymin, ymax, zNear, zFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Functions to create a couple of images to use as textures..
|
||||
static Image createImage1()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -815,7 +815,13 @@
|
|||
573948B87BEE9ED7C0D61B96 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
0014FEC4EECDBEC9D3E4D2C3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLComponent.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
290C12242FFEE231F3B968F7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLContext.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLContext.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
F625545847178F96F8C936AD = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLFrameBuffer.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
B574F9EBAA451FBA2E307398 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLFrameBuffer.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
520FE9C0E815757F8B38BF92 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLHelpers.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
A44FE0DF9D19DECBF7ADC758 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLHelpers.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
F9A70E6158B3B951458B77CF = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLPixelFormat.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
DE9F11F59FD12558656599AD = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLTexture.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
0C41623EC5EFB7F2BFF74CBE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLTexture.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
E677413ACC5E9BB29507E456 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_android_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_android_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
7256B5C43E143C0D3E921975 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_ios_OpenGLComponent.mm"; path = "../../../../modules/juce_opengl/native/juce_ios_OpenGLComponent.mm"; sourceTree = "SOURCE_ROOT"; };
|
||||
7D03DA42549D5FB78BC99DF9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
|
|
@ -1780,7 +1786,13 @@
|
|||
573948B87BEE9ED7C0D61B96,
|
||||
0014FEC4EECDBEC9D3E4D2C3,
|
||||
290C12242FFEE231F3B968F7,
|
||||
F9A70E6158B3B951458B77CF ); name = opengl; sourceTree = "<group>"; };
|
||||
F625545847178F96F8C936AD,
|
||||
B574F9EBAA451FBA2E307398,
|
||||
520FE9C0E815757F8B38BF92,
|
||||
A44FE0DF9D19DECBF7ADC758,
|
||||
F9A70E6158B3B951458B77CF,
|
||||
DE9F11F59FD12558656599AD,
|
||||
0C41623EC5EFB7F2BFF74CBE ); name = opengl; sourceTree = "<group>"; };
|
||||
9D364C0153DE35BED2852412 = { isa = PBXGroup; children = (
|
||||
E677413ACC5E9BB29507E456,
|
||||
7256B5C43E143C0D3E921975,
|
||||
|
|
|
|||
|
|
@ -4141,7 +4141,40 @@
|
|||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
</Filter>
|
||||
<Filter Name="native">
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
|
|
|
|||
|
|
@ -4141,7 +4141,40 @@
|
|||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
</Filter>
|
||||
<Filter Name="native">
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
|
|
|
|||
|
|
@ -759,7 +759,13 @@
|
|||
A732DC02BBE986BF0765764F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
501C821E2ED9A6A109832D6D = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLComponent.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLComponent.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
78F5A67F6FF9DA192A58B4A1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLContext.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLContext.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
461DF8939713777D3F589257 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLFrameBuffer.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
056D9D36FA40179155DFCE42 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLFrameBuffer.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
A2F87D1B38117D57C2C70A4C = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLHelpers.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
E4387419DD15C5A32E3C2202 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLHelpers.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLHelpers.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
399093BB98BFB1397B1AC279 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLPixelFormat.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLPixelFormat.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
1E88B530DFED2D30AC04E457 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_OpenGLTexture.cpp"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
5C39068905EBBFDAE5869767 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_OpenGLTexture.h"; path = "../../../../modules/juce_opengl/opengl/juce_OpenGLTexture.h"; sourceTree = "SOURCE_ROOT"; };
|
||||
3660D5851C5A8399CC96300F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_android_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_android_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
C24F591E8E2034E56431652F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = "juce_ios_OpenGLComponent.mm"; path = "../../../../modules/juce_opengl/native/juce_ios_OpenGLComponent.mm"; sourceTree = "SOURCE_ROOT"; };
|
||||
CDFC7E9C9499579EC158E8A3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_OpenGLComponent.cpp"; path = "../../../../modules/juce_opengl/native/juce_linux_OpenGLComponent.cpp"; sourceTree = "SOURCE_ROOT"; };
|
||||
|
|
@ -1699,7 +1705,13 @@
|
|||
A732DC02BBE986BF0765764F,
|
||||
501C821E2ED9A6A109832D6D,
|
||||
78F5A67F6FF9DA192A58B4A1,
|
||||
399093BB98BFB1397B1AC279 ); name = opengl; sourceTree = "<group>"; };
|
||||
461DF8939713777D3F589257,
|
||||
056D9D36FA40179155DFCE42,
|
||||
A2F87D1B38117D57C2C70A4C,
|
||||
E4387419DD15C5A32E3C2202,
|
||||
399093BB98BFB1397B1AC279,
|
||||
1E88B530DFED2D30AC04E457,
|
||||
5C39068905EBBFDAE5869767 ); name = opengl; sourceTree = "<group>"; };
|
||||
ED2ED05BA2DA3D95081470CB = { isa = PBXGroup; children = (
|
||||
3660D5851C5A8399CC96300F,
|
||||
C24F591E8E2034E56431652F,
|
||||
|
|
|
|||
|
|
@ -4032,7 +4032,40 @@
|
|||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<FileConfiguration Name="Debug|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration Name="Release|Win32"
|
||||
ExcludedFromBuild="true">
|
||||
<Tool Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
</Filter>
|
||||
<Filter Name="native">
|
||||
<File RelativePath="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
|
|
|
|||
|
|
@ -1096,6 +1096,15 @@
|
|||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
|
@ -1512,7 +1521,10 @@
|
|||
<ClInclude Include="..\..\..\..\modules\juce_gui_extra\juce_gui_extra.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\juce_opengl.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_video\playback\juce_DirectShowComponent.h"/>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_video\playback\juce_QuickTimeMovieComponent.h"/>
|
||||
|
|
|
|||
|
|
@ -1375,6 +1375,15 @@
|
|||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLComponent.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\..\modules\juce_opengl\native\juce_android_OpenGLComponent.cpp">
|
||||
<Filter>Juce Modules\juce_opengl\native</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -2595,9 +2604,18 @@
|
|||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLContext.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLFrameBuffer.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLHelpers.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLPixelFormat.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\opengl\juce_OpenGLTexture.h">
|
||||
<Filter>Juce Modules\juce_opengl\opengl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\..\modules\juce_opengl\juce_opengl.h">
|
||||
<Filter>Juce Modules\juce_opengl</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
#if JucePlugin_Build_AU
|
||||
|
||||
#if JUCE_64BIT
|
||||
#if __LP64__
|
||||
#undef JUCE_SUPPORT_CARBON
|
||||
#define JUCE_SUPPORT_CARBON 0
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ ReadWriteLock::ReadWriteLock() noexcept
|
|||
numWriters (0),
|
||||
writerThreadId (0)
|
||||
{
|
||||
readerThreads.ensureStorageAllocated (16);
|
||||
}
|
||||
|
||||
ReadWriteLock::~ReadWriteLock() noexcept
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@
|
|||
//==============================================================================
|
||||
// START_AUTOINCLUDE opengl/*.cpp
|
||||
#include "opengl/juce_OpenGLComponent.cpp"
|
||||
#include "opengl/juce_OpenGLFrameBuffer.cpp"
|
||||
#include "opengl/juce_OpenGLHelpers.cpp"
|
||||
#include "opengl/juce_OpenGLTexture.cpp"
|
||||
// END_AUTOINCLUDE
|
||||
|
||||
using namespace juce;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
#define WINGDIAPI __declspec(dllimport)
|
||||
#define CLEAR_TEMP_WINGDIAPI 1
|
||||
#endif
|
||||
#include <gl/gl.h>
|
||||
#include <gl/GL.h>
|
||||
#ifdef CLEAR_TEMP_WINGDIAPI
|
||||
#undef WINGDIAPI
|
||||
#undef CLEAR_TEMP_WINGDIAPI
|
||||
|
|
@ -64,12 +64,21 @@
|
|||
#include <OpenGLES/ES1/glext.h>
|
||||
#elif JUCE_MAC
|
||||
#include <OpenGL/gl.h>
|
||||
#include "OpenGL/glext.h"
|
||||
#endif
|
||||
|
||||
#ifndef GL_BGRA_EXT
|
||||
#define GL_BGRA_EXT 0x80e1
|
||||
#endif
|
||||
|
||||
#ifndef GL_CLAMP_TO_EDGE
|
||||
#define GL_CLAMP_TO_EDGE 0x812f
|
||||
#endif
|
||||
|
||||
#ifndef GL_DEPTH_COMPONENT16
|
||||
#define GL_DEPTH_COMPONENT16 0x81a5
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
|
@ -80,9 +89,18 @@ BEGIN_JUCE_NAMESPACE
|
|||
#ifndef __JUCE_OPENGLCONTEXT_JUCEHEADER__
|
||||
#include "opengl/juce_OpenGLContext.h"
|
||||
#endif
|
||||
#ifndef __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
|
||||
#include "opengl/juce_OpenGLFrameBuffer.h"
|
||||
#endif
|
||||
#ifndef __JUCE_OPENGLHELPERS_JUCEHEADER__
|
||||
#include "opengl/juce_OpenGLHelpers.h"
|
||||
#endif
|
||||
#ifndef __JUCE_OPENGLPIXELFORMAT_JUCEHEADER__
|
||||
#include "opengl/juce_OpenGLPixelFormat.h"
|
||||
#endif
|
||||
#ifndef __JUCE_OPENGLTEXTURE_JUCEHEADER__
|
||||
#include "opengl/juce_OpenGLTexture.h"
|
||||
#endif
|
||||
// END_AUTOINCLUDE
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -34,11 +34,6 @@ void* OpenGLComponent::getNativeWindowHandle() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void juce_glViewport (const int w, const int h)
|
||||
{
|
||||
// glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* component,
|
||||
OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -234,8 +234,3 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/,
|
|||
OwnedArray <OpenGLPixelFormat>& /*results*/)
|
||||
{
|
||||
}
|
||||
|
||||
void juce_glViewport (const int w, const int h)
|
||||
{
|
||||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,11 +196,6 @@ OpenGLContext* OpenGLComponent::createContext()
|
|||
return (c->renderContext != 0) ? c.release() : nullptr;
|
||||
}
|
||||
|
||||
void juce_glViewport (const int w, const int h)
|
||||
{
|
||||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* component, OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
results.add (new OpenGLPixelFormat()); // xxx
|
||||
|
|
|
|||
|
|
@ -271,11 +271,6 @@ void* OpenGLComponent::getNativeWindowHandle() const
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
void juce_glViewport (const int w, const int h)
|
||||
{
|
||||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
static int getPixelFormatAttribute (NSOpenGLPixelFormat* p, NSOpenGLPixelFormatAttribute att)
|
||||
{
|
||||
GLint val = 0;
|
||||
|
|
|
|||
|
|
@ -498,11 +498,6 @@ void* OpenGLComponent::getNativeWindowHandle() const
|
|||
return context != nullptr ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle() : nullptr;
|
||||
}
|
||||
|
||||
void juce_glViewport (const int w, const int h)
|
||||
{
|
||||
glViewport (0, 0, w, h);
|
||||
}
|
||||
|
||||
void OpenGLPixelFormat::getAvailablePixelFormats (Component* component,
|
||||
OwnedArray <OpenGLPixelFormat>& results)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
//==============================================================================
|
||||
extern void juce_glViewport (const int w, const int h);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
OpenGLPixelFormat::OpenGLPixelFormat (const int bitsPerRGBComponent,
|
||||
|
|
@ -425,7 +422,7 @@ bool OpenGLComponent::renderAndSwapBuffers()
|
|||
if (needToUpdateViewport)
|
||||
{
|
||||
needToUpdateViewport = false;
|
||||
juce_glViewport (getWidth(), getHeight());
|
||||
glViewport (0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
renderOpenGL();
|
||||
|
|
|
|||
313
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
Normal file
313
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
enum
|
||||
{
|
||||
GL_FRAMEBUFFER_EXT = 0x8D40,
|
||||
GL_RENDERBUFFER_EXT = 0x8D41,
|
||||
GL_COLOR_ATTACHMENT0_EXT = 0x8CE0,
|
||||
GL_DEPTH_ATTACHMENT_EXT = 0x8D00,
|
||||
GL_STENCIL_ATTACHMENT_EXT = 0x8D20,
|
||||
GL_FRAMEBUFFER_COMPLETE_EXT = 0x8CD5,
|
||||
GL_DEPTH24_STENCIL8_EXT = 0x88F0,
|
||||
GL_RENDERBUFFER_DEPTH_SIZE_EXT = 0x8D54
|
||||
};
|
||||
#endif
|
||||
|
||||
#if JUCE_WINDOWS || JUCE_LINUX
|
||||
|
||||
#define FRAMEBUFFER_FUNCTION_LIST(USE_FUNCTION) \
|
||||
USE_FUNCTION (glIsRenderbufferEXT, GLboolean, (GLuint renderbuffer))\
|
||||
USE_FUNCTION (glBindRenderbufferEXT, void, (GLenum target, GLuint renderbuffer))\
|
||||
USE_FUNCTION (glDeleteRenderbuffersEXT, void, (GLsizei n, const GLuint *renderbuffers))\
|
||||
USE_FUNCTION (glGenRenderbuffersEXT, void, (GLsizei n, GLuint *renderbuffers))\
|
||||
USE_FUNCTION (glRenderbufferStorageEXT, void, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height))\
|
||||
USE_FUNCTION (glGetRenderbufferParameterivEXT, void, (GLenum target, GLenum pname, GLint* params))\
|
||||
USE_FUNCTION (glIsFramebufferEXT, GLboolean, (GLuint framebuffer))\
|
||||
USE_FUNCTION (glBindFramebufferEXT, void, (GLenum target, GLuint framebuffer))\
|
||||
USE_FUNCTION (glDeleteFramebuffersEXT, void, (GLsizei n, const GLuint *framebuffers))\
|
||||
USE_FUNCTION (glGenFramebuffersEXT, void, (GLsizei n, GLuint *framebuffers))\
|
||||
USE_FUNCTION (glCheckFramebufferStatusEXT, GLenum, (GLenum target))\
|
||||
USE_FUNCTION (glFramebufferTexture1DEXT, void, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))\
|
||||
USE_FUNCTION (glFramebufferTexture2DEXT, void, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))\
|
||||
USE_FUNCTION (glFramebufferTexture3DEXT, void, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset))\
|
||||
USE_FUNCTION (glFramebufferRenderbufferEXT, void, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer))\
|
||||
USE_FUNCTION (glGetFramebufferAttachmentParameterivEXT, void, (GLenum target, GLenum attachment, GLenum pname, GLint *params))\
|
||||
USE_FUNCTION (glGenerateMipmapEXT, void, (GLenum target))\
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
#define APICALLTYPE __stdcall
|
||||
#else
|
||||
#define APICALLTYPE
|
||||
#endif
|
||||
|
||||
#define DECLARE_FUNCTION(name, returnType, params) \
|
||||
typedef returnType (APICALLTYPE * type_ ## name) params; static type_ ## name name;
|
||||
FRAMEBUFFER_FUNCTION_LIST (DECLARE_FUNCTION)
|
||||
#undef DECLARE_FUNCTION
|
||||
|
||||
static bool framebufferFunctionsInitialised = false;
|
||||
|
||||
static void initialiseFrameBufferFunctions()
|
||||
{
|
||||
if (! framebufferFunctionsInitialised)
|
||||
{
|
||||
framebufferFunctionsInitialised = true;
|
||||
|
||||
#if JUCE_LINUX
|
||||
#define lookUpFunction(name) glXGetProcAddress ((const GLubyte*) name)
|
||||
#else
|
||||
#define lookUpFunction(name) wglGetProcAddress (name)
|
||||
#endif
|
||||
|
||||
#define FIND_FUNCTION(name, returnType, params) name = (type_ ## name) lookUpFunction (#name);
|
||||
FRAMEBUFFER_FUNCTION_LIST (FIND_FUNCTION)
|
||||
#undef FIND_FUNCTION
|
||||
}
|
||||
}
|
||||
|
||||
#undef FRAMEBUFFER_FUNCTION_LIST
|
||||
|
||||
//==============================================================================
|
||||
#elif JUCE_OPENGL_ES
|
||||
|
||||
#define glIsRenderbufferEXT glIsRenderbufferOES
|
||||
#define glBindRenderbufferEXT glBindRenderbufferOES
|
||||
#define glDeleteRenderbuffersEXT glDeleteRenderbuffersOES
|
||||
#define glGenRenderbuffersEXT glGenRenderbuffersOES
|
||||
#define glRenderbufferStorageEXT glRenderbufferStorageOES
|
||||
#define glGetRenderbufferParameterivEXT glGetRenderbufferParameterivOES
|
||||
#define glIsFramebufferEXT glIsFramebufferOES
|
||||
#define glBindFramebufferEXT glBindFramebufferOES
|
||||
#define glDeleteFramebuffersEXT glDeleteFramebuffersOES
|
||||
#define glGenFramebuffersEXT glGenFramebuffersOES
|
||||
#define glCheckFramebufferStatusEXT glCheckFramebufferStatusOES
|
||||
#define glFramebufferTexture1DEXT glFramebufferTexture1DOES
|
||||
#define glFramebufferTexture2DEXT glFramebufferTexture2DOES
|
||||
#define glFramebufferTexture3DEXT glFramebufferTexture3DOES
|
||||
#define glFramebufferRenderbufferEXT glFramebufferRenderbufferOES
|
||||
#define glGetFramebufferAttachmentParameterivEXT glGetFramebufferAttachmentParameterivOES
|
||||
#define glGenerateMipmapEXT glGenerateMipmapOES
|
||||
|
||||
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
|
||||
#define GL_RGBA8 GL_RGBA
|
||||
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0_OES
|
||||
#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES
|
||||
#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES
|
||||
#define GL_RENDERBUFFER_DEPTH_SIZE_EXT GL_RENDERBUFFER_DEPTH_SIZE_OES
|
||||
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT_OES
|
||||
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_OES
|
||||
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE_OES
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT GL_FRAMEBUFFER_UNSUPPORTED_OES
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
class OpenGLFrameBuffer::Pimpl
|
||||
{
|
||||
public:
|
||||
Pimpl (const int width_, const int height_,
|
||||
const bool wantsDepthBuffer, const bool wantsStencilBuffer,
|
||||
const GLenum textureType = GL_TEXTURE_2D)
|
||||
: width (width_),
|
||||
height (height_),
|
||||
textureID (0),
|
||||
frameBufferHandle (0),
|
||||
depthOrStencilBuffer (0),
|
||||
hasDepthBuffer (false),
|
||||
hasStencilBuffer (false),
|
||||
ok (false)
|
||||
{
|
||||
#if JUCE_WINDOWS || JUCE_LINUX
|
||||
initialiseFrameBufferFunctions();
|
||||
|
||||
if (glGenFramebuffersEXT == nullptr)
|
||||
return;
|
||||
#endif
|
||||
|
||||
resetGLErrorState();
|
||||
|
||||
glGenFramebuffersEXT (1, &frameBufferHandle);
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, frameBufferHandle);
|
||||
|
||||
glGenTextures (1, &textureID);
|
||||
glBindTexture (textureType, textureID);
|
||||
glTexImage2D (textureType, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
glTexParameterf (textureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf (textureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf (textureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf (textureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
textureType, textureID, 0);
|
||||
|
||||
if (wantsDepthBuffer || wantsStencilBuffer)
|
||||
{
|
||||
glGenRenderbuffersEXT (1, &depthOrStencilBuffer);
|
||||
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, depthOrStencilBuffer);
|
||||
jassert (glIsRenderbufferEXT (depthOrStencilBuffer));
|
||||
|
||||
if (wantsDepthBuffer && wantsStencilBuffer)
|
||||
{
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);
|
||||
|
||||
GLint params = 0;
|
||||
glGetRenderbufferParameterivEXT (GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, ¶ms);
|
||||
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthOrStencilBuffer);
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthOrStencilBuffer);
|
||||
|
||||
hasDepthBuffer = true;
|
||||
hasStencilBuffer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if JUCE_OPENGL_ES
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height);
|
||||
#else
|
||||
glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height);
|
||||
#endif
|
||||
|
||||
GLint params = 0;
|
||||
glGetRenderbufferParameterivEXT (GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, ¶ms);
|
||||
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthOrStencilBuffer);
|
||||
|
||||
hasDepthBuffer = true;
|
||||
}
|
||||
}
|
||||
|
||||
ok = checkStatus();
|
||||
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
~Pimpl()
|
||||
{
|
||||
if (textureID != 0)
|
||||
glDeleteTextures (1, &textureID);
|
||||
|
||||
if (depthOrStencilBuffer != 0)
|
||||
glDeleteRenderbuffersEXT (1, &depthOrStencilBuffer);
|
||||
|
||||
if (frameBufferHandle != 0)
|
||||
glDeleteFramebuffersEXT (1, &frameBufferHandle);
|
||||
}
|
||||
|
||||
bool bind() { return bind (frameBufferHandle); }
|
||||
bool unbind() { return bind (0); }
|
||||
|
||||
/*Image createImage()
|
||||
{
|
||||
Image im;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
bind();
|
||||
|
||||
im = Image (Image::ARGB, width, height, true);
|
||||
Image::BitmapData data (im, Image::BitmapData::writeOnly);
|
||||
|
||||
glReadPixels (0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data.data);
|
||||
|
||||
unbind();
|
||||
}
|
||||
|
||||
return im;
|
||||
}*/
|
||||
|
||||
const int width, height;
|
||||
GLuint textureID, frameBufferHandle, depthOrStencilBuffer;
|
||||
bool hasDepthBuffer, hasStencilBuffer, ok;
|
||||
|
||||
private:
|
||||
bool bind (GLuint buffer)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, buffer);
|
||||
ok = checkStatus();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool checkStatus() noexcept
|
||||
{
|
||||
const GLenum status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
|
||||
|
||||
return status == GL_NO_ERROR
|
||||
|| status == GL_FRAMEBUFFER_COMPLETE_EXT;
|
||||
}
|
||||
|
||||
static void resetGLErrorState()
|
||||
{
|
||||
while (glGetError() != GL_NO_ERROR) {}
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (Pimpl);
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
OpenGLFrameBuffer::OpenGLFrameBuffer() {}
|
||||
OpenGLFrameBuffer::~OpenGLFrameBuffer() {}
|
||||
|
||||
bool OpenGLFrameBuffer::initialise (int width, int height)
|
||||
{
|
||||
release();
|
||||
pimpl = new Pimpl (width, height, true, false);
|
||||
|
||||
if (! pimpl->ok)
|
||||
pimpl = nullptr;
|
||||
|
||||
return pimpl != nullptr;
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::release()
|
||||
{
|
||||
pimpl = nullptr;
|
||||
}
|
||||
|
||||
int OpenGLFrameBuffer::getWidth() const noexcept { return pimpl != nullptr ? pimpl->width : 0; }
|
||||
int OpenGLFrameBuffer::getHeight() const noexcept { return pimpl != nullptr ? pimpl->height : 0; }
|
||||
GLuint OpenGLFrameBuffer::getTextureID() const noexcept { return pimpl != nullptr ? pimpl->textureID : 0; }
|
||||
|
||||
void OpenGLFrameBuffer::makeCurrentTarget()
|
||||
{
|
||||
if (pimpl != nullptr)
|
||||
pimpl->bind();
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::releaseCurrentTarget()
|
||||
{
|
||||
if (pimpl != nullptr)
|
||||
pimpl->unbind();
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
83
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h
Normal file
83
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
|
||||
#define __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Creates an openGL frame buffer.
|
||||
*/
|
||||
class JUCE_API OpenGLFrameBuffer
|
||||
{
|
||||
public:
|
||||
/** Creates an uninitialised buffer.
|
||||
To actually allocate the buffer, use initialise().
|
||||
*/
|
||||
OpenGLFrameBuffer();
|
||||
|
||||
/** Destructor. */
|
||||
~OpenGLFrameBuffer();
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to allocates a buffer of the given size.
|
||||
Note that a valid openGL context must be selected when you call this method,
|
||||
or it will fail.
|
||||
*/
|
||||
bool initialise (int width, int height);
|
||||
|
||||
/** Releases the buffer, if one has been allocated. */
|
||||
void release();
|
||||
|
||||
/** Returns true if a valid buffer has been allocated. */
|
||||
bool isValid() const noexcept { return pimpl != nullptr; }
|
||||
|
||||
/** Returns the width of the buffer. */
|
||||
int getWidth() const noexcept;
|
||||
|
||||
/** Returns the height of the buffer. */
|
||||
int getHeight() const noexcept;
|
||||
|
||||
/** Returns the texture ID number for using this buffer as a texture. */
|
||||
unsigned int getTextureID() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Selects this buffer as the current OpenGL rendering target. */
|
||||
void makeCurrentTarget();
|
||||
|
||||
/** Deselects this buffer as the current OpenGL rendering target. */
|
||||
void releaseCurrentTarget();
|
||||
|
||||
private:
|
||||
class Pimpl;
|
||||
friend class ScopedPointer<Pimpl>;
|
||||
ScopedPointer<Pimpl> pimpl;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLFrameBuffer);
|
||||
};
|
||||
|
||||
|
||||
#endif // __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
|
||||
128
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp
Normal file
128
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
void OpenGLHelpers::clear (const Colour& colour)
|
||||
{
|
||||
glClearColor (colour.getFloatRed(), colour.getFloatGreen(),
|
||||
colour.getFloatBlue(), colour.getFloatAlpha());
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void OpenGLHelpers::prepareFor2D (int width, int height)
|
||||
{
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
glOrthof (0.0f, (float) width, 0.0f, (float) height, 0.0f, 1.0f);
|
||||
#else
|
||||
glOrtho (0.0, width, 0.0, height, 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLHelpers::setPerspective (double fovy, double aspect, double zNear, double zFar)
|
||||
{
|
||||
const double ymax = zNear * tan (fovy * double_Pi / 360.0);
|
||||
const double ymin = -ymax;
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
glFrustumf (ymin * aspect, ymax * aspect, ymin, ymax, zNear, zFar);
|
||||
#else
|
||||
glFrustum (ymin * aspect, ymax * aspect, ymin, ymax, zNear, zFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLHelpers::drawQuad2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
const Colour& colour)
|
||||
{
|
||||
glColor4f (colour.getFloatRed(), colour.getFloatGreen(),
|
||||
colour.getFloatBlue(), colour.getFloatAlpha());
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
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 };
|
||||
|
||||
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);
|
||||
|
||||
#else
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2i (0, 0); glVertex2f (x1, y1);
|
||||
glTexCoord2i (1, 0); glVertex2f (x2, y2);
|
||||
glTexCoord2i (1, 1); glVertex2f (x3, y3);
|
||||
glTexCoord2i (0, 1); glVertex2f (x4, y4);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
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,
|
||||
const Colour& colour)
|
||||
{
|
||||
glColor4f (colour.getFloatRed(), colour.getFloatGreen(),
|
||||
colour.getFloatBlue(), colour.getFloatAlpha());
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
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 };
|
||||
|
||||
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);
|
||||
|
||||
#else
|
||||
glBegin (GL_QUADS);
|
||||
glTexCoord2i (0, 0); glVertex3f (x1, y1, z1);
|
||||
glTexCoord2i (1, 0); glVertex3f (x2, y2, z2);
|
||||
glTexCoord2i (1, 1); glVertex3f (x3, y3, z3);
|
||||
glTexCoord2i (0, 1); glVertex3f (x4, y4, z4);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
60
modules/juce_opengl/opengl/juce_OpenGLHelpers.h
Normal file
60
modules/juce_opengl/opengl/juce_OpenGLHelpers.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_OPENGLHELPERS_JUCEHEADER__
|
||||
#define __JUCE_OPENGLHELPERS_JUCEHEADER__
|
||||
|
||||
/**
|
||||
A set of miscellaneous openGL helper functions.
|
||||
*/
|
||||
class JUCE_API OpenGLHelpers
|
||||
{
|
||||
public:
|
||||
/** Clears the current context using the given colour. */
|
||||
static void clear (const 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);
|
||||
|
||||
/** 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,
|
||||
const 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,
|
||||
const Colour& colour);
|
||||
};
|
||||
|
||||
|
||||
#endif // __JUCE_OPENGLHELPERS_JUCEHEADER__
|
||||
118
modules/juce_opengl/opengl/juce_OpenGLTexture.cpp
Normal file
118
modules/juce_opengl/opengl/juce_OpenGLTexture.cpp
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
OpenGLTexture::OpenGLTexture()
|
||||
: textureID (0), width (0), height (0)
|
||||
{
|
||||
}
|
||||
|
||||
OpenGLTexture::~OpenGLTexture()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
void OpenGLTexture::load (const Image& image)
|
||||
{
|
||||
release();
|
||||
|
||||
width = image.getWidth();
|
||||
height = image.getHeight();
|
||||
|
||||
jassert (BitArray (width).countNumberOfSetBits() == 1); // these dimensions must be a power-of-two
|
||||
jassert (BitArray (height).countNumberOfSetBits() == 1);
|
||||
|
||||
glGenTextures (1, &textureID);
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
|
||||
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
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);
|
||||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
Image::BitmapData srcData (image, Image::BitmapData::readOnly);
|
||||
|
||||
#if JUCE_OPENGL_ES
|
||||
enum { internalFormat = GL_RGBA };
|
||||
#else
|
||||
enum { internalFormat = 4 };
|
||||
#endif
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, internalFormat,
|
||||
width, height, 0,
|
||||
image.getFormat() == Image::RGB ? GL_RGB : GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE, srcData.data);
|
||||
}
|
||||
|
||||
void OpenGLTexture::release()
|
||||
{
|
||||
if (textureID != 0)
|
||||
{
|
||||
glDeleteTextures (1, &textureID);
|
||||
textureID = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLTexture::bind() const
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
}
|
||||
|
||||
void OpenGLTexture::unbind() const
|
||||
{
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void OpenGLTexture::draw2D (float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4,
|
||||
const 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,
|
||||
const Colour& colour) const
|
||||
{
|
||||
bind();
|
||||
OpenGLHelpers::drawQuad3D (x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, colour);
|
||||
unbind();
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
73
modules/juce_opengl/opengl/juce_OpenGLTexture.h
Normal file
73
modules/juce_opengl/opengl/juce_OpenGLTexture.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-11 by Raw Material Software Ltd.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
JUCE can be redistributed and/or modified under the terms of the GNU General
|
||||
Public License (Version 2), as published by the Free Software Foundation.
|
||||
A copy of the license is included in the JUCE distribution, or can be found
|
||||
online at www.gnu.org/licenses.
|
||||
|
||||
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses JUCE, commercial licenses are
|
||||
available: visit www.rawmaterialsoftware.com/juce for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_OPENGLTEXTURE_JUCEHEADER__
|
||||
#define __JUCE_OPENGLTEXTURE_JUCEHEADER__
|
||||
|
||||
/**
|
||||
Creates an openGL texture from an Image.
|
||||
*/
|
||||
class JUCE_API OpenGLTexture
|
||||
{
|
||||
public:
|
||||
OpenGLTexture();
|
||||
~OpenGLTexture();
|
||||
|
||||
/** Creates a texture from the given image.
|
||||
Note that the image's width and height must both be a power-of-two.
|
||||
*/
|
||||
void load (const Image& image);
|
||||
|
||||
/** Frees the texture, if there is one. */
|
||||
void release();
|
||||
|
||||
/** Binds the texture to the currently selected openGL context. */
|
||||
void bind() const;
|
||||
|
||||
/** Unbinds the texture to the currently selected openGL context. */
|
||||
void unbind() const;
|
||||
|
||||
/** 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,
|
||||
const 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,
|
||||
const Colour& colour) const;
|
||||
|
||||
private:
|
||||
unsigned int textureID;
|
||||
int width, height;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLTexture);
|
||||
};
|
||||
|
||||
#endif // __JUCE_OPENGLTEXTURE_JUCEHEADER__
|
||||
Loading…
Add table
Add a link
Reference in a new issue