]> icculus.org git repositories - dana/openbox.git/blob - loco/loco.c
compositing pre-pre-pre alpha crap
[dana/openbox.git] / loco / loco.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    loco.c for the Openbox window manager
4    Copyright (c) 2008        Derek Foreman
5    Copyright (c) 2008        Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include <stdio.h>
21 #include "obt/mainloop.h"
22 #include "obt/display.h"
23 #include "obt/mainloop.h"
24 #include <glib.h>
25 #include <GL/glx.h>
26 #include <GL/glext.h>
27 #include <GL/glxext.h>
28 #include <GL/glxtokens.h>
29 /*
30 <dana> you want CreateNotify, DestroyNotify, MapNotify, UnmapNotify, and
31           ConfigureNotify
32           <dana> and then xdamage or whatever
33
34 */
35
36 void composite_setup_window(Window win)
37 {
38     XCompositeRedirectWindow(obt_display, win, CompositeRedirectAutomatic);
39     /*something useful = */XDamageCreate(obt_display, win, XDamageReportRawRectangles);
40 }
41
42 void COMPOSTER_RAWR(const XEvent *e, gpointer data)
43 {
44     Window window;
45     if (e->type == CreateNotify) {
46         window = e->xmap.window;
47         printf("Do first time stuff\n");
48         composite_setup_window(window);
49     }
50     if (e->type == obt_display_extension_damage_basep + XDamageNotify) {
51     }
52     if (e->type == ConfigureNotify) {
53         printf("Window moved or something\n");
54     }
55 }
56
57 void loco_set_mainloop(gint ob_screen, ObtMainLoop *loop)
58 {
59     int w, h;
60     XVisualInfo *vi;
61     GLXContext cont;
62     int config[] =
63         { GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, GLX_RGBA, None };
64
65     vi = glXChooseVisual(obt_display, DefaultScreen(obt_display), config);
66     cont = glXCreateContext(obt_display, vi, NULL, GL_TRUE);
67     if (cont == NULL)
68         printf("context creation failed\n");
69     glXMakeCurrent(obt_display, RootWindow(obt_display, ob_screen), cont);
70
71     w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen));
72     h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen));
73     glViewport(0, 0, w, h);
74     glMatrixMode(GL_PROJECTION);
75     glLoadIdentity();
76 printf("Setting up an orthographic projection of %dx%d\n", w, h);
77     glOrtho(0, w, h, 0.0, -1.0, 100.0);
78     glMatrixMode(GL_MODELVIEW);
79     glLoadIdentity();
80     glClear(GL_COLOR_BUFFER_BIT);
81     glEnable(GL_TEXTURE_RECTANGLE_ARB);
82     glXSwapBuffers(obt_display, RootWindow(obt_display, ob_screen));
83     obt_main_loop_x_add(loop, COMPOSTER_RAWR, NULL, NULL);
84 }
85
86 void loco_shutdown(void)
87 {
88 }