2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../../idlib/precompiled.h"
38 //#include <GL/glaux.h>
42 void Draw_ClearWindow( void ) {
44 if ( !dmapGlobals.drawflag ) {
48 glDrawBuffer( GL_FRONT );
52 glClearColor( 0.5, 0.5, 0.5, 0 );
53 glClear( GL_COLOR_BUFFER_BIT );
59 w = (dmapGlobals.drawBounds.b[1][0] - dmapGlobals.drawBounds.b[0][0]);
60 h = (dmapGlobals.drawBounds.b[1][1] - dmapGlobals.drawBounds.b[0][1]);
62 mx = dmapGlobals.drawBounds.b[0][0] + w/2;
63 my = dmapGlobals.drawBounds.b[1][1] + h/2;
68 gluPerspective (90, 1, 2, 16384);
69 gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
71 glMatrixMode( GL_PROJECTION );
73 glOrtho( dmapGlobals.drawBounds[0][0], dmapGlobals.drawBounds[1][0],
74 dmapGlobals.drawBounds[0][1], dmapGlobals.drawBounds[1][1],
76 glMatrixMode( GL_MODELVIEW );
80 // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
81 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
82 glDisable (GL_DEPTH_TEST);
83 // glEnable (GL_BLEND);
84 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
87 //glColor4f (1,0,0,0.5);
88 // glBegin( GL_LINE_LOOP );
91 glVertex2f( dmapGlobals.drawBounds.b[0][0] + 20, dmapGlobals.drawBounds.b[0][1] + 20 );
92 glVertex2f( dmapGlobals.drawBounds.b[1][0] - 20, dmapGlobals.drawBounds.b[0][1] + 20 );
93 glVertex2f( dmapGlobals.drawBounds.b[1][0] - 20, dmapGlobals.drawBounds.b[1][1] - 20 );
94 glVertex2f( dmapGlobals.drawBounds.b[0][0] + 20, dmapGlobals.drawBounds.b[1][1] - 20 );
103 void Draw_SetRed (void)
105 if (!dmapGlobals.drawflag)
111 void Draw_SetGrey (void)
113 if (!dmapGlobals.drawflag)
116 glColor3f( 0.5f, 0.5f, 0.5f);
119 void Draw_SetBlack (void)
121 if (!dmapGlobals.drawflag)
124 glColor3f( 0.0f, 0.0f, 0.0f );
127 void DrawWinding ( const idWinding *w )
131 if (!dmapGlobals.drawflag)
134 glColor3f( 0.3f, 0.0f, 0.0f );
135 glBegin (GL_POLYGON);
136 for ( i = 0; i < w->GetNumPoints(); i++ )
137 glVertex3f( (*w)[i][0], (*w)[i][1], (*w)[i][2] );
140 glColor3f( 1, 0, 0 );
141 glBegin (GL_LINE_LOOP);
142 for ( i = 0; i < w->GetNumPoints(); i++ )
143 glVertex3f( (*w)[i][0], (*w)[i][1], (*w)[i][2] );
149 void DrawAuxWinding ( const idWinding *w)
153 if (!dmapGlobals.drawflag)
156 glColor3f( 0.0f, 0.3f, 0.0f );
157 glBegin (GL_POLYGON);
158 for ( i = 0; i < w->GetNumPoints(); i++ )
159 glVertex3f( (*w)[i][0], (*w)[i][1], (*w)[i][2] );
162 glColor3f( 0.0f, 1.0f, 0.0f );
163 glBegin (GL_LINE_LOOP);
164 for ( i = 0; i < w->GetNumPoints(); i++ )
165 glVertex3f( (*w)[i][0], (*w)[i][1], (*w)[i][2] );
171 void DrawLine( idVec3 v1, idVec3 v2, int color ) {
172 if (!dmapGlobals.drawflag)
176 case 0: glColor3f( 0, 0, 0 ); break;
177 case 1: glColor3f( 0, 0, 1 ); break;
178 case 2: glColor3f( 0, 1, 0 ); break;
179 case 3: glColor3f( 0, 1, 1 ); break;
180 case 4: glColor3f( 1, 0, 0 ); break;
181 case 5: glColor3f( 1, 0, 1 ); break;
182 case 6: glColor3f( 1, 1, 0 ); break;
183 case 7: glColor3f( 1, 1, 1 ); break;
189 glVertex3fv( v1.ToFloatPtr() );
190 glVertex3fv( v2.ToFloatPtr() );
196 //============================================================
198 #define GLSERV_PORT 25001
203 void GLS_BeginScene (void)
206 WORD wVersionRequested;
207 struct sockaddr_in address;
214 wVersionRequested = MAKEWORD(1, 1);
216 r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
219 common->Error( "Winsock initialization failed.");
223 // connect a socket to the server
225 draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
226 if (draw_socket == -1)
227 common->Error( "draw_socket failed");
229 address.sin_family = AF_INET;
230 address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
231 address.sin_port = GLSERV_PORT;
232 r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
235 closesocket (draw_socket);
240 void GLS_Winding( const idWinding *w, int code )
248 ((int *)buf)[0] = w->GetNumPoints();
249 ((int *)buf)[1] = code;
250 for ( i = 0; i < w->GetNumPoints(); i++ )
251 for (j=0 ; j<3 ; j++)
252 ((float *)buf)[2+i*3+j] = (*w)[i][j];
254 send (draw_socket, (const char *)buf, w->GetNumPoints() * 12 + 8, 0);
257 void GLS_Triangle( const mapTri_t *tri, int code ) {
261 VectorCopy( tri->v[0].xyz, w[0] );
262 VectorCopy( tri->v[1].xyz, w[1] );
263 VectorCopy( tri->v[2].xyz, w[2] );
264 GLS_Winding( &w, code );
267 void GLS_EndScene (void)
269 closesocket (draw_socket);
273 void Draw_ClearWindow( void ) {
276 void DrawWinding( const idWinding *w) {
279 void DrawAuxWinding ( const idWinding *w) {
282 void GLS_Winding( const idWinding *w, int code ) {
285 void GLS_BeginScene (void) {
288 void GLS_EndScene (void)