#include <stdio.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include <unistd.h>
Go to the source code of this file.
Defines | |
#define | X 0 |
misc. functions. More... | |
#define | Y 1 |
#define | Z 2 |
Functions | |
void | DrawHand ( void ) |
Draws the navigation hand. More... | |
void | DrawMatrix (float size, float number) |
DrawMatrix draws the matrix. More... | |
void | IntToString (int x, char text[]) |
IntToString Converts an integer to a string. More... | |
void | printstring (void *font, char *string) |
printstring prints an string into the opengl scenery. More... | |
void | DrawStat (void) |
DrawStat a primitive HUD-Like thing. More... | |
Variables | |
float | campos [] = { 0.0, 15.0, 500.0 } |
float | speednr = 5.0 |
int | frametime |
counts the number of frames per second. More... | |
int | colObject |
the ID of the object the avatar collided with. More... | |
int | WINDOWY = 600 |
int | WINDOWX = 800 |
int | myObjectID |
the ID of the the own avatar in the matrix. More... | |
GLfloat | m_hud [] = { 0.379, 0.409, 0.666, 1.0 } |
material definition for HUD. More... | |
GLfloat | m_hand [] = { 0.6, 0.1, 0.3, 1.0 } |
material definition for the hand. More... |
|
|
Definition at line 14 of file outputOpengl.cpp.
|
Definition at line 15 of file outputOpengl.cpp.
|
Draws the navigation hand.
Definition at line 29 of file outputOpengl.cpp.
00030 { 00031 float finger = -0.05; 00032 float length = -0.1; 00033 00034 glMaterialfv(GL_FRONT,GL_DIFFUSE,m_hand); 00035 00036 glBegin(GL_LINES); 00037 glVertex3f(0.0,0.0,0.05); 00038 glVertex3f(0.0,0.0,0.1); 00039 glEnd(); 00040 00041 glBegin(GL_LINES); 00042 glVertex3f(-0.05,0.0,0.05); 00043 glVertex3f(0.05,0.0,0.05); 00044 glVertex3f(-0.05,0.0,0.05); 00045 glVertex3f(-0.05,0.0,-0.05); 00046 glVertex3f(0.05,0.0,0.05); 00047 glVertex3f(0.05,0.0,-0.05); 00048 glVertex3f(-0.05,0.0,-0.05); 00049 glVertex3f(0.05,0.0,-0.05); 00050 glEnd(); 00051 00052 glBegin(GL_LINES); 00053 glVertex3f(-0.05,0.0,-0.05); 00054 glVertex3f(-0.05,0.0,-0.15); 00055 00056 glVertex3f(0.05,0.0,-0.05); 00057 glVertex3f(0.05,0.0,-0.1); 00058 glVertex3f(0.05,0.0,-0.1); 00059 glVertex3f(0.05,finger,length); 00060 00061 glVertex3f(0.02,0.0,-0.05); 00062 glVertex3f(0.02,0.0,-0.1); 00063 glVertex3f(0.02,0.0,-0.1); 00064 glVertex3f(0.02,finger,length); 00065 00066 glVertex3f(-0.01,0.0,-0.05); 00067 glVertex3f(-0.01,0.0,-0.1); 00068 glVertex3f(-0.01,0.0,-0.1); 00069 glVertex3f(-0.01,finger,length); 00070 00071 glVertex3f(-0.05,0.0,-0.05); 00072 glVertex3f(-0.07,0.0,-0.05); 00073 glVertex3f(-0.07,0.0,-0.05); 00074 glVertex3f(-0.07,-0.05,-0.02); 00075 00076 glEnd(); 00077 }
|
DrawMatrix draws the matrix.
size | The size of the whole matrix |
number | the number of matrix-sectors |
Definition at line 87 of file outputOpengl.cpp.
00088 { 00089 float x,y,z; 00090 float step; 00091 00092 step = size/number; 00093 00094 y = 0.0; 00095 00096 GLfloat m_matrixA[] = { 0.593, 0.726, 0.961, 1.0 }; 00097 GLfloat m_matrixB[] = { 0.277, 0.347, 0.496, 1.0 }; 00098 00099 glMaterialfv(GL_FRONT,GL_DIFFUSE,m_matrixA); 00100 00101 for ( x=0.0; x <= size; x += step) 00102 { 00103 glBegin(GL_LINES); 00104 glNormal3f(0.0,1.0,0.0); 00105 glVertex3f(size-x*2,y,-size); 00106 glVertex3f(size-x*2,y,size); 00107 glEnd(); 00108 } 00109 00110 for ( z=0.0; z <= size; z += step) 00111 { 00112 glBegin(GL_LINES); 00113 glNormal3f(0.0,1.0,0.0); 00114 glVertex3f(-size,y,size-z*2); 00115 glVertex3f(size,y,size-z*2); 00116 glEnd(); 00117 } 00118 00119 step = size/(number*3.0); 00120 00121 glMaterialfv(GL_FRONT,GL_DIFFUSE,m_matrixB); 00122 00123 for ( x=0.0; x <= size; x += step) 00124 { 00125 glBegin(GL_LINES); 00126 glNormal3f(0.0,1.0,0.0); 00127 glVertex3f(size-x*2,y,-size); 00128 glVertex3f(size-x*2,y,size); 00129 glEnd(); 00130 } 00131 00132 00133 for ( z=0.0; z <= size; z += step) 00134 { 00135 glBegin(GL_LINES); 00136 glNormal3f(0.0,1.0,0.0); 00137 glVertex3f(-size,y,size-z*2); 00138 glVertex3f(size,y,size-z*2); 00139 glEnd(); 00140 } 00141 00142 }
|
DrawStat a primitive HUD-Like thing.
Definition at line 204 of file outputOpengl.cpp.
00205 { 00206 char text[40]; 00207 00208 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, m_hud ); 00209 00210 glRasterPos2i(1,WINDOWY-40); 00211 printstring(GLUT_BITMAP_TIMES_ROMAN_24,"The Matrix"); 00212 00213 glRasterPos2i(1,1); 00214 printstring(GLUT_BITMAP_TIMES_ROMAN_24,"Matrix:"); 00215 00216 IntToString ( 0, text ); 00217 glRasterPos2i(80,1); 00218 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00219 IntToString ( 0, text ); 00220 glRasterPos2i(110,1); 00221 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00222 IntToString ( 0, text ); 00223 glRasterPos2i(140,1); 00224 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00225 00226 IntToString ( (int) campos[X], text ); 00227 glRasterPos2i(200,1); 00228 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00229 IntToString ( (int) campos[Y], text ); 00230 glRasterPos2i(255,1); 00231 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00232 IntToString ( (int) campos[Z], text ); 00233 glRasterPos2i(310,1); 00234 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00235 00236 IntToString ( colObject , text ); 00237 glRasterPos2i(420,1); 00238 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00239 00240 IntToString ( myObjectID , text ); 00241 glRasterPos2i(490,1); 00242 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00243 00244 IntToString ( (int)(speednr*10) , text ); 00245 glRasterPos2i(560,1); 00246 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00247 00248 IntToString ( frametime, text ); 00249 glRasterPos2i(WINDOWX-40,WINDOWY-40); 00250 printstring(GLUT_BITMAP_TIMES_ROMAN_24,text); 00251 }
|
IntToString Converts an integer to a string.
x | the integer |
text | the char* where it shall be written into |
Definition at line 151 of file outputOpengl.cpp.
00152 { 00153 int i=0,j=10; 00154 00155 if ( x == 0) 00156 { 00157 text[0] = '0'; 00158 text[1] = '\0'; 00159 } 00160 else 00161 { 00162 i = 0; 00163 if ( x < 0 ) 00164 { 00165 text[0] = '-'; 00166 x = x * -1; 00167 i++; 00168 } 00169 00170 for ( j = x; j > 0; j = j / 10, i++); 00171 00172 i--; 00173 text[i+1] = '\0'; 00174 00175 for ( ; x > 0; x = x / 10, i--) 00176 { 00177 text[i] = (char) ( x % 10 + '0'); 00178 } 00179 } 00180 }
|
printstring prints an string into the opengl scenery.
font | the type of font |
string | the text-string |
Definition at line 189 of file outputOpengl.cpp.
00190 { 00191 int len,i; 00192 00193 len = (int) strlen(string); 00194 00195 for( i = 0; i < len; i++) 00196 glutBitmapCharacter(font,string[i]); 00197 }
|
Definition at line 22 of file outputOpengl.cpp.
|
Definition at line 21 of file outputOpengl.cpp.
|
Definition at line 17 of file outputOpengl.cpp.
|
|
|
|
|
|
Definition at line 18 of file outputOpengl.cpp.