2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant 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.
12 GtkRadiant 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.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 // can't use the glvertex3fv functions, because the vec3_t fields
30 // could be either floats or doubles, depending on DOUBLEVEC_T
33 vec3_t draw_mins, draw_maxs;
38 void InitWindow (void)
40 auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
41 auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
42 auxInitWindow ("qcsg");
45 void Draw_ClearWindow (void)
60 glClearColor (1,0.8,0.8,0);
61 glClear (GL_COLOR_BUFFER_BIT);
63 w = (draw_maxs[0] - draw_mins[0]);
64 h = (draw_maxs[1] - draw_mins[1]);
66 mx = draw_mins[0] + w/2;
67 my = draw_mins[1] + h/2;
72 gluPerspective (90, 1, 2, 16384);
73 gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
76 // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
77 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
78 glDisable (GL_DEPTH_TEST);
80 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
83 glColor4f (1,0,0,0.5);
86 glVertex3f (0, 500, 0);
87 glVertex3f (0, 900, 0);
88 glVertex3f (0, 900, 100);
89 glVertex3f (0, 500, 100);
98 void Draw_SetRed (void)
106 void Draw_SetGrey (void)
111 glColor3f (0.5,0.5,0.5);
114 void Draw_SetBlack (void)
122 void DrawWinding (winding_t *w)
129 glColor4f (0,0,0,0.5);
130 glBegin (GL_LINE_LOOP);
131 for (i=0 ; i<w->numpoints ; i++)
132 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
135 glColor4f (0,1,0,0.3);
136 glBegin (GL_POLYGON);
137 for (i=0 ; i<w->numpoints ; i++)
138 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
144 void DrawAuxWinding (winding_t *w)
151 glColor4f (0,0,0,0.5);
152 glBegin (GL_LINE_LOOP);
153 for (i=0 ; i<w->numpoints ; i++)
154 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
157 glColor4f (1,0,0,0.3);
158 glBegin (GL_POLYGON);
159 for (i=0 ; i<w->numpoints ; i++)
160 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
166 //============================================================
168 #define GLSERV_PORT 25001
173 void GLS_BeginScene (void)
176 WORD wVersionRequested;
177 struct sockaddr_in address;
184 wVersionRequested = MAKEWORD(1, 1);
186 r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
189 Error ("Winsock initialization failed.");
193 // connect a socket to the server
195 draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
196 if (draw_socket == -1)
197 Error ("draw_socket failed");
199 address.sin_family = AF_INET;
200 address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
201 address.sin_port = GLSERV_PORT;
202 r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
205 closesocket (draw_socket);
210 void GLS_Winding (winding_t *w, int code)
218 ((int *)buf)[0] = w->numpoints;
219 ((int *)buf)[1] = code;
220 for (i=0 ; i<w->numpoints ; i++)
221 for (j=0 ; j<3 ; j++)
222 ((float *)buf)[2+i*3+j] = w->p[i][j];
224 send (draw_socket, buf, w->numpoints*12+8, 0);
227 void GLS_EndScene (void)
229 closesocket (draw_socket);