summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-09-23 22:04:10 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-09-30 02:19:51 +0200
commitc7d1024d9786b88665289182a5ed9e590b3a70c4 (patch)
treea52ff7d527d38b026b84d78cf04f25fe32be2e2d /client
parent862bb2cd07e42ead1e0852aba3431eb273155847 (diff)
downloadspice-c7d1024d9786b88665289182a5ed9e590b3a70c4.tar.gz
spice-c7d1024d9786b88665289182a5ed9e590b3a70c4.tar.xz
spice-c7d1024d9786b88665289182a5ed9e590b3a70c4.zip
spicec: use standard opengl 3.0 framebuffer
Diffstat (limited to 'client')
-rw-r--r--client/x11/pixels_source_p.h1
-rw-r--r--client/x11/red_drawable.cpp12
-rw-r--r--client/x11/red_pixmap_gl.cpp84
3 files changed, 50 insertions, 47 deletions
diff --git a/client/x11/pixels_source_p.h b/client/x11/pixels_source_p.h
index 64b0c50e..84311211 100644
--- a/client/x11/pixels_source_p.h
+++ b/client/x11/pixels_source_p.h
@@ -73,6 +73,7 @@ struct PixelsSource_p {
Win win;
GLuint tex;
GLuint stencil_tex;
+ GLuint rbo;
int width, height;
int width_powed, height_powed;
union {
diff --git a/client/x11/red_drawable.cpp b/client/x11/red_drawable.cpp
index bb8ceb44..54e53f8d 100644
--- a/client/x11/red_drawable.cpp
+++ b/client/x11/red_drawable.cpp
@@ -62,7 +62,7 @@ static inline void copy_to_gldrawable_from_gltexture(const RedDrawable_p* dest,
rendertype = source->gl.rendertype;
if (rendertype == RENDER_TYPE_FBO) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
} else {
win = source->gl.win;
context = source->gl.context;
@@ -86,7 +86,7 @@ static inline void copy_to_gldrawable_from_gltexture(const RedDrawable_p* dest,
GLuint fbo;
fbo = source->gl.fbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
} else {
pbuffer = source->gl.pbuff;
glXMakeCurrent(XPlatform::get_display(), pbuffer, context);
@@ -107,7 +107,7 @@ static inline void copy_to_gldrawable_from_pixmap(const RedDrawable_p* dest,
rendertype = dest->source.x_drawable.rendertype;
if (rendertype == RENDER_TYPE_FBO) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
glBindTexture(GL_TEXTURE_2D, 0);
} else {
context = dest->source.x_drawable.context;
@@ -130,7 +130,7 @@ static inline void copy_to_gldrawable_from_pixmap(const RedDrawable_p* dest,
GLuint fbo;
fbo = dest->source.x_drawable.fbo;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
} else {
pbuffer = dest->source.x_drawable.pbuff;
glXMakeCurrent(XPlatform::get_display(), pbuffer, context);
@@ -341,7 +341,7 @@ static inline void copy_to_pixmap_from_gltexture(const RedDrawable_p* dest,
rendertype = source->gl.rendertype;
if (rendertype == RENDER_TYPE_FBO) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, source->gl.fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, source->gl.fbo);
glBindTexture(GL_TEXTURE_2D, 0);
} else {
context = source->gl.context;
@@ -673,7 +673,7 @@ static inline void fill_gl_drawable(RedDrawable_p* dest, const SpiceRect& area,
vertex_x2 = vertex_x1 + (area.right - area.left);
vertex_y2 = vertex_y1 + (area.bottom - area.top);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
glColor3f(rgb32_get_red(color), rgb32_get_green(color),
rgb32_get_blue(color));
diff --git a/client/x11/red_pixmap_gl.cpp b/client/x11/red_pixmap_gl.cpp
index 8d81c31a..1a586286 100644
--- a/client/x11/red_pixmap_gl.cpp
+++ b/client/x11/red_pixmap_gl.cpp
@@ -38,9 +38,10 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
RenderType rendertype)
: RedPixmap(width, height, format, top_bottom)
{
- GLuint fbo;
- GLuint tex;
+ GLuint fbo = 0;
+ GLuint tex = 0;
GLuint stencil_tex = 0;
+ GLuint rbo = 0;
Win xwin;
//GLint max_texture_size;
@@ -68,6 +69,9 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
}*/
if (rendertype == RENDER_TYPE_FBO) {
+ int w = gl_get_to_power_two(width);
+ int h = gl_get_to_power_two(height);
+
glXMakeCurrent(XPlatform::get_display(), xwin, _glcont);
if (!gluCheckExtension((GLubyte *)"GL_EXT_framebuffer_object",
glGetString(GL_EXTENSIONS))) {
@@ -75,41 +79,32 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
glXDestroyContext(XPlatform::get_display(), _glcont);
THROW("no GL_EXT_framebuffer_object extension");
}
- glEnable(GL_TEXTURE_2D);
- glGenFramebuffersEXT(1, &fbo);
- glGenTextures(1, &tex);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
-
- glTexImage2D(GL_TEXTURE_2D, 0, 4, gl_get_to_power_two(width),
- gl_get_to_power_two(height), 0, GL_BGRA, GL_UNSIGNED_BYTE,
- NULL);
-
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, tex, 0);
-
-
- glGenTextures(1, &stencil_tex);
- glBindTexture(GL_TEXTURE_2D, stencil_tex);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_EXT,
- gl_get_to_power_two(width), gl_get_to_power_two(height), 0,
- GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_TEXTURE_2D, stencil_tex, 0);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_STENCIL_ATTACHMENT_EXT,
- GL_TEXTURE_2D, stencil_tex, 0);
glBindTexture(GL_TEXTURE_2D, 0);
+ glGenRenderbuffers(1, &rbo);
+ glBindRenderbuffer(GL_RENDERBUFFER, rbo);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, w, h);
+ glBindRenderbuffer(GL_RENDERBUFFER, 0);
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
+
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ THROW("bad fbo status: %d\n", status);
+
((PixelsSource_p*)get_opaque())->gl.fbo = fbo;
win->set_render_fbo(fbo);
- } else {
+
+ } else if (rendertype == RENDER_TYPE_PBUFF) {
GLXPbuffer pbuff;
pbuff = win->create_pbuff(gl_get_to_power_two(width),
@@ -133,6 +128,8 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
glBindTexture(GL_TEXTURE_2D, 0);
((PixelsSource_p*)get_opaque())->gl.pbuff = pbuff;
win->set_render_pbuff(pbuff);
+ } else {
+ abort();
}
((PixelsSource_p*)get_opaque())->gl.stencil_tex = stencil_tex;
@@ -269,11 +266,27 @@ void RedPixmapGL::past_copy()
RedPixmapGL::~RedPixmapGL()
{
GLXPbuffer pbuff;
- GLuint fbo;
+ GLuint fbo, rbo;
RenderType rendertype;
GLuint tex;
GLuint stencil_tex;
+ rendertype = ((PixelsSource_p*)get_opaque())->gl.rendertype;
+ if (rendertype == RENDER_TYPE_FBO) {
+ fbo = ((PixelsSource_p*)get_opaque())->gl.fbo;
+ rbo = ((PixelsSource_p*)get_opaque())->gl.rbo;
+ spice_debug("deletefbo %u", fbo);
+ if (fbo) {
+ glDeleteFramebuffers(1, &fbo);
+ }
+ if (rbo) {
+ glDeleteRenderbuffers(1, &rbo);
+ }
+ } else {
+ pbuff = ((PixelsSource_p*)get_opaque())->gl.pbuff;
+ glXDestroyPbuffer(XPlatform::get_display(), pbuff);
+ }
+
/*
* GL textures might be destroyed by res change.
*/
@@ -291,17 +304,6 @@ RedPixmapGL::~RedPixmapGL()
}
}
- rendertype = ((PixelsSource_p*)get_opaque())->gl.rendertype;
- if (rendertype == RENDER_TYPE_FBO) {
- fbo = ((PixelsSource_p*)get_opaque())->gl.fbo;
- if (fbo) {
- glDeleteFramebuffersEXT(1, &fbo);
- }
- } else {
- pbuff = ((PixelsSource_p*)get_opaque())->gl.pbuff;
- glXDestroyPbuffer(XPlatform::get_display(), pbuff);
- }
-
/*
* Both tex and stenctil_tex are textures and therefore they are destroyed
* when the context is gone, so we dont free them here as they might have