annotate plugins/crazychat/cc_output.c @ 12323:fc464a0abccc

[gaim-migrate @ 14627] Function prototypes need to be of the form foo(void); instead of foo(); for function that don't take any arguments. This allows the compiler to detect mistakes were someone passes arguments to such a function. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 04 Dec 2005 18:19:56 +0000
parents 80ee726755d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11218
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
1 #include <assert.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
2 #include <string.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
3 #include <stdlib.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
4 #include <GL/gl.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
5 #include <GL/glu.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
6 #include <math.h>
11272
80ee726755d4 [gaim-migrate @ 13455]
Charlie Stockman <chuckleberry>
parents: 11218
diff changeset
7 /*#include "util.h"*/
11218
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
8 #include "cc_interface.h"
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
9 #include "crazychat.h"
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
10 #include <stdio.h>
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
11
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
12 #include "cc_gtk_gl.h"
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
13
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
14 #include "face.h"
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
15 #include "glm.h"
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
16
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
17
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
18 #define TAN_30 0.577
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
19 #define ROOT_3 1.73
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
20 //this will be the width of all heads
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
21 #define HEAD_WIDTH 2.5
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
22 #define HEAD_HEIGHT 2.5 //same for now, this will actually vary from head
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
23 #define PERSONS_HEAD 1
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
24 #define MOVEMENT .33
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
25
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
26 GLfloat ambient[] = {1.0, 1.0, 1.0, 1.0};
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
27 GLfloat diffuse[] = {.7, .7, .7, 1};
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
28 GLfloat specular[] = {1, 1, 1, 1};
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
29 GLfloat lightpos[] = {0.0, 0.0, 20, 1};
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
30 GLfloat specref[] = {1.0, 1, 1, 1,};
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
31
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
32 GLfloat xrot, yrot, zrot;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
33 GLfloat x, y, z, mouth_open;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
34 GLint left_eye_frame, right_eye_frame; //between 0 - 8
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
35 GLint mouth_type;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
36 GLint mouth_frame;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
37 DIRECTION dir;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
38 BOOL left_open, right_open;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
39 GLfloat window_aspect;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
40
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
41 FACE remote_shark_face, remote_dog_face, local_shark_face, local_dog_face;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
42 int count = 0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
43 int curr_materials[DOG_SHARK_CHANGE]; //these are the materials from output_instance
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
44 OUTPUT_MODE curr_mode;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
45 KIND which_face;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
46
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
47 static void destroy_cb(GtkWidget *widget, struct output_instance *data);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
48
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
49 void Interpolate(struct output_instance* instance){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
50 GLfloat rangeX, rangeY, minZ, adj, angle, temp;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
51 count++;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
52 /* yrot=90;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
53 zrot=0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
54 z=5;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
55 x=0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
56 y=0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
57 left_open = right_open = TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
58 mouth_open = (float)(count%10)/10;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
59 dir = CONST;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
60 curr_mode = NORMAL;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
61 return;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
62 */
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
63
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
64 //find z plane from percentage of face
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
65 if(instance->features->head_size==0){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
66 z = 5;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
67 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
68
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
69 temp = (GLfloat)instance->features->head_size/40.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
70 //printf("head size %d\n", instance->features->head_size);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
71
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
72 minZ = ROOT_3;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
73 z = ROOT_3*(PERSONS_HEAD/temp);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
74 if(z < minZ)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
75 z = minZ;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
76
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
77 //these calculations are based on a 90 degree viewing angle
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
78 rangeX = z*(TAN_30)*2;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
79 rangeY = window_aspect*rangeX;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
80 temp = (GLfloat)instance->features->x;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
81 if(temp>50) { //then its on the left
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
82 temp = (temp - 50.0)/50.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
83 x = 0 - temp*rangeX/1.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
84 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
85 else {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
86 temp = (50.0-temp)/50.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
87 x = 0 + temp*rangeX/1.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
88 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
89
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
90 temp = (GLfloat)instance->features->y;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
91
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
92 if(temp>50){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
93 temp = (temp-50.0)/50.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
94 y = 0 - temp*rangeY/1.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
95 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
96 else {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
97 temp = (50.0-temp)/50.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
98 y = 0 + temp*rangeY/1.0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
99 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
100
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
101 temp = (GLfloat)instance->features->head_y_rot;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
102 yrot = temp - 50;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
103 temp = (GLfloat)instance->features->head_z_rot;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
104 zrot = temp-50;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
105
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
106 if(y-instance->past_y < -MOVEMENT)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
107 dir = DOWN;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
108 else if(y-instance->past_y > MOVEMENT)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
109 dir = UP;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
110 else
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
111 dir = CONST;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
112 instance->past_y=y;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
113
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
114 mouth_open = (float)instance->features->mouth_open/105;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
115 count++;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
116 //mouth_open = (count%10)/(10);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
117
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
118 if(instance->features->left_eye_open==0){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
119 left_open = FALSE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
120 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
121 else{
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
122 left_open = TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
123 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
124
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
125 if(instance->features->right_eye_open==0)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
126 right_open = FALSE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
127 else
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
128 right_open = TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
129 //right_open =1 - (count%5)/4;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
130
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
131 //set the materials
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
132 curr_materials[APPENDAGE]=instance->features->appendage_color;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
133 curr_materials[HEAD]=instance->features->head_color;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
134 curr_materials[LIDS]=instance->features->lid_color;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
135 curr_materials[LEFT_IRIS]=instance->features->left_iris_color;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
136 curr_materials[RIGHT_IRIS]=instance->features->right_iris_color;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
137 // we don't get an x rotation
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
138 xrot = 0;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
139 curr_mode=instance->features->mode;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
140 if(instance->features->kind==0)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
141 which_face=DOG;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
142 else
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
143 which_face=SHARK;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
144
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
145 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
146
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
147
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
148
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
149 gboolean configure(GtkWidget *widget,
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
150 GdkEventConfigure *event, void *data)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
151 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
152 GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
153 GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
154
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
155 GLfloat w = widget->allocation.width;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
156 GLfloat h = widget->allocation.height;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
157 GLfloat aspect;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
158
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
159 Debug("configuring\n");
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
160
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
161
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
162 /*** OpenGL BEGIN ***/
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
163 if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
164 return FALSE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
165
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
166 glEnable(GL_DEPTH_TEST);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
167 glViewport(0, 0, w, h);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
168 glMatrixMode(GL_PROJECTION);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
169 glLoadIdentity();
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
170
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
171 if (w > h) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
172 window_aspect = w / h;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
173 } else {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
174 window_aspect = h / w;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
175 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
176
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
177 //glOrtho(-10, 10, -10,10, 0.0001, 1000);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
178 gluPerspective(90.0, window_aspect, 0.0001, 1000.0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
179
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
180 glMatrixMode(GL_MODELVIEW);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
181 glLoadIdentity();
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
182
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
183 gdk_gl_drawable_gl_end(gldrawable);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
184 /*** OpenGL END ***/
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
185
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
186 return TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
187 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
188
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
189 gboolean draw(GtkWidget *widget, GdkEventExpose *event,
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
190 void *data)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
191 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
192 struct output_instance *instance = (struct output_instance*)data;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
193 if(!data) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
194 fprintf(stderr,"null\n");
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
195 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
196 assert(instance);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
197 Interpolate(instance);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
198
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
199 GdkGLContext *glcontext = gtk_widget_get_gl_context (widget);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
200 GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
201
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
202 //return TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
203
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
204 assert(gtk_widget_is_gl_capable(widget));
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
205
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
206 if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
207 fprintf(stderr, "We're fucked this time.\n");
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
208 return FALSE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
209 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
210
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
211
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
212 glClearColor(1.0, 1.0, 1.0, 0.0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
213 //glDisable(GL_CULL_FACE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
214
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
215 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
216 glColor3f(1.0, 1.0, 1.0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
217 glMatrixMode(GL_MODELVIEW);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
218 glLoadIdentity();
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
219
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
220 glTranslatef(x, y, -z);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
221 if(instance->my_output==LOCAL){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
222 if(which_face==DOG){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
223 change_materials(local_dog_face, curr_materials, DOG_SHARK_CHANGE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
224 draw_face(local_dog_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
225 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
226 else {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
227 change_materials(local_shark_face, curr_materials, DOG_SHARK_CHANGE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
228 draw_face(local_shark_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
229 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
230 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
231 else{
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
232 if(which_face==DOG){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
233 change_materials(remote_dog_face, curr_materials, DOG_SHARK_CHANGE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
234 draw_face(remote_dog_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
235 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
236 else{
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
237 change_materials(remote_shark_face, curr_materials, DOG_SHARK_CHANGE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
238 draw_face(remote_shark_face, zrot, yrot, left_open, right_open, mouth_open, dir, curr_mode);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
239 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
240 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
241 if (gdk_gl_drawable_is_double_buffered (gldrawable))
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
242 gdk_gl_drawable_swap_buffers (gldrawable);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
243 else
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
244 glFlush ();
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
245 return TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
246 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
247
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
248 void init (GtkWidget *widget, void *data)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
249 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
250 setupDrawlists(REMOTE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
251 setupLighting(widget);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
252 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
253
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
254
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
255 void setupDrawlists(OUTPUT output)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
256 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
257 if(output==REMOTE){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
258 remote_shark_face = init_face(SHARK);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
259 remote_dog_face = init_face(DOG);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
260 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
261 if(output==LOCAL){
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
262 local_shark_face = init_face(SHARK);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
263 local_dog_face = init_face(DOG);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
264 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
265 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
266
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
267
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
268 void setupLighting(GtkWidget *widget)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
269 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
270
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
271 GLfloat w = widget->allocation.width;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
272 GLfloat h = widget->allocation.height;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
273 glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
274 glEnable(GL_DEPTH_TEST);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
275 glEnable(GL_LIGHTING);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
276 //glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
277 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
278 glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
279 glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
280 glEnable(GL_LIGHT0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
281 //glEnable(GL_COLOR_MATERIAL);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
282 //glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
283 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
284 glMateriali(GL_FRONT, GL_SHININESS, 128);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
285
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
286 //glEnable(GL_CULL_FACE);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
287
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
288 glClear(GL_COLOR_BUFFER_BIT);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
289 glMatrixMode(GL_PROJECTION);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
290 glLoadIdentity();
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
291 //glOrtho(-2, 2, -2, 2, 0.0001, 1000);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
292
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
293 if (w > h) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
294 window_aspect = w / h;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
295 } else {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
296 window_aspect = h / w;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
297 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
298
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
299 gluPerspective(90.0, window_aspect, 0.0001, 1000.0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
300 //glFrustum(-100.0, 100.0, -100.0, 100.0, 0, 10);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
301 glMatrixMode(GL_MODELVIEW);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
302 //gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
303 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
304
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
305 struct output_instance *init_output(struct cc_features *features,
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
306 struct cc_session *session)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
307 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
308 struct draw_info *info;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
309 struct output_instance *instance;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
310 struct window_box ret;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
311
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
312 instance = (struct output_instance*)malloc(sizeof(*instance));
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
313 assert(instance);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
314 memset(instance, 0, sizeof(*instance));
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
315 instance->features = features;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
316 instance->session = session;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
317
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
318 info = (struct draw_info*)malloc(sizeof(*info));
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
319 memset(info, 0, sizeof(*info));
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
320 info->timeout = TRUE;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
321 info->delay_ms = 40;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
322 info->data = instance;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
323
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
324
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
325 cc_new_gl_window(init, configure, draw, info, &ret);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
326 g_signal_connect(GTK_OBJECT(ret.window), "destroy",
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
327 G_CALLBACK(destroy_cb), instance);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
328 gtk_window_set_default_size(ret.window,640,480);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
329 if (session) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
330 gtk_window_set_title(ret.window, session->name);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
331 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
332 gtk_widget_show(ret.window);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
333 instance->widget = ret.window;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
334 instance->box = ret.vbox;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
335 return instance;
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
336 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
337
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
338 static void destroy_cb(GtkWidget *widget, struct output_instance *data)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
339 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
340 Debug("Closing output window\n");
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
341 if (data->session) {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
342 cc_remove_session(data->session->cc, data->session);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
343 close(data->session->tcp_sock);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
344 close(data->session->udp_sock);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
345 Filter_Destroy(data->session->filter);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
346 destroy_output(data->session->output);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
347 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
348 }
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
349
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
350 void destroy_output(struct output_instance *instance)
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
351 {
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
352 free(instance);
ed017b9c532d [gaim-migrate @ 13350]
Charlie Stockman <chuckleberry>
parents:
diff changeset
353 }