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 ){
39 auxInitDisplayMode( AUX_SINGLE | AUX_RGB );
40 auxInitPosition( 0, 0, WIN_SIZE, WIN_SIZE );
41 auxInitWindow( "qcsg" );
44 void Draw_ClearWindow( void ){
58 glClearColor( 1,0.8,0.8,0 );
59 glClear( GL_COLOR_BUFFER_BIT );
61 w = ( draw_maxs[0] - draw_mins[0] );
62 h = ( draw_maxs[1] - draw_mins[1] );
64 mx = draw_mins[0] + w / 2;
65 my = draw_mins[1] + h / 2;
70 gluPerspective( 90, 1, 2, 16384 );
71 gluLookAt( mx, my, draw_maxs[2] + g / 2, mx, my, draw_maxs[2], 0, 1, 0 );
74 // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
75 glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
76 glDisable( GL_DEPTH_TEST );
78 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
81 glColor4f( 1,0,0,0.5 );
82 glBegin( GL_POLYGON );
84 glVertex3f( 0, 500, 0 );
85 glVertex3f( 0, 900, 0 );
86 glVertex3f( 0, 900, 100 );
87 glVertex3f( 0, 500, 100 );
96 void Draw_SetRed( void ){
104 void Draw_SetGrey( void ){
109 glColor3f( 0.5,0.5,0.5 );
112 void Draw_SetBlack( void ){
120 void DrawWinding( winding_t *w ){
127 glColor4f( 0,0,0,0.5 );
128 glBegin( GL_LINE_LOOP );
129 for ( i = 0 ; i < w->numpoints ; i++ )
130 glVertex3f( w->p[i][0],w->p[i][1],w->p[i][2] );
133 glColor4f( 0,1,0,0.3 );
134 glBegin( GL_POLYGON );
135 for ( i = 0 ; i < w->numpoints ; i++ )
136 glVertex3f( w->p[i][0],w->p[i][1],w->p[i][2] );
142 void DrawAuxWinding( winding_t *w ){
149 glColor4f( 0,0,0,0.5 );
150 glBegin( GL_LINE_LOOP );
151 for ( i = 0 ; i < w->numpoints ; i++ )
152 glVertex3f( w->p[i][0],w->p[i][1],w->p[i][2] );
155 glColor4f( 1,0,0,0.3 );
156 glBegin( GL_POLYGON );
157 for ( i = 0 ; i < w->numpoints ; i++ )
158 glVertex3f( w->p[i][0],w->p[i][1],w->p[i][2] );
164 //============================================================
166 #define GLSERV_PORT 25001
171 void GLS_BeginScene( void ){
173 WORD wVersionRequested;
174 struct sockaddr_in address;
180 wVersionRequested = MAKEWORD( 1, 1 );
182 r = WSAStartup( MAKEWORD( 1, 1 ), &winsockdata );
185 Error( "Winsock initialization failed." );
190 // connect a socket to the server
192 draw_socket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP );
193 if ( draw_socket == -1 ) {
194 Error( "draw_socket failed" );
197 address.sin_family = AF_INET;
198 address.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
199 address.sin_port = GLSERV_PORT;
200 r = connect( draw_socket, (struct sockaddr *)&address, sizeof( address ) );
202 closesocket( draw_socket );
207 void GLS_Winding( winding_t *w, int code ){
211 if ( !draw_socket ) {
215 ( (int *)buf )[0] = w->numpoints;
216 ( (int *)buf )[1] = code;
217 for ( i = 0 ; i < w->numpoints ; i++ )
218 for ( j = 0 ; j < 3 ; j++ )
219 ( (float *)buf )[2 + i * 3 + j] = w->p[i][j];
221 send( draw_socket, buf, w->numpoints * 12 + 8, 0 );
224 void GLS_EndScene( void ){
225 closesocket( draw_socket );