summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-19 08:39:40 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-19 08:39:40 (GMT)
commit928f902015a0ad97279ce6e2ac4cb85e5baed684 (patch)
treec3afd6f5b72b32136ab9d40788e1cf05d7b91763 /src/opengl
parent17d6f2a59fe2b170087cdf7074807c6a2dce1043 (diff)
parent5fb5c01bd0ac234eaca890d97053c7b0772861a3 (diff)
downloadQt-928f902015a0ad97279ce6e2ac4cb85e5baed684.zip
Qt-928f902015a0ad97279ce6e2ac4cb85e5baed684.tar.gz
Qt-928f902015a0ad97279ce6e2ac4cb85e5baed684.tar.bz2
Merge commit 'qt/master' into kinetic-graphicseffect
Conflicts: src/gui/graphicsview/qgraphicsitem_p.h
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
-rw-r--r--src/opengl/qgl.cpp10
-rw-r--r--src/opengl/qglcolormap.cpp2
-rw-r--r--src/opengl/qglframebufferobject.cpp6
-rw-r--r--src/opengl/qglpixelbuffer.cpp2
-rw-r--r--src/opengl/qglshaderprogram.cpp2
7 files changed, 42 insertions, 23 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index 842cac4..cf930f3 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -73,8 +73,8 @@ static const char* const qglslMainVertexShader = "\
}";
static const char* const qglslMainWithTexCoordsVertexShader = "\
- attribute lowp vec2 textureCoordArray; \
- varying lowp vec2 textureCoords; \
+ attribute mediump vec2 textureCoordArray; \
+ varying mediump vec2 textureCoords; \
uniform highp float depth;\
void setPosition();\
void main(void) \
@@ -284,7 +284,7 @@ static const char* const qglslSolidBrushSrcFragmentShader = "\
}";
static const char* const qglslImageSrcFragmentShader = "\
- varying highp vec2 textureCoords; \
+ varying mediump vec2 textureCoords; \
uniform sampler2D imageTexture; \
lowp vec4 srcPixel() { \
return texture2D(imageTexture, textureCoords); \
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index b415b13..c1e39a7 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -75,6 +75,7 @@
#include <private/qfontengine_p.h>
#include <private/qtextureglyphcache_p.h>
#include <private/qpixmapdata_gl_p.h>
+#include <private/qdatabuffer_p.h>
#include "qglgradientcache_p.h"
#include "qglengineshadermanager_p.h"
@@ -175,7 +176,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
m_height = height;
QVarLengthArray<uchar> data(width * height);
- for (int i = 0; i < width * height; ++i)
+ for (int i = 0; i < data.size(); ++i)
data[i] = 0;
if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
@@ -200,13 +201,18 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
- GLuint colorBuffer;
- glGenRenderbuffers(1, &colorBuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorBuffer);
- glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, oldWidth, oldHeight);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_RENDERBUFFER_EXT, colorBuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
+ GLuint tmp_texture;
+ glGenTextures(1, &tmp_texture);
+ glBindTexture(GL_TEXTURE_2D, tmp_texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, tmp_texture, 0);
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
glBindTexture(GL_TEXTURE_2D, oldTexture);
@@ -237,11 +243,24 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
glBindTexture(GL_TEXTURE_2D, m_texture);
+
+#ifdef QT_OPENGL_ES_2
+ QDataBuffer<uchar> buffer(4*oldWidth*oldHeight);
+ glReadPixels(0, 0, oldWidth, oldHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer.data());
+
+ // do an in-place conversion from GL_RGBA to GL_ALPHA
+ for (int i=0; i<oldWidth*oldHeight; ++i)
+ buffer.data()[i] = buffer.at(4*i + 3);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight,
+ GL_ALPHA, GL_UNSIGNED_BYTE, buffer.data());
+#else
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
+#endif
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, 0);
- glDeleteRenderbuffers(1, &colorBuffer);
+ glDeleteTextures(1, &tmp_texture);
glDeleteTextures(1, &oldTexture);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 67c02f2..e031fb5 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -147,7 +147,7 @@ QGLSignalProxy *QGLSignalProxy::instance()
\brief The QGL namespace specifies miscellaneous identifiers used
in the Qt OpenGL module.
- \ingroup multimedia
+ \ingroup painting-3D
*/
/*!
@@ -190,7 +190,7 @@ QGLSignalProxy *QGLSignalProxy::instance()
\brief The QGLFormat class specifies the display format of an OpenGL
rendering context.
- \ingroup multimedia
+ \ingroup painting-3D
A display format has several characteristics:
\list
@@ -1554,7 +1554,7 @@ Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg()
\class QGLContext
\brief The QGLContext class encapsulates an OpenGL rendering context.
- \ingroup multimedia
+ \ingroup painting-3D
An OpenGL rendering context is a complete set of OpenGL state
variables. The rendering context's \l {QGL::FormatOption} {format}
@@ -2775,8 +2775,8 @@ const QGLContext* QGLContext::currentContext()
\class QGLWidget
\brief The QGLWidget class is a widget for rendering OpenGL graphics.
- \ingroup multimedia
- \mainclass
+ \ingroup painting-3D
+
QGLWidget provides functionality for displaying OpenGL graphics
integrated into a Qt application. It is very simple to use. You
diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp
index 0d38ce7..cdbf1c8 100644
--- a/src/opengl/qglcolormap.cpp
+++ b/src/opengl/qglcolormap.cpp
@@ -45,7 +45,7 @@
QGLWidgets.
\module OpenGL
- \ingroup multimedia
+ \ingroup painting-3D
\ingroup shared
QGLColormap provides a platform independent way of specifying and
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index f48c18d..db33297 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -90,7 +90,7 @@ public:
\since 4.6
- \ingroup multimedia
+ \ingroup painting-3D
A framebuffer object has several characteristics:
\list
@@ -275,7 +275,6 @@ public:
GLenum target;
QSize size;
QGLFramebufferObjectFormat format;
- int samples;
uint valid : 1;
uint bound : 1;
QGLFramebufferObject::Attachment fbo_attachment;
@@ -368,7 +367,6 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At
valid = checkFramebufferStatus();
color_buffer = 0;
- samples = 0;
} else {
GLint maxSamples;
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
@@ -478,7 +476,7 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At
\brief The QGLFramebufferObject class encapsulates an OpenGL framebuffer object.
\since 4.2
- \ingroup multimedia
+ \ingroup painting-3D
The QGLFramebufferObject class encapsulates an OpenGL framebuffer
object, defined by the \c{GL_EXT_framebuffer_object} extension. In
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 884bb36..4140bdf 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -44,7 +44,7 @@
\brief The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
\since 4.1
- \ingroup multimedia
+ \ingroup painting-3D
Rendering into a pbuffer is normally done using full hardware
acceleration. This can be significantly faster than rendering
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index e3627ff..f8bffd3 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
\class QGLShaderProgram
\brief The QGLShaderProgram class allows OpenGL shader programs to be linked and used.
\since 4.6
+ \ingroup painting-3D
\section1 Introduction
@@ -181,6 +182,7 @@ QT_BEGIN_NAMESPACE
\class QGLShader
\brief The QGLShader class allows OpenGL shaders to be compiled.
\since 4.6
+ \ingroup painting-3D
This class supports shaders written in the OpenGL Shading Language (GLSL)
and in the OpenGL/ES Shading Language (GLSL/ES).