2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, 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 Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
30 // can't use the glvertex3fv functions, because the vec3_t fields
31 // could be either floats or doubles, depending on DOUBLEVEC_T
34 vec3_t draw_mins, draw_maxs;
39 void InitWindow (void)
41 auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
42 auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
43 auxInitWindow ("qcsg");
46 void Draw_ClearWindow (void)
61 glClearColor (1,0.8,0.8,0);
62 glClear (GL_COLOR_BUFFER_BIT);
64 w = (draw_maxs[0] - draw_mins[0]);
65 h = (draw_maxs[1] - draw_mins[1]);
67 mx = draw_mins[0] + w/2;
68 my = draw_mins[1] + h/2;
73 gluPerspective (90, 1, 2, 16384);
74 gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
77 // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
78 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
79 glDisable (GL_DEPTH_TEST);
81 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
84 glColor4f (1,0,0,0.5);
87 glVertex3f (0, 500, 0);
88 glVertex3f (0, 900, 0);
89 glVertex3f (0, 900, 100);
90 glVertex3f (0, 500, 100);
99 void Draw_SetRed (void)
107 void Draw_SetGrey (void)
112 glColor3f (0.5,0.5,0.5);
115 void Draw_SetBlack (void)
123 void DrawWinding (winding_t *w)
130 glColor4f (0,0,0,0.5);
131 glBegin (GL_LINE_LOOP);
132 for (i=0 ; i<w->numpoints ; i++)
133 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
136 glColor4f (0,1,0,0.3);
137 glBegin (GL_POLYGON);
138 for (i=0 ; i<w->numpoints ; i++)
139 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
145 void DrawAuxWinding (winding_t *w)
152 glColor4f (0,0,0,0.5);
153 glBegin (GL_LINE_LOOP);
154 for (i=0 ; i<w->numpoints ; i++)
155 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
158 glColor4f (1,0,0,0.3);
159 glBegin (GL_POLYGON);
160 for (i=0 ; i<w->numpoints ; i++)
161 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
167 //============================================================
169 #define GLSERV_PORT 25001
174 void GLS_BeginScene (void)
177 WORD wVersionRequested;
178 struct sockaddr_in address;
185 wVersionRequested = MAKEWORD(1, 1);
187 r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
190 Error ("Winsock initialization failed.");
194 // connect a socket to the server
196 draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
197 if (draw_socket == -1)
198 Error ("draw_socket failed");
200 address.sin_family = AF_INET;
201 address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
202 address.sin_port = GLSERV_PORT;
203 r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
206 closesocket (draw_socket);
211 void GLS_Winding (winding_t *w, int code)
219 ((int *)buf)[0] = w->numpoints;
220 ((int *)buf)[1] = code;
221 for (i=0 ; i<w->numpoints ; i++)
222 for (j=0 ; j<3 ; j++)
223 ((float *)buf)[2+i*3+j] = w->p[i][j];
225 send (draw_socket, buf, w->numpoints*12+8, 0);
228 void GLS_EndScene (void)
230 closesocket (draw_socket);