2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
22 #include <windows.h>
\r
25 #include <GL/glaux.h>
\r
29 // can't use the glvertex3fv functions, because the vec3_t fields
\r
30 // could be either floats or doubles, depending on DOUBLEVEC_T
\r
33 vec3_t draw_mins, draw_maxs;
\r
36 #define WIN_SIZE 512
\r
38 void InitWindow (void)
\r
40 auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
\r
41 auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
\r
42 auxInitWindow ("qcsg");
\r
45 void Draw_ClearWindow (void)
\r
60 glClearColor (1,0.8,0.8,0);
\r
61 glClear (GL_COLOR_BUFFER_BIT);
\r
63 w = (draw_maxs[0] - draw_mins[0]);
\r
64 h = (draw_maxs[1] - draw_mins[1]);
\r
66 mx = draw_mins[0] + w/2;
\r
67 my = draw_mins[1] + h/2;
\r
72 gluPerspective (90, 1, 2, 16384);
\r
73 gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
\r
76 // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
\r
77 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
\r
78 glDisable (GL_DEPTH_TEST);
\r
79 glEnable (GL_BLEND);
\r
80 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
\r
83 glColor4f (1,0,0,0.5);
\r
84 glBegin (GL_POLYGON);
\r
86 glVertex3f (0, 500, 0);
\r
87 glVertex3f (0, 900, 0);
\r
88 glVertex3f (0, 900, 100);
\r
89 glVertex3f (0, 500, 100);
\r
98 void Draw_SetRed (void)
\r
106 void Draw_SetGrey (void)
\r
111 glColor3f (0.5,0.5,0.5);
\r
114 void Draw_SetBlack (void)
\r
122 void DrawWinding (winding_t *w)
\r
129 glColor4f (0,0,0,0.5);
\r
130 glBegin (GL_LINE_LOOP);
\r
131 for (i=0 ; i<w->numpoints ; i++)
\r
132 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
\r
135 glColor4f (0,1,0,0.3);
\r
136 glBegin (GL_POLYGON);
\r
137 for (i=0 ; i<w->numpoints ; i++)
\r
138 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
\r
144 void DrawAuxWinding (winding_t *w)
\r
151 glColor4f (0,0,0,0.5);
\r
152 glBegin (GL_LINE_LOOP);
\r
153 for (i=0 ; i<w->numpoints ; i++)
\r
154 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
\r
157 glColor4f (1,0,0,0.3);
\r
158 glBegin (GL_POLYGON);
\r
159 for (i=0 ; i<w->numpoints ; i++)
\r
160 glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
\r
166 //============================================================
\r
168 #define GLSERV_PORT 25001
\r
170 qboolean wins_init;
\r
173 void GLS_BeginScene (void)
\r
175 WSADATA winsockdata;
\r
176 WORD wVersionRequested;
\r
177 struct sockaddr_in address;
\r
184 wVersionRequested = MAKEWORD(1, 1);
\r
186 r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
\r
189 Error ("Winsock initialization failed.");
\r
193 // connect a socket to the server
\r
195 draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
\r
196 if (draw_socket == -1)
\r
197 Error ("draw_socket failed");
\r
199 address.sin_family = AF_INET;
\r
200 address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
\r
201 address.sin_port = GLSERV_PORT;
\r
202 r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
\r
205 closesocket (draw_socket);
\r
210 void GLS_Winding (winding_t *w, int code)
\r
218 ((int *)buf)[0] = w->numpoints;
\r
219 ((int *)buf)[1] = code;
\r
220 for (i=0 ; i<w->numpoints ; i++)
\r
221 for (j=0 ; j<3 ; j++)
\r
222 ((float *)buf)[2+i*3+j] = w->p[i][j];
\r
224 send (draw_socket, buf, w->numpoints*12+8, 0);
\r
227 void GLS_EndScene (void)
\r
229 closesocket (draw_socket);
\r