return g_object_new (GST_TYPE_GL_DISPLAY, NULL);
}
-#define HANDLE_X_ERRORS
+//#define HANDLE_X_ERRORS
#ifdef HANDLE_X_ERRORS
static int
x_error_handler (Display * display, XErrorEvent * event)
GST_DEBUG ("No GLX extension");
return FALSE;
}
-#if 0
- {
- int i;
- int n;
-
- visinfo = XGetVisualInfo (display->display, 0, NULL, &n);
- for (i = 0; i < n; i++) {
- GST_ERROR ("%d: %d %ld", i, visinfo[i].depth, visinfo[i].visualid);
- if (visinfo[i].depth == 32)
- break;
- }
-
- visinfo += i;
- }
-#endif
- if (1) {
- visinfo = glXChooseVisual (display->display, scrnum, attrib);
- if (visinfo == NULL) {
- GST_DEBUG ("No usable visual");
- return FALSE;
- }
+ visinfo = glXChooseVisual (display->display, scrnum, attrib);
+ if (visinfo == NULL) {
+ GST_DEBUG ("No usable visual");
+ return FALSE;
}
display->visinfo = visinfo;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect;
- GST_ERROR ("creating window with visual %ld", visinfo->visualid);
+ GST_DEBUG ("creating window with visual %ld", visinfo->visualid);
window = XCreateWindow (display->display, root, 0, 0,
100, 100, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
parent_window, 0, 0, width, height,
0, display->visinfo->depth, InputOutput,
display->visinfo->visual, mask, &attr);
- XMapWindow (display->display, display->window);
+ if (display->visible) {
+ XMapWindow (display->display, display->window);
+ }
XSync (display->display, FALSE);
}
}
void
+gst_gl_display_set_visible (GstGLDisplay * display, gboolean visible)
+{
+ if (display->visible == visible)
+ return;
+ display->visible = visible;
+ if (display->visible) {
+ XMapWindow (display->display, display->window);
+ } else {
+ XUnmapWindow (display->display, display->window);
+ }
+ XSync (display->display, FALSE);
+}
+
+void
gst_gl_display_set_window (GstGLDisplay * display, Window window)
{
g_mutex_lock (display->lock);
-#if 0
- if (window != display->assigned_window) {
- if (display->assigned_window == None) {
- gst_gl_display_destroy_tmp_window (display);
- }
- display->assigned_window = window;
- if (display->assigned_window == None) {
- gst_gl_display_init_tmp_window (display);
- } else {
- display->window = window;
- }
- }
-#else
if (window != display->parent_window) {
gst_gl_display_destroy_tmp_window (display);
display->parent_window = window;
gst_gl_display_init_tmp_window (display);
-
- //XReparentWindow (display->display, display->window,
- // display->assigned_window, 0, 0);
}
-#endif
g_mutex_unlock (display->lock);
}
}
+#if 0
static void
draw_rect_texture (GstGLDisplay * display, GstVideoFormat type,
void *data, int width, int height)
glEnd ();
glDeleteTextures (1, &texture);
}
+#endif
+#if 0
void
gst_gl_display_draw_image (GstGLDisplay * display, GstVideoFormat type,
void *data, int width, int height)
ret = glXGetSyncValuesOML (display->display, display->window,
&ust, &mst, &sbc);
- GST_DEBUG ("sync values %d %lld %lld %lld", ret, ust, mst, sbc);
+ GST_ERROR ("sync values %d %lld %lld %lld", ret, ust, mst, sbc);
}
#endif
gst_gl_display_unlock (display);
}
+#endif
void
-gst_gl_display_draw_rbo (GstGLDisplay * display, GLuint rbo,
+gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture,
int width, int height)
{
- GLuint texture;
- GLuint fbo;
-
g_return_if_fail (width > 0);
g_return_if_fail (height > 0);
- g_return_if_fail (rbo != None);
+ g_return_if_fail (texture != None);
gst_gl_display_lock (display);
g_assert (display->context != NULL);
gst_gl_display_update_attributes (display);
-
- glViewport (0, 0, display->win_width, display->win_height);
-
- glClearColor (0.3, 0.3, 0.3, 1.0);
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
-
- glMatrixMode (GL_MODELVIEW);
- glLoadIdentity ();
-
- glDisable (GL_CULL_FACE);
- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
-
- glColor4f (1, 1, 1, 1);
-
- glGenFramebuffersEXT (1, &fbo);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo);
-
- glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rbo);
-
- glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
- glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
-
- g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
- GL_FRAMEBUFFER_COMPLETE_EXT);
-
-#if 1
+#if 0
+ /* Doesn't work */
{
- void *buffer;
+ int64_t ust = 1234;
+ int64_t mst = 1234;
+ int64_t sbc = 1234;
+ gboolean ret;
- buffer = malloc (320 * 240 * 4);
- memset (buffer, random (), 320 * 240 * 4);
- free (buffer);
+ ret = glXGetSyncValuesOML (display->display, display->window,
+ &ust, &mst, &sbc);
+ GST_ERROR ("sync values %d %lld %lld %lld", ret, ust, mst, sbc);
}
#endif
- glEnable (GL_TEXTURE_RECTANGLE_ARB);
- glGenTextures (1, &texture);
- glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
- glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_RECTANGLE_ARB, texture, 0);
-
- glDrawBuffer (0);
- glReadBuffer (0);
- glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
- glColor4f (1, 0, 1, 1);
- gst_gl_display_check_error (display, __LINE__);
-//glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
- glBegin (GL_QUADS);
-
- glNormal3f (0, 0, -1);
-
- glTexCoord2f (width, 0);
- glVertex3f (0.9, 0.9, 0);
- glTexCoord2f (0, 0);
- glVertex3f (-0.9, 0.9, 0);
- glTexCoord2f (0, height);
- glVertex3f (-0.9, -0.9, 0);
- glTexCoord2f (width, height);
- glVertex3f (0.9, -0.9, 0);
- glEnd ();
- gst_gl_display_check_error (display, __LINE__);
- glDeleteTextures (1, &texture);
-
- glDeleteFramebuffersEXT (1, &fbo);
- gst_gl_display_check_error (display, __LINE__);
-
- glXSwapBuffers (display->display, display->window);
-
- gst_gl_display_unlock (display);
-}
-
-void
-gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture,
- int width, int height)
-{
- g_return_if_fail (width > 0);
- g_return_if_fail (height > 0);
- g_return_if_fail (texture != None);
-
- gst_gl_display_lock (display);
-
- g_assert (display->window != None);
- g_assert (display->context != NULL);
-
- gst_gl_display_update_attributes (display);
+#if 1
+ /* Doesn't work */
+ glXSwapIntervalSGI (1);
+#endif
glViewport (0, 0, display->win_width, display->win_height);
glNormal3f (0, 0, -1);
glTexCoord2f (width, 0);
- glVertex3f (0.9, 0.9, 0);
+ glVertex3f (1.0, 1.0, 0);
glTexCoord2f (0, 0);
- glVertex3f (-0.9, 0.9, 0);
+ glVertex3f (-1.0, 1.0, 0);
glTexCoord2f (0, height);
- glVertex3f (-0.9, -0.9, 0);
+ glVertex3f (-1.0, -1.0, 0);
glTexCoord2f (width, height);
- glVertex3f (0.9, -0.9, 0);
+ glVertex3f (1.0, -1.0, 0);
glEnd ();
gst_gl_display_check_error (display, __LINE__);