Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

gldraw.c File Reference

#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include "qbsp.h"

Include dependency graph for gldraw.c:

Include dependency graph

Go to the source code of this file.

Defines

#define GLSERV_PORT   25001
#define WIN_SIZE   512

Functions

void Draw_ClearWindow (void)
void Draw_SetBlack (void)
void Draw_SetGrey (void)
void Draw_SetRed (void)
void DrawAuxWinding (winding_t *w)
void DrawWinding (winding_t *w)
void GLS_BeginScene (void)
void GLS_EndScene (void)
void GLS_Winding (winding_t *w, int code)
void InitWindow (void)

Variables

vec3_t draw_maxs
vec3_t draw_mins
int draw_socket
qboolean drawflag
qboolean wins_init


Define Documentation

#define GLSERV_PORT   25001
 

Definition at line 169 of file gldraw.c.

#define WIN_SIZE   512
 

Definition at line 37 of file gldraw.c.

Referenced by InitWindow().


Function Documentation

void Draw_ClearWindow void   ) 
 

Definition at line 46 of file gldraw.c.

00047 {
00048     static int  init;
00049     int     w, h, g;
00050     vec_t   mx, my;
00051 
00052     if (!drawflag)
00053         return;
00054 
00055     if (!init)
00056     {
00057         init = true;
00058         InitWindow ();
00059     }
00060 
00061     glClearColor (1,0.8,0.8,0);
00062     glClear (GL_COLOR_BUFFER_BIT);
00063 
00064     w = (draw_maxs[0] - draw_mins[0]);
00065     h = (draw_maxs[1] - draw_mins[1]);
00066 
00067     mx = draw_mins[0] + w/2;
00068     my = draw_mins[1] + h/2;
00069 
00070     g = w > h ? w : h;
00071 
00072     glLoadIdentity ();
00073     gluPerspective (90,  1,  2,  16384);
00074     gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0);
00075 
00076     glColor3f (0,0,0);
00077 //  glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
00078     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
00079     glDisable (GL_DEPTH_TEST);
00080     glEnable (GL_BLEND);
00081     glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00082 
00083 #if 0
00084     glColor4f (1,0,0,0.5);
00085     glBegin (GL_POLYGON);
00086 
00087     glVertex3f (0, 500, 0);
00088     glVertex3f (0, 900, 0);
00089     glVertex3f (0, 900, 100);
00090     glVertex3f (0, 500, 100);
00091 
00092     glEnd ();
00093 #endif
00094 
00095     glFlush ();
00096 
00097 }

void Draw_SetBlack void   ) 
 

Definition at line 115 of file gldraw.c.

References glColor3f.

00116 {
00117     if (!drawflag)
00118         return;
00119 
00120     glColor3f (0,0,0);
00121 }

void Draw_SetGrey void   ) 
 

Definition at line 107 of file gldraw.c.

References glColor3f.

00108 {
00109     if (!drawflag)
00110         return;
00111 
00112     glColor3f (0.5,0.5,0.5);
00113 }

void Draw_SetRed void   ) 
 

Definition at line 99 of file gldraw.c.

References glColor3f.

00100 {
00101     if (!drawflag)
00102         return;
00103 
00104     glColor3f (1,0,0);
00105 }

void DrawAuxWinding winding_t w  ) 
 

Definition at line 145 of file gldraw.c.

References glBegin, glColor4f, glEnd, glFlush, glVertex3f, i, winding_t::numpoints, winding_t::p, and w.

00146 {
00147     int     i;
00148 
00149     if (!drawflag)
00150         return;
00151 
00152     glColor4f (0,0,0,0.5);
00153     glBegin (GL_LINE_LOOP);
00154     for (i=0 ; i<w->numpoints ; i++)
00155         glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
00156     glEnd ();
00157 
00158     glColor4f (1,0,0,0.3);
00159     glBegin (GL_POLYGON);
00160     for (i=0 ; i<w->numpoints ; i++)
00161         glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
00162     glEnd ();
00163 
00164     glFlush ();
00165 }

void DrawWinding winding_t w  ) 
 

Definition at line 123 of file gldraw.c.

00124 {
00125     int     i;
00126 
00127     if (!drawflag)
00128         return;
00129 
00130     glColor4f (0,0,0,0.5);
00131     glBegin (GL_LINE_LOOP);
00132     for (i=0 ; i<w->numpoints ; i++)
00133         glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
00134     glEnd ();
00135 
00136     glColor4f (0,1,0,0.3);
00137     glBegin (GL_POLYGON);
00138     for (i=0 ; i<w->numpoints ; i++)
00139         glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] );
00140     glEnd ();
00141 
00142     glFlush ();
00143 }

void GLS_BeginScene void   ) 
 

Definition at line 174 of file gldraw.c.

Referenced by DrawBrushList().

00175 {
00176     WSADATA winsockdata;
00177     WORD    wVersionRequested; 
00178     struct sockaddr_in  address;
00179     int     r;
00180 
00181     if (!wins_init)
00182     {
00183         wins_init = true;
00184 
00185         wVersionRequested = MAKEWORD(1, 1); 
00186 
00187         r = WSAStartup (MAKEWORD(1, 1), &winsockdata);
00188 
00189         if (r)
00190             Error ("Winsock initialization failed.");
00191 
00192     }
00193 
00194     // connect a socket to the server
00195 
00196     draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
00197     if (draw_socket == -1)
00198         Error ("draw_socket failed");
00199 
00200     address.sin_family = AF_INET;
00201     address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
00202     address.sin_port = GLSERV_PORT;
00203     r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address));
00204     if (r == -1)
00205     {
00206         closesocket (draw_socket);
00207         draw_socket = 0;
00208     }
00209 }

void GLS_EndScene void   ) 
 

Definition at line 228 of file gldraw.c.

Referenced by DrawBrushList().

00229 {
00230     closesocket (draw_socket);
00231     draw_socket = 0;
00232 }

void GLS_Winding winding_t w,
int  code
 

Definition at line 211 of file gldraw.c.

00212 {
00213     byte    buf[1024];
00214     int     i, j;
00215 
00216     if (!draw_socket)
00217         return;
00218 
00219     ((int *)buf)[0] = w->numpoints;
00220     ((int *)buf)[1] = code;
00221     for (i=0 ; i<w->numpoints ; i++)
00222         for (j=0 ; j<3 ; j++)
00223             ((float *)buf)[2+i*3+j] = w->p[i][j];
00224 
00225     send (draw_socket, buf, w->numpoints*12+8, 0);
00226 }

void InitWindow void   ) 
 

Definition at line 39 of file gldraw.c.

References WIN_SIZE.

Referenced by Draw_ClearWindow().

00040 {
00041     auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
00042     auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE);
00043     auxInitWindow ("qcsg");
00044 }


Variable Documentation

vec3_t draw_maxs
 

Definition at line 34 of file gldraw.c.

Referenced by Draw_ClearWindow().

vec3_t draw_mins
 

Definition at line 34 of file gldraw.c.

Referenced by Draw_ClearWindow().

int draw_socket
 

Definition at line 172 of file gldraw.c.

Referenced by GLS_BeginScene(), GLS_EndScene(), and GLS_Winding().

qboolean drawflag
 

Definition at line 33 of file gldraw.c.

Referenced by main().

qboolean wins_init
 

Definition at line 171 of file gldraw.c.

Referenced by GLS_BeginScene().


Generated on Thu Aug 25 12:52:49 2005 for Quake III Arena by  doxygen 1.3.9.1