ERLEDIGT
JA
JA
ANTWORTEN
11
11
ZUGRIFFE
461
461
EMPFEHLEN
-
10.11.11 16:59 #1
- Registriert seit
- Nov 2011
- Beiträge
- 7
hi, ich versuche einen einfachen bildschirmschoner zu bastel,
1. problem
der kasten soll auf dem bildschirm erseinen (transparent)
und dann sichtbar werden, macht er leider nur nicht... ich finde den fehler nicht...
2. problem
der kasten wird immer schneller,
sollte aber eine konstante geschwindigkeit haben
bin für jede hilfe dankbar =)
gruss k_n
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
#include <iostream> #include <stdlib.h> #include <math.h> //Benoetigt fuer OpenGL #include <GL/glut.h> // OpenGL #include <GL/glf.h> // GLF using namespace std; //Variable für Transparenz GLfloat t = 0.0; // koordinaten für die Spiralbewegung GLfloat positionX = 0.0; GLfloat positionY = 0.0; GLfloat winkel = 0.0; void aktion (int i) { glPushMatrix(); while(t<1){ t=t+0.1; // transparenzwert soll geändert werden glutPostRedisplay(); glutTimerFunc(25 ,aktion,1); } //objekt wird spiralförmig aus dem bildschirm bewegt if(winkel >= 8 ){ winkel = 0.0; // objekt wieder in mitte t = 0.0; // objekt wieder transparent } positionX = 1.5 * winkel*cos(winkel); positionY = 1.5 * winkel*sin(winkel); winkel = winkel + 0.025/(1+0.25*winkel); // erzeugt die Bewegung glPopMatrix(); glutPostRedisplay(); glutTimerFunc(25 ,aktion,1); } void kasten(void){ //fläche des kasten glColor4f(0.0,0.0,0.8,t); glBegin (GL_POLYGON); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 1.0, 1.0); glVertex2f ( 1.0, -1.0); glEnd(); // umrandung des kasten glColor4f(1.0,0.0,0.0,t); glBegin (GL_LINE_LOOP); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 1.0, 1.0); glVertex2f ( 1.0, -1.0); glEnd(); glLineWidth(1.); } // Graphik wird erstellt void display(void) { glClearColor(1.0 , 1.0 , 1.0 , 1.0); // macht hintergrund farbig glClear (GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT, GL_LINE); glPushMatrix(); glScalef( 1.0 , 1.0 , 1 ); glTranslatef(positionX, positionY , 1.0); kasten(); // funktion für den kasten ... glPopMatrix(); glutSwapBuffers(); // Bildspeicher wird gewechselt } // Aenderungen des Fensters void reshape (int w, int h) { float faktor1 = (float) h / (float) w; float faktor2 = (float) w / (float) h; glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); // Weltkoordinaten if (w <= h) gluOrtho2D (-8.0, 8.0, -8.0 * faktor1, 8.0 * faktor1); else gluOrtho2D (-8.0 * faktor2, 8.0 * faktor2, -8.0, 8.0); glMatrixMode(GL_MODELVIEW); } // Tastaturabfragen void keyboard(unsigned char key, int x, int y) { switch (key) { //glutmainloop() beenden case 27: // Escape-Taste exit(0); break; } } int main(int argc, char** argv) { // Initialisierungen (GLUT) glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_ALPHA | GLUT_RGBA ); glutInitWindowSize (1000, 1000); glutInitWindowPosition (200, 200); glutCreateWindow (argv[0]); glutFullScreen(); // FULLSCREEN // Initialisierungen (GLF) glfInit(); glfLoadFont("/opt/glf/fonts/arial1.glf"); // Callback Funktionen glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutTimerFunc(2000,aktion,1); // //Nun beginnt es; glutMainLoop(); return 0; }Geändert von kommt_noch (10.11.11 um 17:03 Uhr)
-
Hi und Willkommen bei tutorials.de

Ohne Code können wir schlecht sagen, was los ist.
Benutze die Codetags.
Und bitte beachte Netiquette §15.
Was ist dieser "Kasten"?Netiquette (vA §15) und Nutzungsregeln (vA §4.8) einhalten! Programmcode in Codetags/Codeboxen.
Sehr gute Beiträge bitte Bewerten (Stern darunter oder "Danke").
"Funktioniert nicht" ist zu ungenau! Code, Fehlermeldungen, Verhalten des Programms, ...?
-
10.11.11 17:08 #3
- Registriert seit
- Nov 2011
- Beiträge
- 7
ich war ja noch gar nicht feritg
das ist nur ein quadrat das spiralförmig sich aus dem bildschirm rausbewegen soll
und dann nach einigen umdrehungen (bildschirm verlassen) wieder erscheinen soll ...
und beim erscheinen soll es eigentlich transparent sein ... aber es weigert sich standhaft dieses zu sein
-
Also...die Transparenz:
Warum machst du in Aktion eine while-Schleife,
die von 0 durch auf 1 zählt?
Sollte das nnicht auf mehrere aktion-Durchgänge aufgeteilt werden?
Und zur verschnellerten Rotation:
Math. ist das normal, wenn man immer einen fixen Winkelschritt weitergeht.
Kann deine Positionsberechnung jetzt auf die Schnelle nicht ganz nachvollziehen...
würde das eher Schritt für Schritt machen.
Das Objekt soll sich von der Bildschirmmitte weg spiralförmig nach außen bewegen?
Dann mach zuerst Variablen für Winkel (0-360° und Radius bzw. Entfernung von der Bildschirmmitte)
Bei jedem aktion zählst du einen fixen Wert zum radius
und einen fixen Wert zum Winkel dazu. Dann winkel%=360;
Erst dann berechnest du mit sin/cos etc. die x/y-Koordinaten.
Um zu verhindern, dass die Bewegung schneller wird, musst du den Wikel mit zunehmendem Radius proportional verkleinern (doppelter Radius ergibt doppelten Kreisumfang...).
Aslo, was tatsächlich zum aktuellen Winkel addiert wird, ist grob gesagt der (Fixwert / Radius).
Sonderfall Radius==0: Dann Ergebnis auch 0.
Muss mit if überprüft werden, weil sonst Division durch 0.Netiquette (vA §15) und Nutzungsregeln (vA §4.8) einhalten! Programmcode in Codetags/Codeboxen.
Sehr gute Beiträge bitte Bewerten (Stern darunter oder "Danke").
"Funktioniert nicht" ist zu ungenau! Code, Fehlermeldungen, Verhalten des Programms, ...?
-
11.11.11 10:15 #5
- Registriert seit
- Nov 2011
- Beiträge
- 7
zur while schleife ...
Code :1 2 3 4 5 6 7
while(t<1){ t=t+0.1; // transparenzwert soll geändert werden glutPostRedisplay(); glutTimerFunc(25 ,aktion,1); }
ich dachte mit :
glutPostRedisplay();
glutTimerFunc(25 ,aktion,1);
rufe ich die funktion ja wieder auf ... also das es in mehreren durchgängen passiert ...
wobei dafür so betrachtet ne if-abfrage mit if(t<1) besser scheint ...
die koordinaten berechne ich nach der Archimedische_Spirale.
-
Zur Transparenz:
aktion wird ja sowieso schon regelmäßig aufgerufen, auch wegen der Bewegung.
Also ja, nur ein if reicht.
Zur Spiralbewegung...ich schreib mal eine Funktion.
so jetzt aber:
Stüzt nicht ab oder so, aber ob die Werte stimmen...Code cpp:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#include <stdio.h> #include <math.h> class spirale { protected: char uhr; double fixwinkel, winkel, fixradius, radius, x, y; public: //Parameter: //1: Abstand zwischen den "Linien" //2: Geschwindigkeit. Passenden Wert finden //3: Wenn gegen den Uhrzeigersinn 0, sonst 1 spirale(double linienabstand, int geschwindigkeit, char uhrzeigersinn = 1) { uhr = uhrzeigersinn; fixradius = linienabstand; fixwinkel = 360.0 * (double)geschwindigkeit; if(!uhrzeigersinn) fixwinkel = -fixwinkel; winkel = 0.0; radius = 0.0; } void aktion() { char negativ; if(fixradius < 0.0) { if(radius > 0.0) { winkel += fixwinkel / radius; while(winkel < 0.0) winkel += 360.0; while(winkel >= 360.0) winkel -= 360.0; } radius -= fixradius; if(radius < 0.0) radius = 0.0; } else if(fixradius > 0.0) { radius += fixradius; if(radius > 0.0) { winkel += fixwinkel / radius; while(winkel < 0.0) winkel += 360.0; while(winkel >= 360.0) winkel -= 360.0; } } printf("%f %f\n",radius,winkel); x = winkel; if(x > 180.0) { negativ = 1; x -= 180.0; } else negativ = 0; if(x > 90.0) x = 180.0 - x; x *= 3.14159265; x /= 360.0; x = sin(x); if(negativ) x = -x; y = winkel + 90.0; if(y >= 360.0) y -= 360.0; if(y > 180.0) { negativ = 1; y -= 180.0; } else negativ = 0; if(y > 90.0) y = 180.0 - y; y *= 3.14159265; y /= 360.0; y = sin(y); if(negativ) y = -y; } //Koordinaten abfragen, von der Bildschirmmitte ausgehend (math. Coordsystem) double getx() { return x; } double gety() { return y; } //0=nach innen, 1=nach aussen void richtung(char aussen) { if(aussen && fixradius < 0.0) fixradius = -fixradius; if(!aussen && fixradius > 0.0) fixradius = -fixradius; } };
das sieht man grafisch wahrscheinlich einfacher.Netiquette (vA §15) und Nutzungsregeln (vA §4.8) einhalten! Programmcode in Codetags/Codeboxen.
Sehr gute Beiträge bitte Bewerten (Stern darunter oder "Danke").
"Funktioniert nicht" ist zu ungenau! Code, Fehlermeldungen, Verhalten des Programms, ...?
-
11.11.11 12:27 #7
- Registriert seit
- Nov 2011
- Beiträge
- 7
hmm ... das mit der spirale werd ich ma noch n bissel ausprobieren ...
aber was mache ich wegen der transparenz ?
irgendwo muss da noch n fehler sein ...
ich habe den teil mit der bewegung erstmal rausgenommen,
umd das "einbleden" zu versuchen ... aber das kästchen ist gleich von anfang an da ...
liegt das an der zeile im main teil:
glutInitDisplayMode (GLUT_DOUBLE | GLUT_ALPHA | GLUT_RGBA );
bei der bin ich mir nicht so sicher ob das richtig ist ...
oder ist es ein anderer teil den ich bei main oder so vergessen habe?
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
#include <iostream> #include <stdlib.h> #include <math.h> //Benoetigt fuer OpenGL #include <GL/glut.h> // OpenGL #include <GL/glf.h> // GLF using namespace std; //Variable für Transparenz GLfloat t = 0.0; // koordinaten für die Spiralbewegung GLfloat positionX = 0.0; GLfloat positionY = 0.0; void aktion (int i) { glPushMatrix(); if(t<1){ t=t+0.1; // transparenzwert soll geändert werden } glutPostRedisplay(); glutTimerFunc(25 ,aktion,1); } void kasten(void){ //fläche des kasten glColor4f(0.0,0.0,0.8,t); glBegin (GL_POLYGON); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 1.0, 1.0); glVertex2f ( 1.0, -1.0); glEnd(); // umrandung des kasten glColor4f(1.0,0.0,0.0,t); glBegin (GL_LINE_LOOP); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 1.0, 1.0); glVertex2f ( 1.0, -1.0); glEnd(); glLineWidth(1.); } // Graphik wird erstellt void display(void) { glClearColor(1.0 , 1.0 , 1.0 , 1.0); // macht hintergrund farbig glClear (GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT, GL_LINE); glPushMatrix(); glScalef( 1.0 , 1.0 , 1 ); glTranslatef(positionX, positionY , 1.0); kasten(); // funktion für den kasten ... glPopMatrix(); glutSwapBuffers(); // Bildspeicher wird gewechselt } // Aenderungen des Fensters void reshape (int w, int h) { float faktor1 = (float) h / (float) w; float faktor2 = (float) w / (float) h; glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); // Weltkoordinaten if (w <= h) gluOrtho2D (-8.0, 8.0, -8.0 * faktor1, 8.0 * faktor1); else gluOrtho2D (-8.0 * faktor2, 8.0 * faktor2, -8.0, 8.0); glMatrixMode(GL_MODELVIEW); } // Tastaturabfragen void keyboard(unsigned char key, int x, int y) { switch (key) { //glutmainloop() beenden case 27: // Escape-Taste exit(0); break; } } int main(int argc, char** argv) { // Initialisierungen (GLUT) glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_ALPHA | GLUT_RGBA ); glutInitWindowSize (1000, 1000); glutInitWindowPosition (200, 200); glutCreateWindow (argv[0]); glutFullScreen(); // FULLSCREEN // Initialisierungen (GLF) glfInit(); glfLoadFont("/opt/glf/fonts/arial1.glf"); // Callback Funktionen glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutTimerFunc(2000,aktion,1); // //Nun beginnt es; glutMainLoop(); return 0; }
-
Du hast den Timeraufruf ja noch immer drin?
Weg damit oder höher.
25ms ist viel zu schnell.
In 0 Schritten bis zu 1.0 Alpha macht 250ms. Deswegen wirds dir nicht auffallen...Netiquette (vA §15) und Nutzungsregeln (vA §4.8) einhalten! Programmcode in Codetags/Codeboxen.
Sehr gute Beiträge bitte Bewerten (Stern darunter oder "Danke").
"Funktioniert nicht" ist zu ungenau! Code, Fehlermeldungen, Verhalten des Programms, ...?
-
11.11.11 13:04 #9
- Registriert seit
- Nov 2011
- Beiträge
- 7
wenn ich die funktion "aktion" verändere tut sich trotzdem nix...
selbst wenn ich den teil wo ich
t = t + 0.001
mache weglasse, ist der kasten da, dabei sollte er doch zumindestens dann durch
Transparenz t=0.0 nicht zu sehen sein ...
das wundert mich ja dabei ... wenn das schon ma passieren würde hätte ich schon n schritt nach vorne
Code :1 2 3 4 5 6 7 8 9 10
void aktion (int i) { glPushMatrix(); if(t<1){ t=t+0.001; // transparenzwert soll geändert werden } glutPostRedisplay(); glutTimerFunc(2500 ,aktion,1); }
-
Hallo,
allein den Alpha-Wert der Farbe zu setzen, reicht nicht. Du musst noch Blending aktivieren und einen passenden Blending-Modus auswählen. Siehe z.B. http://wiki.delphigl.com/index.php/glBlendFunc (ist zwar für Delphi geschrieben, aber das macht keinen großen Unterschied).
Grüße,
Matthias„Gib einem Menschen einen Fisch, und er wird für einen Tag satt. Lehre ihn Fischen, und er wird ein Leben lang satt.“
“For every complex problem, there is an answer that is short, simple and wrong.”
“Pessimism is safe, but optimism is a lot faster!”
Aktuelles Coding Quiz: #17 - Wörter kreuz und quer
-
23.11.11 17:12 #11
- Registriert seit
- Nov 2011
- Beiträge
- 7
so ... einige tage vergangen und meinen bildschirmschoner etwas aufgebessert...
nachdem es ...auch mit dem alpha wert ging war mir der kasten zu langweilig ...
und noch n paar spielerein eingebaut ...
nu ist er fertig
danke nochmal für die hilfe
<kommt_noch>
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
// // mein kleiner Bildschirmschoner version 3.2 beta // // #include <iostream> #include <stdlib.h> #include <math.h> //Benoetigt fuer OpenGL #include <GL/glut.h> // OpenGL #include <GL/glf.h> // GLF using namespace std; //Varable für den Transparenzwert GLfloat t = 0.0; //Variablen für das zufällige Erscheinen GLfloat a = 0.0; GLfloat b = 0.0; // Variablen für die Spiralbewegung GLfloat positionX = 0.0; GLfloat positionY = 0.0; GLfloat winkel = 0.01; GLfloat radius = 0.01; // Funktion die zufällige Werte für a und b generiert void position(void) { GLfloat vz; vz = rand()%2; if (vz ==1) a = -(rand()%34); else a = (rand()%34); vz = rand()%2; if (vz ==1) b = -(rand()%18); else b = (rand()%18); } // Funktion durch die Veränderungen erzeugt werden void aktion (int i) { if(t<1){ // objekt wird sichtbar gemacht t += 0.01; glutPostRedisplay(); glutTimerFunc(30 ,aktion,1); } else{ if(radius >= 40) { winkel = 0.0; t=0.0; position(); } winkel += 0.15/(1+ radius); // erzeugt die Bewegung positionX = 1.5 * winkel*cos(winkel); positionY = 1.5 * winkel*sin(winkel); radius = sqrt(positionX*positionX + positionY*positionY); glutPostRedisplay(); glutTimerFunc(25 ,aktion,1); } } // Funktion zum erstellen des Kreuzes // mit den Variablen c1,c2,c3,c4 // für die Farbunterschiede void objekt(GLfloat c1, GLfloat c2, GLfloat c3, GLfloat c4){ //Beginn c2-Fläche glColor4f(0.0,0.0,c2,t); glBegin (GL_POLYGON); glVertex2f (-3.0, -3.0); glVertex2f (-3.0, -1.0); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, -3.0); glEnd(); glBegin (GL_POLYGON); glVertex2f (-3.0, 1.0); glVertex2f (-3.0, 2.0); glVertex2f (-1.0, 2.0); glVertex2f (-1.0, 1.0); glEnd(); glBegin (GL_POLYGON); glVertex2f (-2.0, 2.0); glVertex2f (-2.0, 3.0); glVertex2f (-1.0, 3.0); glVertex2f (-1.0, 2.0); glEnd(); //Beginn c3-Fläche glColor4f(0.0,0.0,c3,t); glBegin (GL_POLYGON); glVertex2f (-2.0, 0.0); glVertex2f (-3.0, 1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 0.0, 0.0); glEnd(); glBegin (GL_POLYGON); glVertex2f ( 1.0, -3.0); glVertex2f ( 0.0, -2.0); glVertex2f ( 1.0, -1.0); glVertex2f ( 3.0, -3.0); glEnd(); //Beginn c4-Fläche glColor4f(0.0,0.0,c4,t); glBegin (GL_POLYGON); glVertex2f (-3.0, -1.0); glVertex2f (-2.0, 0.0); glVertex2f ( 0.0, 0.0); glVertex2f (-1.0, -1.0); glEnd(); glBegin (GL_POLYGON); glVertex2f ( 0.0, 2.0); glVertex2f ( 1.0, 3.0); glVertex2f ( 3.0, 3.0); glVertex2f ( 1.0, 1.0); glEnd(); //beginn c1-Fläche glColor4f(0.0,0.0,c1,t); glBegin (GL_POLYGON); glVertex2f (-1.0, -3.0); glVertex2f (-1.0, -1.0); glVertex2f ( 3.0, 3.0); glVertex2f ( 3.0, 1.0); glEnd(); glBegin (GL_POLYGON); glVertex2f ( 1.5, 0.5); glVertex2f ( 3.0, -1.0); glVertex2f ( 3.0, -3.0); glVertex2f ( 0.5, -0.5); glEnd(); glBegin (GL_POLYGON); glVertex2f ( 0.5, -0.5); glVertex2f (-1.0, 1.0); glVertex2f (-1.0, 3.0); glVertex2f ( 1.5, 0.5); glEnd(); glLineWidth(3.); // für Umrandung derFlächen glColor4f(0.0,0.0,0.0,t); glBegin (GL_LINE_LOOP); glVertex2f (-3.0, 1.0); glVertex2f (-3.0, 2.0); glVertex2f (-2.0, 2.0); glVertex2f (-2.0, 3.0); glVertex2f (-1.0, 3.0); glVertex2f (-1.0, 1.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f (-3.0, -3.0); glVertex2f (-3.0, -1.0); glVertex2f (-1.0, -1.0); glVertex2f (-1.0, -3.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f (-3.0, -1.0); glVertex2f (-2.0, 0.0); glVertex2f ( 0.0, 0.0); glVertex2f (-1.0, -1.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f ( 0.0, 2.0); glVertex2f ( 1.0, 3.0); glVertex2f ( 3.0, 3.0); glVertex2f ( 1.0, 1.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f (-2.0, 0.0); glVertex2f (-3.0, 1.0); glVertex2f (-1.0, 1.0); glVertex2f ( 0.0, 0.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f ( 1.0, -3.0); glVertex2f ( 0.0, -2.0); glVertex2f ( 1.0, -1.0); glVertex2f ( 3.0, -3.0); glEnd(); glBegin (GL_LINE_LOOP); glVertex2f ( 0.0, 0.0); glVertex2f (-1.0, 1.0); glVertex2f (-1.0, 3.0); glVertex2f ( 1.0, 1.0); glVertex2f ( 3.0, 3.0); glVertex2f ( 3.0, 1.0); glVertex2f ( 2.0, 0.0); glVertex2f ( 3.0, -1.0); glVertex2f ( 3.0, -3.0); glVertex2f ( 1.0, -1.0); glVertex2f (-1.0, -3.0); glVertex2f (-1.0, -1.0); glEnd(); glLineWidth(1.); } // Graphik wird erstellt void display(void) { GLfloat posX = 0.0; GLfloat posY = -5.0; GLfloat tmp = 0.0; //Variablen für Farbwerte GLfloat c1 = 0.6 ; GLfloat c2 = 0.5 ; GLfloat c3 = 0.4 ; GLfloat c4 = 0.3 ; GLfloat tmpc = 0.0 ; glClearColor(0.50 , 0.50 , 0.50 , 0.0); // macht hintergrund farbig glClear (GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT, GL_LINE); // Schleife zum erzeugen der 4 kreuze for(int i=0; i<4;i++){ glPushMatrix(); glScalef( 0.3 , 0.3 , 1 ); glTranslatef(positionX+posX+a, positionY+posY+b , 1.0); glRotatef( i*90 ,0,0,1); //dreht die kreuze in die richtige position //erstellen des Kreuzes objekt(c1,c2,c3,c4); //Wechsel der Farben ab zweitem Durchlauf tmpc =c1; c1=c4; c4=c2; c2=c3; c3=tmpc; // ändern der koordinaten des Mittelpunktes tmp = posX ; posX = -posY ; posY = tmp ; glPopMatrix(); } glutSwapBuffers(); // Bildspeicher wird gewechselt } // Aenderungen des Fensters void reshape (int w, int h) { float faktor1 = (float) h / (float) w; float faktor2 = (float) w / (float) h; glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); // Weltkoordinaten if (w <= h) gluOrtho2D (-8.0, 8.0, -8.0 * faktor1, 8.0 * faktor1); else gluOrtho2D (-8.0 * faktor2, 8.0 * faktor2, -8.0, 8.0); glMatrixMode(GL_MODELVIEW); } // Tastaturabfragen void keyboard(unsigned char key, int x, int y) { switch (key) { //glutmainloop() beenden case 27: // Escape-Taste exit(0); break; } } int main(int argc, char** argv) { // Initialisierungen (GLUT) glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA ); glutInitWindowSize (1000, 1000); glutInitWindowPosition (200, 200); glutCreateWindow (argv[0]); glutFullScreen(); // FULLSCREEN // Initialisierungen (GLF) glfInit(); glfLoadFont("/opt/glf/fonts/arial1.glf"); // Callback Funktionen // für transparenz erforderlich glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); srand(NULL); position(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc (keyboard); glutTimerFunc(2000,aktion,1); // //Nun beginnt es; glutMainLoop(); return 0; } //ende //////////////////////////////////////////////////////////////////////////////
-
23.11.11 17:13 #12
- Registriert seit
- Nov 2011
- Beiträge
- 7
aso von mir aus dann auch hier fertig ... =)
Ähnliche Themen
-
Illustrator - Probleme mit Transparenz in Logo und mit Schein nach aussen
Von daniel89 im Forum Vektor-ProgrammeAntworten: 13Letzter Beitrag: 18.10.08, 10:45 -
probleme mit fstream funk. open(dateiname);
Von FaNo86 im Forum C/C++Antworten: 2Letzter Beitrag: 18.04.07, 19:19 -
CReordset Open Probleme
Von schuepany im Forum VisualStudio & MFCAntworten: 0Letzter Beitrag: 19.06.06, 16:57 -
FireFox Probleme mit window.open
Von kirashet im Forum Javascript & AjaxAntworten: 1Letzter Beitrag: 15.06.05, 12:04 -
probleme mit window.open und netscape
Von arnold85 im Forum Javascript & AjaxAntworten: 1Letzter Beitrag: 21.10.04, 21:29





Zitieren


Login






