speed typing game (former Sponge Bob s Words )
|
|
- Susanne Arnold
- vor 8 Jahren
- Abrufe
Transkript
1 project: author: website: speed typing game (former Sponge Bob s Words ) (c) 2008 Kai Kajus Noack. All rights reserved. License: CREATIVE COMMONS Attribution-Noncommercial-Share Alike 3.0 Germany You may not use this file except in compliance with the License. You may obtain a copy of the License at: Es ist Ihnen gestattet: das Werk vervielfältigen, verbreiten, öffentlich zugänglich zu machen Abwandlungen bzw. Bearbeitungen des Inhaltes anzufertigen zu den folgenden Bedingungen: Namensnennung. Sie müssen den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen. Keine kommerzielle Nutzung. Dieses Werk darf nicht für kommerzielle Zwecke verwendet werden. Weitergabe unter gleichen Bedingungen. Wenn Sie den lizenzierten Inhalt bearbeiten oder in anderer Weise umgestalten, verändern oder als Grundlage für einen anderen Inhalt verwenden, dürfen Sie den neu entstandenen Inhalt nur unter Verwendung von Lizenzbedingungen weitergeben, die mit denen dieses Lizenzvertrages identisch oder vergleichbar sind. - Im Falle einer Verbreitung müssen Sie anderen die Lizenzbedingungen, unter welche dieses Werk fällt, mitteilen. Am Einfachsten ist es, einen Link auf diese Seite einzubinden. - Jede der vorgenannten Bedingungen kann aufgehoben werden, sofern Sie die Einwilligung des Rechteinhabers dazu erhalten. - Diese Lizenz lässt die Urheberpersönlichkeitsrechte unberührt.
2 const.h Printed on , 13:26:58 Page 1 #ifndef CONSTS_H_INCLUDED #define CONSTS_H_INCLUDED // unsere Konstantent für das Spiel static const float PI = L; static const int WINWIDTH = 800; static const int WINHEIGHT = 600; static const int WORTANZAHL = 2000; static const int MAXWORTLAENGE = 15; static const int COUNTDOWN = 60; static const int MAXBLITZE = 10; #endif
3 main.h Printed on , 13:29:14 Page 1 #ifndef MAIN_H_ #define MAIN_H_ class game { public: Game(); virtual~game(); ; void initrendering(void); #endif
4 main.cpp Printed on , 13:28:56 Page 1 /****************************************************** * Kai Kajus Noack * * Project: "Game: SpongeBob's Words" * * Date: * ******************************************************/ #include <iostream> #include <stdlib.h> #include <GL/glut.h> #include <GL/gl.h> #include "text3d.h" // selbstdefinierte Konstanten #include "const.h" // zum Dateieinlesen #include <fstream> #include <iomanip> // für Casting int zu String #include <sstream> #include <string> // für Texturen #include "imageloader.h" // der Timer #include <time.h> // trigonometrische Funktionen #include <math.h> // Objekt: Wort (Spielelement) #include "Word.h" // vektor-klasse zum zeichnen #include <vector> #include "vec3f.h" using namespace std; bool blitz = false; bool psychomode = false; bool startscreen = true; bool gameover = false; // Alpha-Würfel *** START const float BOX_SIZE = 7.0f; // Seitenlänge des Würfels constfloat ALPHA=0.6f; // Durchsichtigkeit der Flächen // Vektoren geben Richtungen der Seitenfläche an struct Face{ Vec3f up; Vec3f right; Vec3f out; ; // Seitenfläche Alpha-Würfel struct Cube{ Face top; Face bottom; Face left; Face right; Face front; Face back; ; // Rotation des Vektors entsprechend der Gradangabe um die gegebene Achse Vec3f rotate(vec3f v, Vec3f axis, float degrees){ axis=axis.normalize(); float radians = degrees* PI/ 180;
5 main.cpp Printed on , 13:28:56 Page 2 float s=sin(radians); float c=cos(radians); return v*c+axis*axis.dot(v)*(1-c)+v.cross(axis)*s; // Rotation der Seitenfläche void rotate(face&face, Vec3f axis, float degrees){ face.up = rotate(face.up, axis, degrees); face.right = rotate(face.right, axis, degrees); face.out = rotate(face.out, axis, degrees); // Rotation des Würfels void rotate(cube&cube, Vec3f axis, float degrees){ rotate(cube.top, axis, degrees); rotate(cube.bottom, axis, degrees); rotate(cube.left, axis, degrees); rotate(cube.right, axis, degrees); rotate(cube.front, axis, degrees); rotate(cube.back, axis, degrees); // Vektoren-Initialisierung für die Seitenflächen void initcube(cube&cube){ cube.top.up = Vec3f(0, 0,-1); cube.top.right = Vec3f(1, 0, 0); cube.top.out = Vec3f(0, 1, 0); cube.bottom.up = Vec3f(0, 0, 1); cube.bottom.right = Vec3f(1, 0, 0); cube.bottom.out = Vec3f(0,-1, 0); cube.left.up = Vec3f(0, 0,-1); cube.left.right = Vec3f(0, 1, 0); cube.left.out = Vec3f(-1, 0, 0); cube.right.up = Vec3f(0,-1, 0); cube.right.right = Vec3f(0, 0, 1); cube.right.out = Vec3f(1, 0, 0); cube.front.up = Vec3f(0, 1, 0); cube.front.right = Vec3f(1, 0, 0); cube.front.out = Vec3f(0, 0, 1); cube.back.up = Vec3f(1, 0, 0); cube.back.right = Vec3f(0, 1, 0); cube.back.out = Vec3f(0, 0,-1); // Ist uns face1 oder face2 zugewandt bool comparefaces(face* face1, Face* face2){ return face1->out[2] < face2->out[2]; // Eckpunkte der Seitenfläche void facevertices(face&face, Vec3f* vs){ vs[0] = BOX_SIZE/ 2*(face.out- face.right- face.up); vs[1] = BOX_SIZE/ 2*(face.out- face.right + face.up); vs[2] = BOX_SIZE/ 2*(face.out + face.right + face.up); vs[3] = BOX_SIZE/ 2*(face.out + face.right- face.up); void drawtopface(face&face){
6 main.cpp Printed on , 13:28:56 Page 3 Vec3f vs[4]; facevertices(face, vs); gldisable(gl_texture_2d); glbegin(gl_quads); glcolor4f(1.0f, 1.0f, 0.0f, ALPHA); glnormal3f(face.out[0], face.out[1], face.out[2]); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); void drawbottomface(face&face){ Vec3f vs[4]; facevertices(face, vs); gldisable(gl_texture_2d); glbegin(gl_quads); glcolor4f(1.0f, 0.0f, 1.0f, ALPHA); glnormal3f(face.out[0], face.out[1], face.out[2]); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); void drawleftface(face&face){ Vec3f vs[4]; facevertices(face, vs); gldisable(gl_texture_2d); glbegin(gl_quads); glnormal3f(face.out[0], face.out[1], face.out[2]); glcolor4f(0.0f, 1.0f, 1.0f, ALPHA); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); glcolor4f(0.0f, 0.0f, 1.0f, ALPHA); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); void drawrightface(face&face){ Vec3f vs[4]; facevertices(face, vs); gldisable(gl_texture_2d); glbegin(gl_quads); glnormal3f(face.out[0], face.out[1], face.out[2]); glcolor4f(1.0f, 0.0f, 0.0f, ALPHA); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); glcolor4f(0.0f, 1.0f, 0.0f, ALPHA); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); void drawfrontface(face&face, GLuint textureid){ Vec3f vs[4]; facevertices(face, vs); glenable(gl_texture_2d); glbindtexture(gl_texture_2d, textureid); gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
7 main.cpp Printed on , 13:28:56 Page 4 gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glcolor4f(1.0f, 1.0f, 1.0f, ALPHA); glbegin(gl_quads); glnormal3f(face.out[0], face.out[1], face.out[2]); gltexcoord2f(0, 0); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); gltexcoord2f(0, 1); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); gltexcoord2f(1, 1); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); gltexcoord2f(1, 0); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); void drawbackface(face&face, GLuint textureid){ Vec3f vs[4]; facevertices(face, vs); glenable(gl_texture_2d); glbindtexture(gl_texture_2d, textureid); gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glcolor4f(1.0f, 1.0f, 1.0f, ALPHA); glbegin(gl_quads); glnormal3f(face.out[0], face.out[1], face.out[2]); gltexcoord2f(0, 0); glvertex3f(vs[0][0], vs[0][1], vs[0][2]); gltexcoord2f(0, 1); glvertex3f(vs[1][0], vs[1][1], vs[1][2]); gltexcoord2f(1, 1); glvertex3f(vs[2][0], vs[2][1], vs[2][2]); gltexcoord2f(1, 0); glvertex3f(vs[3][0], vs[3][1], vs[3][2]); glend(); // Seitenfläche auf Würfel zeichnen void drawface(face* face, Cube&cube, GLuint textureid){ if(face ==&(cube.top)){ drawtopface(cube.top); else if(face ==&(cube.bottom)){ drawbottomface(cube.bottom); else if(face ==&(cube.left)){ drawleftface(cube.left); else if(face ==&(cube.right)){ drawrightface(cube.right); else if(face ==&(cube.front)){ drawfrontface(cube.front, textureid); else{ drawbackface(cube.back, textureid); // Alpha-Würfel *** ENDE Cube _cube; // der Würfel // Timer-Variablen int minutes, sek, recenttime; // Spielzeit in Sekunden clock_t starttime, endtime; // Spielmodus: Training oder Countdown string gamemode; // Spielzeit int countdowntime = COUNTDOWN; string timespent; // Arrays + String + Zähler für Keyboard-Eingabe des Spielers
8 main.cpp Printed on , 13:28:56 Page 5 char keyboardinput[maxwortlaenge]; string eingabewort; unsigned char* keys = new unsigned char[maxwortlaenge]; int inputchar = 0; // Statistisch mitzählen int charcounter = 0; int wordcounter = 0; int wordfalse = 0; int wordright = 0; // Arrays für eingelesene Strings char allwords[wortanzahl][maxwortlaenge]; string allewoerter[wortanzahl]; // Zufallszahl für Wortauswahl int randomnr = 0; // Punkte speichern int scoreint = 0; string score; // das Wort auf dem Bildschirm Word*wort; string createnewword(void){ // initialisieren eines Random (notwendig für nä. Fkt.aufruf) srand(time(null)); // generate random number randomnr = rand()% WORTANZAHL; // zu lange Wörter ggf. kürzen if((allewoerter[randomnr]).length()>=(unsigned)maxwortlaenge){ return(allewoerter[randomnr]).substr(0,maxwortlaenge-1); return allwords[randomnr]; // Stream zwecks Umwandlung von int zu string stringstream out; string setscore(int scoredvalue){ // Punktzahl + 1 scoreint+=scoredvalue; // stream bereinigen out.str(""); out.clear(); // neue Punkte in den Stream schreiben out<< "Score: "<< scoreint; return out.str(); void resetinputstate(void){ // bisherige Eingaben löschen eingabewort.clear(); for(int j=0; j<maxwortlaenge; j++){ keyboardinput[j] = '\0'; // Position des Wortes auf Bildschirm zurücksetzen wort->resetwordpos(); // Textur-Loader GLuint loadtexture(image*image){ GLuint texture;
9 main.cpp Printed on , 13:28:56 Page 6 glgentextures(1,&texture); // Textur den Bilddaten zuordnen glbindtexture(gl_texture_2d, texture); // Mappen des Bildes auf die Textur (Bild nach OpenGL laden) glteximage2d(gl_texture_2d, 0, GL_RGB, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); //The actual pixel data // Textur-ID zurückgeben return texture; // 3D-Text bereinigen void cleanup(){ t3dcleanup(); /**** TEXTUREN ****/ GLuint _textureidfloor; GLuint _textureidsponge; // weitere Spielvariablen (Winkel) float _angle = 0.0f; float _angle2 = 0.0f; // Var. für: Verschiebung Würfel in X-Richtung je nach Punktzahl des Spielers float offsetx = 1.0; // Rendern vorbereiten void initrendering(){ glenable(gl_depth_test); glenable(gl_color_material); glenable(gl_lighting); glenable(gl_light0); glenable(gl_light1); glenable(gl_normalize); glshademodel(gl_smooth); glenable(gl_fog); glclearcolor(0.1f, 0.1f, 0.15f, 1); // Initialisierung der 3D-Schriften t3dinit(); // Bild in Textur laden Image* image = loadbmp("img/floor.bmp"); _textureidfloor = loadtexture(image); // image-objekt löschen, dann neu laden delete image; image=loadbmp("img/spongebob.bmp"); _textureidsponge=loadtexture(image); delete image; /**** PARTIKEL START ****/ const int ParticleCount = 500; typedef struct{ double Xpos; double Ypos; double Zpos; double Xmov; double Zmov; double Red;
10 main.cpp Printed on , 13:28:56 Page 7 double Green; double Blue; double Direction; double Acceleration; double Deceleration; double Scalez; bool Visible; PARTICLES; PARTICLES Particle[ParticleCount]; void glcreateparticles(void){ int i; for(i=1; i<particlecount; i++){ Particle[i].Xpos=0; Particle[i].Ypos=-5; Particle[i].Zpos=-5; Particle[i].Xmov=(((((((2-1+1)*rand()%11)+1)-1+1)*rand()%11)+1)*0.005)- (((((((2-1+1)*rand()%11)+1)-1+1)*rand()%11)+1)*0.005); Particle[i].Zmov=(((((((2-1+1)*rand()%11)+1)-1+1)*rand()%11)+1)*0.005)- (((((((2-1+1)*rand()%11)+1)-1+1)*rand()%11)+1)*0.005); Particle[i].Red=1; Particle[i].Green=1; Particle[i].Blue=1; Particle[i].Scalez=0.25; Particle[i].Direction = 0; Particle[i].Acceleration=((((((8-5+2)*rand()%11)+5)-1+1)*rand()%11)+1)*0.02; Particle[i].Deceleration = ; void glupdateparticles(void){ int i; for(i=1; i<particlecount; i++) { glcolor3f(particle[i].red, Particle[i].Green, Particle[i].Blue); Particle[i].Ypos=(Particle[i].Ypos+Particle[i].Acceleration-Particle[i].Deceleration)*0.8; // 0.8 -> cool particle effect Particle[i].Deceleration = Particle[i].Deceleration ; Particle[i].Xpos=Particle[i].Xpos+Particle[i].Xmov; Particle[i].Zpos=Particle[i].Zpos+Particle[i].Zmov; Particle[i].Direction=Particle[i].Direction+((((((int)( )*rand()%11)+1)-1+1) * rand()%11)+1); if(particle[i].ypos <-5){ Particle[i].Xpos=0; Particle[i].Ypos=-5; Particle[i].Zpos=-5; Particle[i].Red=1; Particle[i].Green=1; Particle[i].Blue=1; Particle[i].Direction = 0; Particle[i].Acceleration=((((((8-5+2)*rand()%11)+5)-1+1)*rand()%11)+1)* 0.02; Particle[i].Deceleration = ; void gldrawparticles(void){ glpushmatrix(); gltranslatef(0.0f, 10.0f,-9.0f); glrotatef(180.0f, 0.0f, 0.0f, 1.0f); glcolor3f(1.0f, 0.5f, 0.0f);
11 main.cpp Printed on , 13:28:56 Page 8 int i; gldisable(gl_lighting); // zusätzlich hinzugefügt gldisable(gl_texture_2d); for(i=1; i<particlecount; i++) { glpushmatrix(); gltranslatef(particle[i].xpos, Particle[i].Ypos, Particle[i].Zpos); glrotatef(particle[i].direction- 90, 0, 0, 1); glscalef(particle[i].scalez, Particle[i].Scalez, Particle[i].Scalez); gldisable(gl_depth_test); glenable(gl_blend); // Erklärung glblendfunc(gl_dst_color, GL_ZERO); glbegin(gl_quads); gltexcoord2d(0, 0); glvertex3f(-1,-1, 0); gltexcoord2d(1, 0); glvertex3f(1,-1, 0); gltexcoord2d(1, 1); glvertex3f(1, 1, 0); gltexcoord2d(0, 1); glvertex3f(-1, 1, 0); glend(); glblendfunc(gl_one, GL_ONE); glbegin(gl_quads); gltexcoord2d(0, 0); glvertex3f(-1,-1, 0); gltexcoord2d(1, 0); glvertex3f(1,-1, 0); gltexcoord2d(1, 1); glvertex3f(1, 1, 0); gltexcoord2d(0, 1); glvertex3f(-1, 1, 0); glend(); glenable(gl_depth_test); glpopmatrix(); glenable(gl_lighting); glpopmatrix(); void initparticles(){ glenable(gl_texture_2d); glenable(gl_depth_test); glcreateparticles(); /**** PARTIKEL ENDE ****/ void paintflyingcube(){ // Optional: // Rotes ambientes Licht neben Würfel hinzufügen // GLfloat ambientcolor[] = {0.2f, 0.2f, 0.2f, 1.0f; // gllightmodelfv(gl_light_model_ambient, ambientcolor); // GLfloat lightcolor1[] = {1.5f, 0.5f, 0.5f, 1.0f; // GLfloat lightpos1[] = {2.0f, 0.0f, 2.0f, 1.0f; // gllightfv(gl_light1, GL_DIFFUSE, lightcolor1); // gllightfv(gl_light1, GL_POSITION, lightpos1); glpushmatrix(); gltranslatef(-8.0f, 0.0f, 0.0f); glrotatef(_angle, 0.0f, 1.0f, 0.0f); glcolor3f(1.0f, 1.0f, 0.0f);
12 main.cpp Printed on , 13:28:56 Page 9 glbegin(gl_quads); // Smooth Shading (für jeden Punkt eine eigene Normale!) // Front glnormal3f(-1.0f, 0.0f, 1.0f); glvertex3f(-1.5f+offsetx,-1.0f, 1.5f); glnormal3f(1.0f, 0.0f, 1.0f); glvertex3f(1.5f+offsetx,-1.0f, 1.5f); glnormal3f(1.0f, 0.0f, 1.0f); glvertex3f(1.5f+offsetx, 1.0f, 1.5f); glnormal3f(-1.0f, 0.0f, 1.0f); glvertex3f(-1.5f+offsetx, 1.0f, 1.5f); // Rechts glnormal3f(1.0f, 0.0f,-1.0f); glvertex3f(1.5f+offsetx,-1.0f,-1.5f); glnormal3f(1.0f, 0.0f,-1.0f); glvertex3f(1.5f+offsetx, 1.0f,-1.5f); glnormal3f(1.0f, 0.0f, 1.0f); glvertex3f(1.5f+offsetx, 1.0f, 1.5f); glnormal3f(1.0f, 0.0f, 1.0f); glvertex3f(1.5f+offsetx,-1.0f, 1.5f); // Hinten glnormal3f(-1.0f, 0.0f,-1.0f); glvertex3f(-1.5f+offsetx,-1.0f,-1.5f); glnormal3f(-1.0f, 0.0f,-1.0f); glvertex3f(-1.5f+offsetx, 1.0f,-1.5f); glnormal3f(1.0f, 0.0f,-1.0f); glvertex3f(1.5f+offsetx, 1.0f,-1.5f); glnormal3f(1.0f, 0.0f,-1.0f); glvertex3f(1.5f+offsetx,-1.0f,-1.5f); // Links glnormal3f(-1.0f, 0.0f,-1.0f); glvertex3f(-1.5f+offsetx,-1.0f,-1.5f); glnormal3f(-1.0f, 0.0f, 1.0f); glvertex3f(-1.5f+offsetx,-1.0f, 1.5f); glnormal3f(-1.0f, 0.0f, 1.0f); glvertex3f(-1.5f+offsetx, 1.0f, 1.5f); glnormal3f(-1.0f, 0.0f,-1.0f); glvertex3f(-1.5f+offsetx, 1.0f,-1.5f); glend(); glpopmatrix(); int blitzzaehler = 0; void blitzen(){ // Blitz-Effekt im Hintergrund if(0==blitzzaehler%2) glclearcolor(2.0f, 2.0f, 2.0f, 1); else glclearcolor(0.1f, 0.1f, 0.15f, 1); blitzzaehler++; // auf 5 Blitze beschränken if(blitzzaehler>maxblitze){ blitz=false; blitzzaehler=0; glclearcolor(0.1f, 0.1f, 0.15f, 1); // Tastatur-Eingaben des Spielers prüfen void checkuserinput(){ wordcounter++; // bei korrekter Eingabe
13 main.cpp Printed on , 13:28:56 Page 10 if(!(wort->name.compare(eingabewort))){ wordright++; score=setscore(1); blitz=true; resetinputstate(); wort->name=createnewword(); // Würfel verschiebt sich offsetx+= 0.5; // Spezial: Eingabe zur Aktivierung der Psychomode-Grafik ;) elseif(!(eingabewort.compare("000"))){ psychomode=!psychomode; resetinputstate(); // bei Falschschreibung des Wortes else if( wort->name.compare(eingabewort)){ wordfalse++; score=setscore(-1); resetinputstate(); wort->name=createnewword(); // Würfel verschiebt sich offsetx-= 0.5; // wichtig für die Position xxx eingabewort inputchar=0; void handlekeypress(unsigned char key, int x, int y){ // Startbildschirm: if(startscreen){ switch(key){ case 27: // Escape cleanup(); exit(0); break; case '1': gamemode = "countdown"; startscreen=false; break; case '2': gamemode = "training"; startscreen=false; break; default: cout<< "falsche Eingabe"<< endl; resetinputstate(); // Spiel läuft: else if(!gameover){ charcounter++; switch(key){ case 27: // Escape cleanup(); exit(0); break; case '\r': checkuserinput(); break; default: keyboardinput[inputchar] = key;
14 main.cpp Printed on , 13:28:56 Page 11 eingabewort = keyboardinput; inputchar++; // Eingabe ist zu lang if((unsigned)inputchar>wort->name.length()){ score=setscore(-1); resetinputstate(); inputchar=0; // wenn GameOver aktiv ist: else{ switch(key){ case 27: // Escape cleanup(); exit(0); break; // Neustart des Spiels via Enter-Taste case '\r': // Neu-Initialisierungen charcounter=0; wordcounter=0; wordfalse=0; wordright=0; scoreint=0; score=setscore(0); countdowntime=countdown; starttime=clock(); offsetx=1.0f; startscreen=true; gameover=false; resetinputstate(); break; // Bodenplatte mit Wassertextur zeichnen void paintfloor(){ // Texturen aktivieren glenable(gl_texture_2d); // Flur-Textur verwenden glbindtexture(gl_texture_2d, _textureidfloor); // Bild nah oder fern, nutze GL_NEAREST Mapping gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // zeichne Boden mit Texturkoordinaten glbegin(gl_quads); // Normalen-Vektor zeigt nach oben glnormal3f(0.0, 1.0f, 0.0f); gltexcoord2f(0.0f, 0.0f); glvertex3f(-7.0f,-5.0f, 5.0f); gltexcoord2f(1.0f, 0.0f); glvertex3f(7.0f,-5.0f, 5.0f); gltexcoord2f(1.0f, 1.0f); glvertex3f(25.0f,-5.0f,-25.0f); gltexcoord2f(0.0f, 1.0f); glvertex3f(-25.0f,-5.0f,-25.0f); glend(); // Texturen deaktivieren gldisable(gl_texture_2d);
15 main.cpp Printed on , 13:28:56 Page 12 // eine Veränderung der Fenstergröße beachten void handleresize(int w, int h){ glviewport(0, 0, w, h); glmatrixmode(gl_projection); glloadidentity(); gluperspective(45.0,(double)w/(double)h, 1.0, 200.0); void moveandpaintword(string suchwort){ glcolor3f(1.0,1.0,1.0); // zeichne das frontal zu sehende Wort glpushmatrix(); // Wort bewegen gltranslatef(wort->posx, wort->posy, wort->posz); // optional: Wort rotieren // glrotatef(wort->angle, 0.0f, 1.0f, 0.0f); // Wort zeichnen t3ddraw3d(suchwort, 0, 0, 0.2f); glpopmatrix(); // Wortkopie als Reflexion auf dem Boden zeichnen glpushmatrix(); gltranslatef(wort->posx, wort->posy-9.0f, wort->posz-4.0f); glrotatef(-180.0f, 1.0f,0.0f,0.0f); glcolor4f(0.2f,0.2f,1.0f,0.5f); t3ddraw3d(suchwort, 0, 0, 0.2f); glcolor3f(0.5f, 0.5f, 0.65f); glpopmatrix(); glenable(gl_normalize); // wenn das Suchwort hinter uns ist, bringe es wieder nach vorne if(wort->posz > 12.0){ resetinputstate(); // rechts unten im Bildschirm erscheint die Eingabe des Spielers void showkeyboardinput(){ glpushmatrix(); gltranslated(5.2f,-4.5f,3.0f); glscalef(0.5f, 0.5f, 0.5f); t3ddraw3d(eingabewort, 0, 0, 0.2f); glpopmatrix(); // rechts oben erscheinen die Punkte und der Timer void showscore(){ glcolor3f(2.0f,0.0f,0.0f); glpushmatrix(); gltranslated(5.45f,4.0f,4.0f); glscalef(0.35f, 0.35f, 0.35f); t3ddraw3d(score, 0, 0, 0.2f); glpopmatrix(); void showtimer(){ glpushmatrix(); gltranslated(5.5f,4.4f,4.0f); glscalef(0.3f, 0.3f, 0.3f); glcolor3f(2.0f, 0.0f, 0.0f); t3ddraw3d(timespent, 0, 0, 0.2f); glpopmatrix(); // glcolor3f(0.3f, 1.0f, 0.3f);
16 main.cpp Printed on , 13:28:56 Page 13 // Konvertierung double convertradtoangle(double rad){ double angle0=rad*2*pi/360; return angle0; // Zahl runden double Round(double Zahl, unsigned int Stellen){ Zahl*= pow(10, Stellen); if(zahl >= 0) Zahl=floor(Zahl+0.5); else Zahl=ceil(Zahl-0.5); Zahl/= pow(10, Stellen); return Zahl; // bei Spielstart anzeigen void showstartscreen(){ gldisable(gl_fog); glpushmatrix(); gltranslated(0.0f,0.0f,-3.0f); glcolor3f(1.5f, 1.5f, 0.5f); t3ddraw3d("wahl des Modus:\n1 - Countdown\n2 - Training", 0, 0, 0.2f); glpopmatrix(); glenable(gl_fog); // beim Gameover anzeigen void showgameover(double result){ glpushmatrix(); gltranslated(0.0f,-2.0f,3.0f); glrotatef(_angle, 0.5f, 1.0f, 0.5f); _angle-= 0.5f; glcolor3f(0.2f, 0.2f, 1.0f); t3ddraw3d("game Over!", 0, 0, 0.2f); glpopmatrix(); // Ausgabe des erzielten Ergebnisses glpushmatrix(); gltranslated(0.0f,1.0f+cos(convertradtoangle(_angle)),0.0f); glscalef(0.5f, 0.5f, 0.5f); glcolor3f(0.2f, 1.0f, 0.2f); // Lösche Daten aus Stream out.str(""); out.clear(); // Schreibe neue Daten in Stream (beachte negatives oder Null-Ergebnis) if(result<=0) out<< "Oh, keine Woerter richtig :("; else out<< "Super! "<< scoreint<< " Punkte!\n\n "<< Round(result,3)<< " Sekunden pro Wort!\n\n" << wordright<< " von "<< wordcounter<< " Woertern richtig!\n"<< "Fehlerquote: "<< Round(((float)( wordfalse)/(float)(wordcounter))*100, 2) << "%" << "\n\n" << charcounter*(60.0f/(float)countdown) << " Anschlaege pro Minute"; // String aus dem Stream generieren und an Text-Zeichner übergeben t3ddraw3d(out.str(), 0, 0, 0.2f); glpopmatrix(); // Nebeleffekt (+ versteckte psychomode-grafik) void paintfog(){ GLfloat fogcolor[] ={0.5f, 0.5f, 0.5f, 1; glfogfv(gl_fog_color, fogcolor);
17 main.cpp Printed on , 13:28:56 Page 14 glfogi(gl_fog_mode, GL_LINEAR); glfogf(gl_fog_start, 4.0f); glfogf(gl_fog_end, 25.0f); if(psychomode){ double r=20.0f; double tiefec = 8.0f; int stepf = 90; glcolor3f(1.0f,0.0f,0.0f); glpushmatrix(); gltranslatef(0.0f,0.0f,-20.0f); // eine interessante Rotation der Box glrotatef(_angle2, cos(convertradtoangle(_angle)), 0.5f, 1.0f); tiefec); 0.0f); for(int angl = 45; angl <= 315; angl+=stepf){ glbegin(gl_polygon); // Box wird sehr verschiedenfarbig glcolor3f(cos(convertradtoangle(angl)), sin(convertradtoangle(angl)), 0.0f); glvertex3f(r*cos(convertradtoangle(angl)), r*sin(convertradtoangle(angl)), 0.0f); glvertex3f(r*cos(convertradtoangle(angl)), r*sin(convertradtoangle(angl)), tiefec); glvertex3f(r*cos(convertradtoangle(angl+stepf)), r*sin(convertradtoangle(angl+stepf)), glvertex3f(r*cos(convertradtoangle(angl+stepf)), r*sin(convertradtoangle(angl+stepf)), glend(); glpopmatrix(); // zeichne die von mir erdachte "cos-sin-krone" glcolor3f(1.0f,0.0f,0.0f); glpushmatrix(); gltranslatef(0.0f,0.0f,-15.0f); double tiefe = 25.0f; double nextstep = 15.0f; double radius = 5.5f; double paintangle, nextstage; glrotatef(_angle2*5, 0.1f, 0.1f, 1.0f); for(double recentangle = 0; recentangle <= 360; recentangle+=nextstep){ glcolor3f(cos(convertradtoangle(recentangle)), sin(convertradtoangle(recentangle)), 0.0f); paintangle=convertradtoangle(recentangle); nextstage=convertradtoangle(recentangle+nextstep); glbegin(gl_polygon); glvertex3f(radius*cos(paintangle),radius*sin(paintangle),0.0f); glvertex3f(radius*cos(paintangle),radius*sin(paintangle),tiefe-21.0f); glvertex3f(radius*cos(nextstage),radius*sin(nextstage),tiefe); glvertex3f(radius*cos(nextstage),radius*sin(nextstage),0.0f); glend(); glpopmatrix(); // Zeit ermitteln und auf Bildschirm ausgeben je nach Spielmodus stringstream outtime; void writetime(){ // Stream löschen outtime.str(""); outtime.clear(); if(gamemode=="training"){ if(sek>= 60){ sek=0;
18 main.cpp Printed on , 13:28:56 Page 15 minutes++; if(sek < 10) outtime << "Time " << minutes << ":0" << sek << endl; else{ outtime<< "Time "<< minutes<< ":"<< sek<< endl; else if(gamemode=="countdown"){ outtime<< "Time: "<< countdowntime<< endl; timespent=outtime.str(); // Viereck-Bild von Spongebob auf Boden zeichnen void paintspongebob(){ gldisable(gl_fog); glpushmatrix(); glenable(gl_texture_2d); gltranslatef(-7.0+(float)(scoreint/3.0),-3.0,1.0); glrotatef(scoreint*5,0.0,1.0,0.0); // Spongebob-Textur anwenden glbindtexture(gl_texture_2d, _textureidsponge); gltexparameteri(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gltexparameteri(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glbegin(gl_quads); glnormal3f(0.0, 1.0f, 0.0f); gltexcoord2f(0.0f, 0.0f); glvertex3f(0.0f, 0.0f, 3.0f); gltexcoord2f(1.0f, 0.0f); glvertex3f(0.0f, 0.0f, 0.0f); gltexcoord2f(1.0f, 1.0f); glvertex3f(3.0f, 0.0f, 0.0f); gltexcoord2f(0.0f, 1.0f); glvertex3f(3.0f, 0.0f, 3.0f); glend(); gldisable(gl_texture_2d); glpopmatrix(); glenable(gl_fog); // Alpha-Würfel wird größer, je mehr Punkte der Spieler erreicht float cubescale = 0.0f; void paintalphacube(){ gldisable(gl_fog); glenable(gl_blend); // alpha blending aktivieren glblendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA); // Blendfunktion bestimmen glpushmatrix(); cubescale=1.0+(float)scoreint/20.0; glscalef(cubescale,cubescale,cubescale); gltranslatef(0.0f,2.0f,-35.0f+float(scoreint)); vector<face*> faces; faces.push_back(&(_cube.top)); faces.push_back(&(_cube.bottom)); faces.push_back(&(_cube.left)); faces.push_back(&(_cube.right)); faces.push_back(&(_cube.front)); faces.push_back(&(_cube.back)); // Seitenflächen sortieren von hinten nach vorne sort(faces.begin(), faces.end(), comparefaces); for(unsignedint i=0; i<faces.size(); i++){ drawface(faces[i], _cube, _textureidsponge);
19 main.cpp Printed on , 13:28:56 Page 16 glpopmatrix(); glenable(gl_fog); // gesamte Szene zeichnen (im Loop) void drawscene(){ glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0f, 0.0f,-8.0f); // Licht einstellen GLfloat ambientcolor[] ={0.4f, 0.4f, 0.4f, 1.0f; gllightmodelfv(gl_light_model_ambient, ambientcolor); GLfloat lightcolor0[] ={0.6f, 0.6f, 0.6f, 1.0f; GLfloat lightpos0[] ={-0.5f, 0.5f, 1.0f, 0.0f; gllightfv(gl_light0, GL_DIFFUSE, lightcolor0); gllightfv(gl_light0, GL_POSITION, lightpos0); glscalef(0.5, 0.5, 0.5); glcolor3f(0.3f, 1.0f, 0.3f); if(!startscreen){ // Zeit für den Trainingsmodus if(gamemode=="training"){ endtime=clock(); recenttime=(endtime-starttime)/1000; if(recenttime>0){ starttime=clock(); endtime=clock(); sek++; // Timer für Modus Countdown if(gamemode=="countdown"){ endtime=clock(); recenttime=(endtime-starttime)/1000; if(recenttime>0){ starttime=clock(); endtime=clock(); countdowntime--; if(countdowntime <= 0) gameover = true; writetime(); glupdateparticles(); gldrawparticles(); // SPIELENDE if(gameover){ // kalkuliere Punkte + Statistik double result; if(scoreint <= 0) result = 0; else result = double(countdown)/double(scoreint); showgameover(result); // SPIELSTART else if(startscreen){ showstartscreen(); // SPIEL LÄUFT!
20 main.cpp Printed on , 13:28:56 Page 17 else{ // bewege das Wort moveandpaintword(wort->name); // zeige bereits eingebenes Wort showkeyboardinput(); // Grafikelemente zeichnen paintfog(); paintfloor(); paintspongebob(); paintflyingcube(); paintalphacube(); gldisable(gl_depth_test); // Depth Testing ausschalten (zeichnet somit nur auf Vordergrund) showtimer(); showscore(); glenable(gl_depth_test); // Depth Testing wieder anschalten gldisable(gl_blend); // Turn Blending Off // blitzen, falls Wort richtig eingegeben if(blitz==true) blitzen(); glutswapbuffers(); // sich verändernde Paramter zur Belebung der Szene void update(int value){ wort->posz+= 0.1f; _angle+= 1.5f; wort->angle+= 0.1f; _angle2+= 0.2f; // alpha cube drehen rotate(_cube, Vec3f(1, 1, 0), 1); glutpostredisplay(); gluttimerfunc(25, update, 0); // Wortliste einlesen und verfügbar machen void initwordlist(void){ // Dateiname wählen char datei[] = "wordlist.txt"; // Datei öffnen und einlesen ifstream filestream(datei, ios::in); // wenn Einlesen erfolgreich if(filestream.good()){ // Dateizeiger ans Ende der Datei positionieren filestream.seekg(0l,ios::end); // Ausgabe der Datei-Eigenschaften (Konsole) cout << "Datei: " << datei << "\t Size: " << filestream.tellg() << " Bytes" << endl; // Dateizeiger an den Datei-Anfang positionieren filestream.seekg(0l,ios::beg); // lese Wort für Wort ein: for(int j=0; j<wortanzahl; j++){ filestream.getline(allwords[j],wortanzahl*maxwortlaenge); // allewoerter[j] = allwords[j]; else cout<< "Dateifehler oder Datei nicht gefunden!"<< endl;
21 main.cpp Printed on , 13:28:56 Page 18 int main(int argc, char** argv){ glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutinitwindowsize(winwidth, WINHEIGHT); glutcreatewindow("spongebob's Words 1.0"); initrendering(); initwordlist(); wort = new Word(createNewWord()); score=setscore(0); glutdisplayfunc(drawscene); glutkeyboardfunc(handlekeypress); glutreshapefunc(handleresize); gluttimerfunc(25, update, 0); // schreibe Timer-Startzeit starttime=clock(); // weitere Initialisierungen initparticles(); initcube(_cube); glutmainloop(); return 0;
22 text3d.h Printed on , 13:30:14 Page 1 /* File for "Drawing Text" lesson of the OpenGL tutorial on * */ #ifndef TEXT_3D_H_INCLUDED #define TEXT_3D_H_INCLUDED #include <string> //Initializes 3D text. Must be called before other functions in this header. void t3dinit(); //Frees memory allocated for 3D text. No other functions in this header may be //called after this one. void t3dcleanup(); /* Draws the specified string, using OpenGL, as a set of polygons in the x-y * plane, with the top of the letters having the greatest y coordinate. The * normals point in the positive z direction. (If you need the normals to point * in the positive z direction on one side of the characters and the negative z * direction on the other, call t3ddraw3d with a very small depth.) * * The string is drawn left-aligned if halign is negative, right-aligned if it * is positive, and centered horizontally if it is 0. The string is drawn top- * aligned if valign is negative, bottom-aligned if it is positive, and centered * vertically if it is 0. * * The string may have newline characters, in which case the string will be * drawn on multiple lines as one would expect. The lines are drawn lineheight * times the height of the font apart. The height of the font is the "normal" * height of capital letters, rather than the distance from the top of "normal" * capital letters to the bottom of lowercase letters like "p". * * All unprintable ASCII characters (other than '\n') are drawn as spaces. */ void t3ddraw2d(std::string str, int halign, int valign, float lineheight = 1.5f); /* Draws the specified string, using OpenGL, using polygons as a right prism, * where the parallel faces are letters parallel to the x-y plane, with the top * of the letters having the greatest y coordinate. * * The string is drawn left-aligned if halign is negative, right-aligned if it * is positive, and centered horizontally if it is 0. The string is drawn top- * aligned if valign is negative, bottom-aligned if it is positive, and centered * vertically if it is 0. * * The string may have newline characters, in which case the string will be * drawn on multiple lines as one would expect. The lines are drawn lineheight * times the height of the font apart. The height of the font is the "normal" * height of capital letters, rather than the distance from the top of "normal" * capital letters to the bottom of lowercase letters like "p". * * The depth of the characters is depth times the height of the font. The * characters are centered at z = 0. * * All unprintable ASCII characters (other than '\n') are drawn as spaces. */ void t3ddraw3d(std::string str, int halign, int valign, float depth, float lineheight = 1.5f); /* Returns the draw width of the specified string, as a multiple of the height
23 text3d.h Printed on , 13:30:14 Page 2 * of the font. The height of the font is the "normal" height of capital * letters, rather than the distance from the top of "normal" capital letters to * the bottom of lowercase letters like "p". The width is the same as the width * of the longest line. */ float t3ddrawwidth(std::string str); /* Returns the draw height of the specified string, as a multiple of the height * of the font. The height of the font is the "normal" height of capital * letters, rather than the distance from the top of "normal" capital letters to * the bottom of lowercase letters like "p". The draw is lineheight times one * fewer than the number of lines in the string, plus 1. */ float t3ddrawheight(std::string str, float lineheight = 1.5f); //Indicates that an exception occurred when setting up 3D text class T3DLoadException{ private: std::string message0; public: T3DLoadException(std::string message1); std::string message()const; ; #endif
24 text3d.cpp Printed on , 13:29:58 Page 1 /* File for "Drawing Text" lesson of the OpenGL tutorial on * */ /* The 3D font is stored in an external file called "charset", which is * basically a compact way of representing a series of OpenGL commands for * drawing each of the printable ASCII characters, other than the space * character (33 to 126). The file has the following format: * * * * the characters "VTR\0FNT\0" * float space_width (the width of ' ', relative to the height the font) * * float char_33_scale * unsigned short char_33_width (width = value * scale / 65536) * unsigned short char_33_height (height = value * scale / 65536) * unsigned short char_33_num_verts * unsigned short char_33_vert_1_x (x = value * scale / scale / 2) * unsigned short char_33_vert_1_y (y = value * scale / scale / 2) * unsigned short char_33_vert_2_x (x = value * scale / scale / 2) * unsigned short char_33_vert_2_y (y = value * scale / scale / 2) *... * unsigned short char_33_vert_n_x (x = value * scale / scale / 2) * unsigned short char_33_vert_n_y (y = value * scale / scale / 2) * unsigned short opcode_1_for_char_33_front_face * unsigned short opcode_2_for_char_33_front_face *... * unsigned short opcode_n_for_char_33_front_face * unsigned short end_part_opcode * unsigned short opcode_1_for_char_33_3d_part * unsigned short opcode_2_for_char_33_3d_part *... * unsigned short opcode_n_for_char_33_3d_part * unsigned short end_part_opcode * * float char_34_scale *... * * * The character models are centered at (0, 0[, 0]). * * unsigned shorts are represented in little-endian format. floats are * represented using one signed character exp followed by one signed integer * mant, presented in little-endian format. This represents the number * mant * 2^exp if mant is positive and -(~mant * 2^exp) if mant is negative. * * The opcodes are as follows: * * 0 to num_verts - 1: * vertex with the same index as the opcode, using the vertex on the front * face (the one with normal (0, 0, 1)) * num_verts to 2 * num_verts - 1: * Vertex with index opcode - num_verts, using the vertex on the back face * (the one with normal (0, 0, -1)). This opcode is only available for the * 3D part of each model. * 65532: * Normal vector. Followed by an unsigned short indicating the angle of the * vector divided by (2 pi) times The normal vector indicated is * (cos theta, sin theta, 0). This opcode is only available for the 3D part * of each model. * 65533: GL_TRIANGLE_STRIP * 65534: GL_TRIANGLES
25 text3d.cpp Printed on , 13:29:58 Page 2 * 65535: end_part * * Vertices must be specified in counterclockwise order, or, in the case of * triangle strips, they must be specified such that the first three vertices * indicate a triangle in counterclockwise order. When specifying the 2D part * of the model, counterclockwise order is relative to the front face. */ #include <fstream> #include <math.h> #ifdef APPLE #include <OpenGL/OpenGL.h> #include <GLUT/glut.h> #else #include <GL/glut.h> #endif #include "text3d.h" using namespace std; T3DLoadException::T3DLoadException(string message1): message0(message1){ string T3DLoadException::message() const{ return message0; namespace{ //Converts a four-character array to an integer, using little-endian form int toint(const char* bytes){ return int(((unsigned char)bytes[3] << 24) ((unsigned char)bytes[2] << 16) ((unsigned char)bytes[1] << 8) (unsigned char)bytes[0]); //Converts a five-character array to a float, as indicated in the comment at //the top of this file float tofloat(const char* buffer){ char exp = buffer[0]; int mant = toint(buffer + 1); bool isnegative; if(mant<0){ isnegative = true; mant=~mant; else isnegative = false; float a =( u +(unsigned int)mant)* pow(2.0f, exp)/ ; return isnegative?-a: a; //Converts a two-character array to an unsigned short, using little-endian //form unsigned short toushort(const char* buffer){ return(((unsigned short)((unsigned char)buffer[1])) << 8) + (unsigned short)((unsigned char)buffer[0]);
26 text3d.cpp Printed on , 13:29:58 Page 3 //Just like auto_ptr, but for arrays template<class T> class auto_array{ private: T* array; mutable bool isreleased; public: explicit auto_array(t* array_ = NULL): array(array_), isreleased(false){ auto_array(const auto_array<t>&aarray){ array=aarray.array; isreleased = aarray.isreleased; aarray.isreleased = true; ~auto_array(){ if(!isreleased&& array!= NULL){ delete[] array; T* get()const{ return array; T&operator*()const{ return*array; void operator=(const auto_array<t>&aarray){ if(!isreleased&& array!= NULL){ delete[] array; array=aarray.array; isreleased = aarray.isreleased; aarray.isreleased = true; T* operator->() const{ return array; T* release(){ isreleased = true; return array; void reset(t* array_ = NULL){ if(!isreleased&& array!= NULL){ delete[] array; array=array_; T* operator+(int i){ return array + i; T&operator[](int i){ return array[i];
27 text3d.cpp Printed on , 13:29:58 Page 4 ; enum Opcodes{OP_NORMAL=65532, OP_TRIANGLE_STRIP, OP_TRIANGLES, OP_END_PART; const float PI_TIMES_2_OVER_65536 = 2* f/ f; class T3DFont{ private: float spacewidth; float widths[94]; GLuint displaylistid2d; GLuint displaylistid3d; public: //Loads the specified font file into a new T3DFont object T3DFont(ifstream&input){ char buffer[8]; input.read(buffer, 8); if(input.fail()){ throw T3DLoadException("Invalid font file"); const char header[9] = "VTR\0FNT\0"; for(int i=0; i<8; i++){ if(buffer[i]!= header[i]){ throw T3DLoadException("Invalid font file"); input.read(buffer, 5); spacewidth=tofloat(buffer); displaylistid2d = glgenlists(94); displaylistid3d = glgenlists(94); for(int i=0; i<94; i++){ input.read(buffer, 5); float scale = tofloat(buffer)/ 65536; input.read(buffer, 2); float width = scale* toushort(buffer); input.read(buffer, 2); float height = scale* toushort(buffer); scale/= height; widths[i] = width/ height; input.read(buffer, 2); unsigned short numverts = toushort(buffer); auto_array<float> verts(new float[2* numverts]); float* verts2 = verts.get(); for(int j=0; j<numverts; j++){ input.read(buffer, 2); verts2[2* j] = scale*((int)toushort(buffer) ); input.read(buffer, 2); verts2[2*j+1]= scale*((int)toushort(buffer) ); //Face part of the model glnewlist(displaylistid2d + i, GL_COMPILE); glnormal3f(0, 0, 1); input.read(buffer, 2);
28 text3d.cpp Printed on , 13:29:58 Page 5 unsigned short opcode = toushort(buffer); switch(opcode){ case OP_TRIANGLES: glbegin(gl_triangles); break; case OP_TRIANGLE_STRIP: glbegin(gl_triangle_strip); break; default: throw T3DLoadException("Invalid font file"); //Prevents excessive iteration or infinite loops on invalid //font files int limit=10000; while(true){ input.read(buffer, 2); opcode = toushort(buffer); switch(opcode){ case OP_TRIANGLES: glend(); glbegin(gl_triangles); break; case OP_TRIANGLE_STRIP: glend(); glbegin(gl_triangle_strip); break; case OP_END_PART: goto BreakOuter; default: glvertex3f(verts2[2*opcode], verts2[2*opcode+1], 0); break; BreakOuter: if(--limit== 0){ glendlist(); throw T3DLoadException("Invalid font file"); glend(); glendlist(); //3D part of the model glnewlist(displaylistid3d + i, GL_COMPILE); glpushmatrix(); gltranslatef(0, 0, 0.5f); glfrontface(gl_cw); glcalllist(displaylistid2d + i); gltranslatef(0, 0,-1); glscalef(1, 1,-1); glfrontface(gl_ccw); glcalllist(displaylistid2d + i); glfrontface(gl_cw); input.read(buffer, 2); opcode = toushort(buffer); switch(opcode){ case OP_TRIANGLES: glbegin(gl_triangles);
29 text3d.cpp Printed on , 13:29:58 Page 6 break; case OP_TRIANGLE_STRIP: glbegin(gl_triangle_strip); break; default: throw T3DLoadException("Invalid font file"); limit = 10000; while(true){ input.read(buffer, 2); opcode = toushort(buffer); switch(opcode){ case OP_TRIANGLES: glend(); glbegin(gl_triangles); break; case OP_TRIANGLE_STRIP: glend(); glbegin(gl_triangle_strip); break; case OP_NORMAL: input.read(buffer, 2); float angle; angle = toushort(buffer)* PI_TIMES_2_OVER_65536; float x, y; x=cos(angle); y=sin(angle); glnormal3f(x, y, 0); break; case OP_END_PART: goto BreakOuter2; default: if(opcode<numverts){ glvertex3f(verts2[2*opcode], verts2[2*opcode+1], 0); else{ glvertex3f(verts2[2*(opcode- numverts)], verts2[2*(opcode- numverts) + 1], -1); break; BreakOuter2: if(--limit== 0){ glendlist(); throw T3DLoadException("Invalid font file"); glend(); glpopmatrix(); glendlist(); if(input.fail()){ throw T3DLoadException("Invalid font file"); input.read(buffer, 1);
30 text3d.cpp Printed on , 13:29:58 Page 7 if(!input.eof()){ throw T3DLoadException("Invalid font file"); void draw2d(char c){ if(c>= 33&& c<= 126){ glcalllist(displaylistid2d+c-'!'); void draw3d(char c){ if(c>= 33&& c<= 126){ glcalllist(displaylistid3d+c-'!'); ; float width(char c){ if(c>= 33&& c<= 126){ return widths[c- 33]; else{ return spacewidth; T3DFont* font=null; //The font used to draw 2D and 3D characters void draw2d(char c){ font->draw2d(c); void draw3d(char c){ font->draw3d(c); void drawline(const char* str, int halign, void(*drawfunc)(char)){ glpushmatrix(); if(halign>= 0){ float width = 0; for(int i=0; str[i]!= '\n'&& str[i]!= '\0'; i++){ width+= font->width(str[i]); gltranslatef(halign > 0?-width:-width/ 2, 0, 0); for(int i=0; str[i]!= '\n'&& str[i]!= '\0'; i++){ float width = font->width(str[i]); gltranslatef(width/ 2, 0, 0); drawfunc(str[i]); gltranslatef(width/ 2, 0, 0); glpopmatrix(); void draw(const char* str, int halign, int valign, float lineheight, void(*drawfunc)(char)){ GLint shademodel; glgetintegerv(gl_shade_model,&shademodel);
31 text3d.cpp Printed on , 13:29:58 Page 8 glshademodel(gl_smooth); GLboolean lightsenabled; glgetbooleanv(gl_lighting,&lightsenabled); GLboolean normalswerenormalized; glgetbooleanv(gl_normalize,&normalswerenormalized); if(lightsenabled){ glenable(gl_normalize); else{ gldisable(gl_normalize); glpushmatrix(); if(valign>= 0){ int numlines = 1; for(int i=0; str[i]!= '\0'; i++){ if(str[i]== '\n'){ numlines++; float height = lineheight*(numlines- 1) + 1; gltranslatef(0, valign > 0? height: height/ 2, 0); gltranslatef(0,-0.5f, 0); drawline(str, halign, drawfunc); for(int i=0; str[i]!= '\0'; i++){ if(str[i]== '\n'){ gltranslatef(0,-lineheight, 0); drawline(str + i + 1, halign, drawfunc); glpopmatrix(); glshademodel(shademodel); if(normalswerenormalized){ glenable(gl_normalize); else{ gldisable(gl_normalize); void t3dinit(){ if(font== NULL){ ifstream input; input.open("charset", istream::binary); font = new T3DFont(input); input.close(); void t3dcleanup(){ delete font; void t3ddraw2d(string str, int halign, int valign, float lineheight){ GLboolean wasculling; glgetbooleanv(gl_cull_face,&wasculling); gldisable(gl_cull_face);
32 text3d.cpp Printed on , 13:29:58 Page 9 draw(str.c_str(), halign, valign, lineheight, draw2d); if(wasculling){ glenable(gl_cull_face); void t3ddraw3d(string str, int halign, int valign, float depth, float lineheight){ GLboolean wasculling; glgetbooleanv(gl_cull_face,&wasculling); glenable(gl_cull_face); GLint frontface; glgetintegerv(gl_front_face,&frontface); glpushmatrix(); glscalef(1, 1, depth); draw(str.c_str(), halign, valign, lineheight, draw3d); glpopmatrix(); if(!wasculling){ gldisable(gl_cull_face); glfrontface(frontface); float t3ddrawwidth(string str){ float bestwidth = 0; int i=0; while(str[i]!= '\0'){ float width = 0; while(str[i]!= '\n'&& str[i]!= '\0'){ width+= font->width(str[i]); i++; if(width > bestwidth){ bestwidth=width; if(str[i]!= '\0'){ i++; return bestwidth; float t3ddrawheight(string str, float lineheight){ int numlines = 1; for(int i=0; str[i]!= '\0'; i++){ if(str[i]== '\n'){ numlines++; return(numlines- 1)* lineheight + 1;
33 imageloader.h Printed on , 13:27:48 Page 1 /* File for "Fog" lesson of the OpenGL tutorial on * */ #ifndef IMAGE_LOADER_H_INCLUDED #define IMAGE_LOADER_H_INCLUDED //Represents an image class Image{ public: Image(char* ps,int w,int h); ~Image(); ; /* An array of the form (R1, G1, B1, R2, G2, B2,...) indicating the * color of each pixel in image. Color components range from 0 to 255. * The array starts the bottom-left pixel, then moves right to the end * of the row, then moves up to the next column, and so on. This is the * format in which OpenGL likes images. */ char* pixels; int width; int height; //Reads a bitmap image from file. Image* loadbmp(const char* filename); #endif
34 imageloader.cpp Printed on , 13:27:33 Page 1 /* File for "Fog" lesson of the OpenGL tutorial on * */ #include <assert.h> #include <fstream> #include "imageloader.h" using namespace std; Image::Image(char* ps, int w, int h): pixels(ps), width(w), height(h){ Image::~Image(){ delete[] pixels; namespace{ //Converts a four-character array to an integer, using little-endian form int toint(const char* bytes){ return(int)(((unsigned char)bytes[3] << 24) ((unsigned char)bytes[2] << 16) ((unsigned char)bytes[1] << 8) (unsigned char)bytes[0]); //Converts a two-character array to a short, using little-endian form short toshort(const char* bytes){ return(short)(((unsigned char)bytes[1] << 8) (unsigned char)bytes[0]); //Reads the next four bytes as an integer, using little-endian form int readint(ifstream&input){ char buffer[4]; input.read(buffer, 4); return toint(buffer); //Reads the next two bytes as a short, using little-endian form short readshort(ifstream&input){ char buffer[2]; input.read(buffer, 2); return toshort(buffer); //Just like auto_ptr, but for arrays template<class T> class auto_array{ private: T* array; mutable bool isreleased; public: explicit auto_array(t* array_ = NULL): array(array_), isreleased(false){ auto_array(const auto_array<t>&aarray){ array=aarray.array;
35 imageloader.cpp Printed on , 13:27:33 Page 2 isreleased = aarray.isreleased; aarray.isreleased = true; ~auto_array(){ if(!isreleased&& array!= NULL){ delete[] array; T* get()const{ return array; T&operator*()const{ return*array; void operator=(const auto_array<t>&aarray){ if(!isreleased&& array!= NULL){ delete[] array; array=aarray.array; isreleased = aarray.isreleased; aarray.isreleased = true; T* operator->() const{ return array; T* release(){ isreleased = true; return array; void reset(t* array_ = NULL){ if(!isreleased&& array!= NULL){ delete[] array; array=array_; T* operator+(int i){ return array + i; ; T&operator[](int i){ return array[i]; Image* loadbmp(const char* filename){ ifstream input; input.open(filename, ifstream::binary); assert(!input.fail()!"could not find file"); char buffer[2]; input.read(buffer, 2); assert(buffer[0] == 'B'&& buffer[1] == 'M'!"Not a bitmap file"); input.ignore(8); int dataoffset = readint(input);
36 imageloader.cpp Printed on , 13:27:33 Page 3 //Read the header int headersize = readint(input); int width; int height; switch(headersize){ case 40: //V3 width=readint(input); height=readint(input); input.ignore(2); assert(readshort(input)== 24!"Image is not 24 bits per pixel"); assert(readshort(input)== 0!"Image is compressed"); break; case 12: //OS/2 V1 width=readint(input); height=readint(input); input.ignore(2); assert(readshort(input)== 24!"Image is not 24 bits per pixel"); break; case 64: //OS/2 V2 assert(!"can't load OS/2 V2 bitmaps"); break; case 108: //Windows V4 assert(!"can't load Windows V4 bitmaps"); break; case 124: //Windows V5 assert(!"can't load Windows V5 bitmaps"); break; default: assert(!"unknown bitmap format"); //Read the data int bytesperrow=((width*3+3)/4)*4-(width*3%4); int size = bytesperrow* height; auto_array<char> pixels(new char[size]); input.seekg(dataoffset, ios_base::beg); input.read(pixels.get(), size); //Get the data into the right format auto_array<char> pixels2(new char[width* height* 3]); for(int y=0; y<height; y++){ for(int x=0; x<width; x++){ for(int c=0; c<3; c++){ pixels2[3*(width*y+x)+c]= pixels[bytesperrow*y+3*x+(2-c)]; input.close(); return new Image(pixels2.release(), width, height);
37 vec3f.h Printed on , 13:30:52 Page 1 /* Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above notice and this permission notice shall be included in all copies * or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* File for "Alpha Blending" lesson of the OpenGL tutorial on * */ #ifndef VEC3F_H_INCLUDED #define VEC3F_H_INCLUDED #include <iostream> class Vec3f{ private: float v[3]; public: Vec3f(); Vec3f(float x, float y, float z); float&operator[](int index); float operator[](int index) const; Vec3f operator*(float scale) const; Vec3f operator/(float scale) const; Vec3foperator+(const Vec3f&other)const; Vec3foperator-(const Vec3f&other)const; Vec3foperator-()const; const Vec3f&operator*=(float scale); const Vec3f&operator/=(float scale); const Vec3f&operator+=(const Vec3f&other); const Vec3f&operator-=(const Vec3f&other); ; float magnitude() const; float magnitudesquared() const; Vec3f normalize()const; float dot(const Vec3f&other) const; Vec3f cross(const Vec3f&other)const; Vec3f operator*(float scale, const Vec3f&v); std::ostream&operator<<(std::ostream&output,const Vec3f&v);
Up and Down - Projekt mit dem AT90USB162
Up and Down - Projekt mit dem AT90USB162 Über diese Dokumentation: Projekt geplant, durchgeführt und ausgearbeitet von: Florian Patzer Erweiterte Projektangaben: Dieses Projekt wurde im Rahmen des Datenverarbeitungsunterrichts
MehrInptools-Handbuch. Steffen Macke
Inptools-Handbuch Steffen Macke Inptools-Handbuch Steffen Macke Veröffentlicht $Date 2014-01-28$ Copyright 2008, 2009, 2011, 2012, 2014 Steffen Macke Dieses Dokument wurde unter der GNU-Lizenz für freie
MehrProjektarbeit: Roulette Spiel
Projektarbeit: Roulette Spiel auf dem Atmega162 Im Fach Datenverarbeitungstechnik 1. Aufgabestellung Die Aufgabe verlangte es ein Reaktionsspiel auf einem Olimex AVR USB 162 zu entwerfen. Auf dem Entwicklerboard
MehrProjektarbeit aus der Datenverarbeitung. Lotto. von: Hubert Schlenk Olimex AVR USB 162 Entwicklerboard Hubert Schlenk
Projektarbeit aus der Datenverarbeitung Lotto von: Hubert Schlenk 21.07.2010 Olimex AVR USB 162 Entwicklerboard 2010 Hubert Schlenk Aufgabenstellung: Die Aufgabe war die Entwicklung eines kleinen Programmes
MehrHochschule Darmstadt Informatik-Praktikum (INF 1) WS 2014/2015 Wirtschaftsingenieur Bachelor 4. Aufgabe Datenstruktur, Dateieingabe und -ausgabe
Aufgabenstellung Für ein Baumkataster sollen für maximal 500 Bäume Informationen gespeichert werden, die alle nach der gleichen Weise wie folgt strukturiert sind: Nummer Bauminfo Baumart Hoehe Baum Umfang
MehrAddieren und Subtrahieren mit Mikrocontroller Atmega AT90162USB
Addieren und Subtrahieren mit Mikrocontroller Atmega AT90162USB Projekt: Markus Sellner Hardware: AT90USB162 auf Entwicklerplatine AVR-USB-162 von Olimex erweitert um zwei 7-Segment-Anzeigen Aufgabe: Mit
MehrVbs To Exe converts VBS (.vbs) files to the EXE (.exe) format.
Vbs To Exe - Help Index 1 - Program description 1.1 Description 1.2 Usage 1.3 Options 1.4 Commandline 1.5 Environment variables 1.6 System requirements 2 - License 2.1 License 2.2 Miscelleanous 3 - Contact
MehrInformatik - Übungsstunde
Informatik - Übungsstunde Jonas Lauener (jlauener@student.ethz.ch) ETH Zürich Woche 08-25.04.2018 Lernziele const: Reference const: Pointer vector: iterator using Jonas Lauener (ETH Zürich) Informatik
MehrAngewandte Mathematik und Programmierung
Angewandte Mathematik und Programmierung Einführung in das Konzept der objektorientierten Anwendungen zu mathematischen Rechnens SS2013 Inhalt Projekt Vorlesung: praktische Implementierung üben Ein und
MehrComputergrafik 1 Übung
Prof. Dr. Andreas Butz Dipl.-Medieninf. Hendrik Richter Dipl.-Medieninf. Raphael Wimmer Computergrafik 1 Übung Meshes http://codeidol.com/img/illustrator-cs/54084xfg1001_0.jpg 6 1 Primitive 2 2D-Objekte
Mehrmiditech 4merge 4-fach MIDI Merger mit :
miditech 4merge 4-fach MIDI Merger mit : 4 x MIDI Input Port, 4 LEDs für MIDI In Signale 1 x MIDI Output Port MIDI USB Port, auch für USB Power Adapter Power LED und LOGO LEDs Hochwertiges Aluminium Gehäuse
MehrHochschule Darmstadt Informatik-Praktikum (INF 1) WS 2015/2016 Wirtschaftsingenieur Bachelor 5. Aufgabe Datenstruktur, Dateieingabe und -ausgabe
Aufgabenstellung Für eine Hausverwaltung sollen für maximal 500 Wohnungen Informationen gespeichert werden, die alle nach der gleichen Weise wie folgt strukturiert sind: Art Baujahr Wohnung Whnginfo Nebenkosten
MehrC++-Zusammenfassung. H. Schaudt. August 18, 2005
C++-Zusammenfassung H. Schaudt August 18, 2005 1 Datentypen 1.1 Grunddatentypen int (-32xxx bis +32xxx, implementerungs-abhängig) char -128 bis +128 float double bool (C++) int und char sind austauschbar:
MehrFunktionen Häufig müssen bestimmte Operationen in einem Programm mehrmals ausgeführt werden. Schlechte Lösung: Gute Lösung:
Funktionen Häufig müssen bestimmte Operationen in einem Programm mehrmals ausgeführt werden. Schlechte Lösung: Der Sourcecode wird an den entsprechenden Stellen im Programm wiederholt Programm wird lang
Mehr2. Semester, 2. Prüfung, Lösung
2. Semester, 2. Prüfung, Lösung Name Die gesamte Prüfung bezieht sich auf die Programmierung in C++! Prüfungsdauer: 90 Minuten Mit Kugelschreiber oder Tinte schreiben Lösungen können direkt auf die Aufgabenblätter
MehrKlausur in Programmieren
Studiengang Sensorik/Sensorsystemtechnik Note / normierte Punkte Klausur in Programmieren Wintersemester 2010/11, 17. Februar 2011 Dauer: 1,5h Hilfsmittel: Keine (Wörterbücher sind auf Nachfrage erlaubt)
MehrMicrocontroller / C-Programmierung Selbststudium Semesterwoche 1
Microcontroller / C-Programmierung Selbststudium Semesterwoche 1 1. Aufgabe 1-15 (Buch S. 26)*: Umrechnung Fahrenheit Celsius mit Funktion. #include float CelsiusToFahrenheit(float value); float
MehrProjektarbeit Reaktionsspiel
Projektarbeit Reaktionsspiel aus der Datenverarbeitungstechnik Realisiert auf dem Olimex AVR USB 162 Entwicklerboard Andreas Loy Juli 2010 1. Aufgabestellung Die Aufgabe verlangte es ein Reaktionsspiel
MehrWörterbücher von MS nach Ooo konvertieren
Wörterbücher von MS nach Ooo konvertieren Herausgegeben durch das deutschsprachige Projekt von OpenOffice.org Autoren Autoren vorhergehender Versionen RPK ggmbh Kempten Copyright und Lizenzhinweis Copyright
MehrTherefore the respective option of the password-protected menu ("UPDATE TUBE DATA BASE") has to be selected:
ENGLISH Version Update Dräger X-act 5000 ("UPDATE TUBE DATA BASE") The "BARCODE OPERATION AIR" mode is used to automatically transfer the needed measurement parameters to the instrument. The Dräger X-act
MehrInformatik für Mathematiker und Physiker Woche 7. David Sommer
Informatik für Mathematiker und Physiker Woche 7 David Sommer David Sommer 30. Oktober 2018 1 Heute: 1. Repetition Floats 2. References 3. Vectors 4. Characters David Sommer 30. Oktober 2018 2 Übungen
MehrEmail-Verschlüsselung
Email-Verschlüsselung...oder möchten Sie alle Postkarten beim Nachbarn abholen? Florian Bokor Mark Neis 23. Oktober 2012 Vorstellung Mark Neis Mail: neismark@gmx.de Key-ID: 0x088EE4A1E Beruf: Systemadministrator
MehrKURZANLEITUNG. Firmware-Upgrade: Wie geht das eigentlich?
KURZANLEITUNG Firmware-Upgrade: Wie geht das eigentlich? Die Firmware ist eine Software, die auf der IP-Kamera installiert ist und alle Funktionen des Gerätes steuert. Nach dem Firmware-Update stehen Ihnen
MehrI - Phone 3D 3D Spieleentwicklung für's I-Phone
I - Phone 3D 3D Spielentwicklung für das I-Phone Gliederung Allgemein Open GL ES Arbeitsschritte / 3D Grafik Ein Spiel entsteht Ein Beispiel Vorgehensweise Allgemein Erzeugen von Modellen Komplexe Modelle
MehrBenutzerhandbuch für Google Cloud Print
Benutzerhandbuch für Google Cloud Print In diesem Handbuch verwendete Symbole Dieses Handbuch verwendet die folgenden Symbole. Hinweis! Das sind Vorsichtsmaßnahmen und Beschränkungen für den korrekten
MehrInformatik Repetitorium SS 2009. Volker Jaedicke Volker.Jaedicke@web.de 0179 1322692
Informatik Repetitorium SS 2009 Volker Jaedicke Volker.Jaedicke@web.de 0179 1322692 Operatoren und Datentypen Beispiel: Anweisungen Variable int a float b int c a= a % (int) (++b-1/4) Vorher 36 3.5 c=b
MehrOpenGL auf Mac OS X und ios
OpenGL auf Mac OS X und ios Torsten Kammer 28.4.2011 CocoaHeads Aachen Grundlagen API für hardwarebeschleunigte 3D-Grafik Kann auch für schnelles 2D verwendet werden Grundlage von Core Image, Core Animation,
MehrZiel, Inhalt. Programmieren in C++ Wir lernen wie man Funktionen oder Klassen einmal schreibt, so dass sie für verschiedene Datentypen verwendbar sind
Templates und Containerklassen Ziel, Inhalt Wir lernen wie man Funktionen oder Klassen einmal schreibt, so dass sie für verschiedene Datentypen verwendbar sind Templates und Containerklassen 1 Ziel, Inhalt
MehrDas neue Volume-Flag S (Scannen erforderlich)
NetWorker 7.4.2 - Allgemein Tip 2, Seite 1/5 Das neue Volume-Flag S (Scannen erforderlich) Nach der Wiederherstellung des Bootstraps ist es sehr wahrscheinlich, daß die in ihm enthaltenen Informationen
MehrSoftwareupdate-Anleitung // AC Porty L Netzteileinschub
1 Softwareupdate-Anleitung // AC Porty L Netzteileinschub Softwareupdate-Anleitung // AC Porty L Netzteileinschub HENSEL-VISIT GmbH & Co. KG Robert-Bunsen-Str. 3 D-97076 Würzburg-Lengfeld GERMANY Tel./Phone:
MehrZusammenfassung des Handzettels für Programmieren in C
Zusammenfassung des Handzettels für Programmieren in C In der handschriftlichen Kopie werden mehr Abkürzungen verwendet. Alles Grün markierte dient zum lernen und wird nicht auf den Handzettel übertragen.
MehrPatentrelevante Aspekte der GPLv2/LGPLv2
Patentrelevante Aspekte der GPLv2/LGPLv2 von RA Dr. Till Jaeger OSADL Seminar on Software Patents and Open Source Licensing, Berlin, 6./7. November 2008 Agenda 1. Regelungen der GPLv2 zu Patenten 2. Implizite
MehrWintersemester Maschinenbau und Kunststofftechnik. Informatik. Tobias Wolf http://informatik.swoke.de. Seite 1 von 18
Kapitel 3 Datentypen und Variablen Seite 1 von 18 Datentypen - Einführung - Für jede Variable muss ein Datentyp festgelegt werden. - Hierdurch werden die Wertemenge und die verwendbaren Operatoren festgelegt.
MehrKapitel 21: OpenGl 1
Kapitel 21: OpenGl 1 OpenGl Programming Guide 2 OpenGl 200 Befehle in OpenGL Library (geometrische Primitive, Attribute) glcolor3f(1.0,0.0,0.0); glrotatef(30.0,0.0,0.0,1.0); 50 Befehle in OpenGl Utility
MehrDominik Stockem Datenschutzbeauftragter Microsoft Deutschland GmbH
Dominik Stockem Datenschutzbeauftragter Microsoft Deutschland GmbH Peter Cullen, Microsoft Corporation Sicherheit - Die Sicherheit der Computer und Netzwerke unserer Kunden hat Top-Priorität und wir haben
MehrHMExcel Stand:
HMExcel Stand: 11.03.2017 Automatisierung ( Fernsteuerung ) von Excel unter Microsoft Windows Tilman Küpper (tilman.kuepper@hm.edu) Inhalt 1. Einleitung... 1 2. Beispiele... 2 2.1. Daten in ein Tabellenblatt
MehrDelegatesund Ereignisse
Delegatesund Ereignisse «Delegierter» Methoden Schablone Funktionszeiger Dr. Beatrice Amrhein Überblick Definition eines Delegat Einfache Delegate Beispiele von Delegat-Anwendungen Definition eines Ereignisses
MehrFast alle pdfs sind betroffen, Lösungsmöglichkeiten siehe Folgeseiten
Fast alle pdfs sind betroffen, Lösungsmöglichkeiten siehe Folgeseiten Acrobat Reader Deutsch Dokumenteigenschaften oder Englisch Document Properties aufrufen mit Strg D oder cmd D Nicht eingebettete Schriften
MehrTriff die Zahl ein Spiel mit dem AT90USB162
Triff die Zahl ein Spiel mit dem AT90USB162 Projektteam: Christoph Russow Oliver Nießlein Hardware: AT90USB162 auf Entwicklerplatine AVR-USB-162 von Olimex erweitert um zwei 7-Segment-Anzeigen Hardware:
Mehrhttps://portal.microsoftonline.com
Sie haben nun Office über Office365 bezogen. Ihr Account wird in Kürze in dem Office365 Portal angelegt. Anschließend können Sie, wie unten beschrieben, die Software beziehen. Congratulations, you have
MehrComputergrafik SS 2008 Oliver Vornberger. Kapitel 21: OpenGl
Computergrafik SS 2008 Oliver Vornberger Kapitel 21: OpenGl 1 OpenGl Programming Guide 2 OpenGl 200 Befehle in OpenGL Library (geometrische Primitive, Attribute) glcolor3f(1.0,0.0,0.0); glrotatef(30.0,0.0,0.0,1.0);
MehrKlausur C++ #1 Jahr: 2001; Dozent: Dipl.Ing. Sorber
Klausur C++ #1 Jahr: 2001; Dozent: Dipl.Ing. Sorber 1) Welche Antworten zur Operatorüberladung sind richtig? (1) a) C++ - Operatoren können zusammen mit Objekten funktionieren b) C++ - Operatoren wird
MehrFB Informatik. Fehler. Testplan
Fehler #include int i,n,summe; int summe (int); cout 0) cin>n; i=summme(n); cout
MehrUSB Treiber updaten unter Windows 7/Vista
USB Treiber updaten unter Windows 7/Vista Hinweis: Für den Downloader ist momentan keine 64 Bit Version erhältlich. Der Downloader ist nur kompatibel mit 32 Bit Versionen von Windows 7/Vista. Für den Einsatz
MehrDatentypen: Enum, Array, Struct, Union
Datentypen: Enum, Array, Struct, Union C-Kurs 2013, 2. Tutorium Freitagsrunde http://wiki.freitagsrunde.org 10. September 2013 This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
MehrEinführung in die Programmierung (EPR)
Goethe-Center for Scientific Computing (G-CSC) Goethe-Universität Frankfurt am Main Einführung in die Programmierung (EPR) (Übung, Wintersemester 2014/2015) Dr. S. Reiter, M. Rupp, Dr. A. Vogel, Dr. K.
MehrMediaBoxXT 4.0. Einfache Erstellung von Postscript-Dateien mit QuarkXPress. JoLauterbach Software GmbH Stolzingstraße 4a 95445 Bayreuth Germany
MediaBoxXT 4.0 Einfache Erstellung von Postscript-Dateien mit QuarkXPress JoLauterbach Software GmbH Stolzingstraße 4a 95445 Bayreuth Germany Telefon: 0921-730 3363 Fax: 0921-730 3394 Internet: email:
MehrKartei zum Lesetagebuch
Kartei zum Lesetagebuch Diese Kartei habe ich für meinen eigenen Unterricht erstellt und stelle es auf meiner privaten Homepage www.grundschulnews.de zum absolut kostenlosen Download bereit. Eine Registrierung
MehrHauptbildschirm HINWEIS. (1) Die Library (Bibliothek) ist der Hauptbildschirm dieser App. Tippen Sie, um die Dateien und Ordner der App anzuzeigen.
MusicSoft Manager ist eine für iphone, ipod touch und ipad konzipierte App und kann verwendet werden, um die folgenden Verwaltungsaufgaben für Songs, Style-Daten und weitere auf digitalen Musikinstrumenten
MehrObjektbasierte Entwicklung
Embedded Software Objektbasierte Entwicklung Objektorientierung in C? Prof. Dr. Nikolaus Wulff Objektbasiert entwickeln Ohne C++ wird meist C im alten Stil programmiert. => Ein endlose while-schleife mit
MehrMobiDM-App Handbuch für Windows Mobile
MobiDM-App Handbuch für Windows Mobile Dieses Handbuch beschreibt die Installation und Nutzung der MobiDM-App für Windows Mobile Version: x.x MobiDM-App Handbuch für Windows Mobile Seite 1 Inhalt 1. WILLKOMMEN
MehrProgrammierkurs Java
Programmierkurs Java Dr. Dietrich Boles Aufgaben zu UE16-Rekursion (Stand 09.12.2011) Aufgabe 1: Implementieren Sie in Java ein Programm, das solange einzelne Zeichen vom Terminal einliest, bis ein #-Zeichen
Mehrtricerat Simplify Value Package
tricerat Simplify Value Package Das Simplify Value Package importiert mehr als 350 gebräuchliche Einstellungsobjekte in die Datenbank der Simplify Suite - so dass diese per Drag & Drop zugewiesen werden
MehrLösungsvorschlag zum Übungsblatt 1 zur Vorlesung Informatik II / WS2001/02
Lösungsvorschlag zum Übungsblatt 1 zur Vorlesung Informatik II / WS2001/02 Prof. Dr.-Ing. Holger Vogelsang (FH-Karlsruhe) Dipl.-Inform. (FH) Gudrun Keller (FH-Karlsruhe) Dipl.-Inform. Mathias Supp (.riess
Mehr1 Vom Problem zum Programm
Hintergrundinformationen zur Vorlesung GRUNDLAGEN DER INFORMATIK I Studiengang Elektrotechnik WS 02/03 AG Betriebssysteme FB3 Kirsten Berkenkötter 1 Vom Problem zum Programm Aufgabenstellung analysieren
MehrJava-Schulung Grundlagen
Java-Schulung Grundlagen Java 2 Standard Edition JDK 5 / 6 31.05.2008 Marcel Wieczorek 1 Themenübersicht Basiswissen Objektorientierung Datentypen Fehlerbehandlung Sonstiges Einführung Klassen, Strings
MehrInformationsmanagement
Probestudium Wirtschaftsinformatik WS 10/11 Informationsmanagement http://www.wip.wiwi.uni-due.de/ Prof. Dr. Heimo H. Adelsberger Dipl.-Wirt.-Inf. Andreas Drechsler Institut für Informatik und Wirtschaftsinformatik
MehrInstallation mit Lizenz-Server verbinden
Einsteiger Fortgeschrittene Profis markus.meinl@m-quest.ch Version 1.0 Voraussetzungen für diesen Workshop 1. Die M-Quest Suite 2005-M oder höher ist auf diesem Rechner installiert 2. Der M-Lock 2005 Lizenzserver
MehrTutorium Rechnerorganisation
Woche 2 Tutorien 3 und 4 zur Vorlesung Rechnerorganisation 1 Christian A. Mandery: KIT Universität des Landes Baden-Württemberg und nationales Grossforschungszentrum in der Helmholtz-Gemeinschaft www.kit.edu
MehrProgrammier-Befehle - Woche 08
Datentypen Vektoren (mehrdim.) eines bestimmten Typs Erfordert: #include Wichtige Befehle: Definition: std::vector my vec (n rows, std::vector(n cols, init value)) Zugriff:
MehrCABLE TESTER. Manual DN-14003
CABLE TESTER Manual DN-14003 Note: Please read and learn safety instructions before use or maintain the equipment This cable tester can t test any electrified product. 9V reduplicated battery is used in
MehrKlausur in Programmieren
Studiengang Sensorik/Sensorsystemtechnik Note / normierte Punkte Klausur in Programmieren Sommer 2014, 16. Juli 2014 Dauer: 1,5h Hilfsmittel: Keine (Wörterbücher sind auf Nachfrage erlaubt) Name: Matrikelnr.:
MehrJava Einführung Collections
Java Einführung Collections Inhalt dieser Einheit Behälterklassen, die in der Java API bereitgestellt werden Wiederholung Array Collections (Vector, List, Set) Map 2 Wiederholung Array a[0] a[1] a[2] a[3]...
MehrRemotely Anywhere Verwendung von Zertifikaten Schritt für Schritt Anleitung zur Implementation von Zertifikaten in Remotely Anywhere
Remotely Anywhere Verwendung von Zertifikaten Schritt für Schritt Anleitung zur Implementation von Zertifikaten in Remotely Anywhere Copyright 1997-2005 Brainware Consulting & Development AG All rights
MehrUSB-Stick (USB-Stick größer 4G. Es ist eine größere Partition notwendig als die eines 4GB Rohlings, der mit NTFS formatiert wurde)
Colorfly i106 Q1 System-Installations-Tutorial Hinweise vor der Installation / Hit for preparation: 准 备 事 项 : 外 接 键 盘 ( 配 套 的 磁 吸 式 键 盘 USB 键 盘 通 过 OTG 插 发 射 器 的 无 线 键 盘 都 可 ); U 盘 ( 大 于 4G 的 空 白 U 盘,
MehrDistributed Computing Group
JAVA TUTORIAL Distributed Computing Group Vernetzte Systeme - SS 06 Übersicht Warum Java? Interoperabilität grosse und gut dokumentierte Library weit verbreitet Syntax sehr nahe an C Erfahrung: Java wird
MehrZählen von Objekten einer bestimmten Klasse
Zählen von Objekten einer bestimmten Klasse Ziel, Inhalt Zur Übung versuchen wir eine Klasse zu schreiben, mit der es möglich ist Objekte einer bestimmten Klasse zu zählen. Wir werden den ++ und den --
MehrJavakurs 2013 Objektorientierung
Javakurs 2013 Objektorientierung Objektorientierte Programmierung I Armelle Vérité 7 März 2013 Technische Universität Berlin This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
Mehr12. Vererbung. Prof. Dr. Markus Gross Informatik I für D-ITET (WS 03/04)
12. Vererbung Prof. Dr. Markus Gross Informatik I für D-ITET (WS 03/04)!Vererbung Konzept!Protected Section!Virtuelle Mitgliedsfunktionen!Verwendung von Vererbung Copyright: M. Gross, ETHZ, 2003 2 Vererbung!
MehrOpensource Lizenzen. Frank Müller Opensource Seminar HS2014 Universität Basel
Opensource Lizenzen Frank Müller Opensource Seminar HS2014 Universität Basel Übersicht Einführung Übersicht über ausgewählte Lizenzen Transitionen zwischen Lizenzen OSS ähnliche Bewegungen ausserhalb von
MehrFür AX 4.0, den letzten Hotfix rollup einspielen. Der Hotfix wurde das erste Mal im Hotfix rollup 975357 eingeschlossen:
I. DOCTYPE-Deklaration Die INDEX.XML-Datei, die beim GDPdU-Export erstellt wird, beinhaltet eine DOCTYPE-Deklaration, die inkorrekterweise als Kommentar herausgegeben wird:
MehrVorkurs C++ Programmierung
Vorkurs C++ Programmierung Klassen Letzte Stunde Speicherverwaltung automatische Speicherverwaltung auf dem Stack dynamische Speicherverwaltung auf dem Heap new/new[] und delete/delete[] Speicherklassen:
MehrGraphic Coding. Klausur. 9. Februar 2007. Kurs A
Graphic Coding Klausur 9. Februar 2007 Kurs A Name: Matrikelnummer: Hinweise - Es sind keine Hilfsmaterialien erlaubt. (Keine Bücher, Taschenrechner, Handys) - Sie haben zwei Stunden Zeit. - Insgesamt
MehrDaten fu r Navigator Mobile (ipad)
[Kommentare] Inhalte Navigator Mobile für das ipad... 3 Programme und Dateien... 4 Folgende Installationen sind erforderlich:... 4 Es gibt verschiedene Dateiformate.... 4 Die Installationen... 5 Installation
MehrIntegration von KS-Hostmonitor in itop
Integration von KS-Hostmonitor in itop Itop ist ein Konfigurationsmanagement und Ticketsystem von combodo (www.combodo.com) KS Advanced Hostmonitor ist ein Netzwerkmonitoring Tool von KS-Soft (www.ks-soft.net)
MehrMethoden. von Objekten definiert werden, Methoden,, Zugriffsmethoden und Read-Only
Methoden Wie Konstruktoren und Destruktoren zum Auf- und Abbau von Objekten definiert werden, Wie inline-methoden Methoden,, Zugriffsmethoden und Read-Only Only- Methoden einzusetzen sind, Der this-pointer
MehrDienstspezifikation nach RFC 2396 193
Dienstspezifikation nach RFC 2396 193 Für die Kombination aus Rechnernamen (oder alternativ einer IP-Adresse) und einer Portnummer gibt es mit RFC 2396 einen Standard: hostport host [ : port ] host hostname
MehrMagic Figures. We note that in the example magic square the numbers 1 9 are used. All three rows (columns) have equal sum, called the magic number.
Magic Figures Introduction: This lesson builds on ideas from Magic Squares. Students are introduced to a wider collection of Magic Figures and consider constraints on the Magic Number associated with such
MehrHandbuch. Artologik EZ-Equip. Plug-in für EZbooking version 3.2. Artisan Global Software
Artologik EZ-Equip Plug-in für EZbooking version 3.2 Artologik EZbooking und EZ-Equip EZbooking, Ihre webbasierte Software zum Reservieren von Räumen und Objekten, kann nun durch die Ergänzung um ein oder
MehrBenutzer- und Referenzhandbuch
Benutzer- und Referenzhandbuch MobileTogether Client User & Reference Manual All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, or mechanical,
MehrModul 122 VBA Scribt.docx
Modul 122 VBA-Scribt 1/5 1 Entwicklungsumgebung - ALT + F11 VBA-Entwicklungsumgebung öffnen 2 Prozeduren (Sub-Prozeduren) Eine Prozedur besteht aus folgenden Bestandteilen: [Private Public] Sub subname([byval
MehrEinführung in die C++ Programmierung für Ingenieure
Einführung in die C++ Programmierung für Ingenieure MATTHIAS WALTER / JENS KLUNKER Universität Rostock, Lehrstuhl für Modellierung und Simulation 14. November 2012 c 2012 UNIVERSITÄT ROSTOCK FACULTY OF
Mehr3D Programmierpraktikum: Szenegraphen und Texturierung
3D Programmierpraktikum: Szenegraphen und Praktikum 3D Programmierung Sebastian Boring, Otmar Hilliges Donnerstag, 1. Juni 2006 LMU München Medieninformatik Boring/Hilliges 3D Programmierpraktikum SS2006
MehrUC4 Rapid Automation HP Service Manager Agent Versionshinweise
UC4 Rapid Automation HP Service Manager Agent Versionshinweise UC4 Software, Inc. Copyright UC4 and the UC4 logo are trademarks owned by UC4 Software GmbH (UC4). All such trademarks can be used by permission
MehrEinführung in die Programmierung
Technische Universität München WS 2003/2004 Institut für Informatik Prof. Dr. Christoph Zenger Testklausur Einführung in die Programmierung Probeklausur Java (Lösungsvorschlag) 1 Die Klasse ArrayList In
Mehrjuergen.vogt@uni-ulm.de
Benutzerregistrierung für SciFinder on WWW Mitglieder, auch Studenten, der Universität Ulm können SciFinder Scholar für nicht-kommerzielle Zwecke nutzen. Allerdings ist der Zugang personalisiert. Damit
MehrGrundlagen C und C++ Einheit 03: Grundlagen in C++ Lorenz Schauer Lehrstuhl für Mobile und Verteilte Systeme
Grundlagen C und C++ Einheit 03: Grundlagen in C++ Lorenz Schauer Lehrstuhl für Mobile und Verteilte Systeme Teil 1: Wiederholung C Heutige Agenda Nutzereingaben verarbeiten Teil 2: Grundlagen in C++ Erstes
MehrEinführung in die Robotik Kinematik. Mohamed Oubbati Institut für Neuroinformatik. Tel.: (+49) 731 / 50 24153 mohamed.oubbati@uni-ulm.de 20. 11.
Einführung in die Robotik Kinematik Mohamed Oubbati Institut für Neuroinformatik Tel.: (+49) 731 / 50 24153 mohamed.oubbati@uni-ulm.de 20. 11. 2012 Die Klausur findet am 12 März 2013 im H20 um 11h. Dauer:
MehrOffice 365 Partner-Features
Office 365 Partner-Features Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management Inhalt 1. Zugriff auf Office 365 IUR und Partner-Features
MehrEinführung in die Programmierung
Name, Vorname Matrikelnummer Probeklausur zur Vorlesung Einführung in die Programmierung WS 2008/09 Dauer: 2 Stunden Hinweise: Schreiben Sie Ihren Namen und Ihre Matrikelnummer auf dieses Deckblatt und
MehrLupos3D. PTB Ein Vorschlag für ein einheitliches binäres Austauschformat für 3D-Laserscandaten. Hochschule Bochum 02.09.2008
PTB Ein Vorschlag für ein einheitliches binäres Austauschformat für 3DLaserscandaten Hochschule Bochum 02.09.2008 Olaf Prümm / Michael Pospiš Lupos 3D GbR, GustavMeyerAllee 25, 13355 Berlin Problembeschreibung
MehrAnwendungsbeispiele Buchhaltung
Kostenstellen in Webling Webling ist ein Produkt der Firma: Inhaltsverzeichnis 1 Kostenstellen 1.1 Was sind Kostenstellen? 1.2 Kostenstellen in der 2 Kostenstellen in Webling 2.1 Kostenstellen erstellen
MehrProgrammierpraktikum 3D Computer Grafik
Dipl.Inf. Otmar Hilliges Programmierpraktikum 3D Computer Grafik Szenegraphen, Texturen und Displaylisten. Agenda Organisatorisches Das Konzept der Szenegraphen Grundlagen Beispiel eines Szenegraphen Transformationen
MehrTechnical Support Information No. 123 Revision 2 June 2008
I IA Sensors and Communication - Process Analytics - Karlsruhe, Germany Page 6 of 10 Out Baking Of The MicroSAM Analytical Modules Preparatory Works The pre-adjustments and the following operations are
MehrFIREPLACE EXPANDABLE BANNER v1.01
FIREPLACE EXPANDABLE BANNER v1.01 1. VORAUSSETZUNGEN Installierter Flash MediaMind Workshop: http://demo.mediamind.com/training_zone/workshop/download.asp Working with MediaMind: download url Vor dem Beginn
MehrBilder. 2D Spiele programmieren in Java. Alpha channel. Formate. Optimierung. Empfehlung
2D Spiele programmieren in Java Teil 3: Bilder, Animationen Dr. Katja Wegner Dr. Ursula Rost Bilder Sind vielfach in Spielen einsetzbar (Menüs, Hintergrund, Objekte) Eigenschaften: Typ (e.g. bitmap, vector)
MehrKurzanleitung um Transponder mit einem scemtec TT Reader und der Software UniDemo zu lesen
Kurzanleitung um Transponder mit einem scemtec TT Reader und der Software UniDemo zu lesen QuickStart Guide to read a transponder with a scemtec TT reader and software UniDemo Voraussetzung: - PC mit der
MehrDer Unterschied zwischen beiden Modellen liegt lediglich in der Berechnung des spekularen Anteils, der sich bei Phong aus
Aufgabe 9: Lokale Beleuchtungsmodelle von Phong und Blinn Der Unterschied zwischen beiden Modellen liegt lediglich in der Berechnung des spekularen Anteils, der sich bei Phong aus I s k s ( R V ) n errechnet,
MehrAnlegen eines Twitter-Accounts für Buchhandlungen -- Stand Mai 2011
Anlegen eines Twitter-Accounts für Buchhandlungen -- Stand Mai 2011 Stefanie Leo www.buecherkinder.de 1 Schritt 1 Dies ist die Startseite http://www.twitter.com Zum Anmelden nun die Felder ausfüllen. Der
MehrDie Programmiersprache C99: Zusammenfassung
Die Programmiersprache C99: Zusammenfassung Jörn Loviscach Versionsstand: 7. Dezember 2010, 19:30 Die nummerierten Felder sind absichtlich leer, zum Ausfüllen in der Vorlesung. Videos dazu: http://www.youtube.com/joernloviscach
Mehr