Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
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 |
#include <iostream> #ifdef __APPLE__ # include <GL/glew.h> # include <GL/freeglut.h> # include <OpenGL/glext.h> #else # include "glew.h" # include "freeglut.h" # include "glext.h" #pragma comment(lib, "glew32.lib") #endif using namespace std; // Begin globals. static float Xangle = 150.0, Yangle = 0.0, Zangle = 0.0; // Angles to rotate the tetrahedron. // Vertex co-ordinate vectors for the tetrahedron. static float vertices[] = { 1.0, 1.0, 1.0, // V0 -1.0, 1.0, -1.0, // V1 1.0, -1.0, -1.0, // V2 -1.0, -1.0, 1.0 // v3 }; // Vertex indices for the four trianglular faces. static int triangleIndices[4][3] = { { 1, 2, 3 }, // F0 { 0, 3, 2 }, // F1 { 0, 1, 3 }, // F2 { 0, 2, 1 } // F3 }; // End globals. // Drawing routine. void drawScene(void) { int i; glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); gluLookAt(0.0, 3.0, 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glColor3f(0.0, 0.0, 0.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Rotate scene. glRotatef(Zangle, 0.0, 0.0, 1.0); glRotatef(Yangle, 0.0, 1.0, 0.0); glRotatef(Xangle, 1.0, 0.0, 0.0); // Draw tetrahedron. glBegin(GL_TRIANGLES); for (i = 0; i < 4; ++i) { glArrayElement(triangleIndices[i][0]); glArrayElement(triangleIndices[i][1]); glArrayElement(triangleIndices[i][2]); } glEnd(); glutSwapBuffers(); } // Initialization routine. void setup(void) { glClearColor(1.0, 1.0, 1.0, 0.0); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertices); } // OpenGL window reshape routine. void resize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (float)w / (float)h, 1.0, 50.0); glMatrixMode(GL_MODELVIEW); } // Keyboard input processing routine. void keyInput(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 'x': Xangle += 5.0; if (Xangle > 360.0) Xangle -= 360.0; glutPostRedisplay(); break; case 'X': Xangle -= 5.0; if (Xangle < 0.0) Xangle += 360.0; glutPostRedisplay(); break; case 'y': Yangle += 5.0; if (Yangle > 360.0) Yangle -= 360.0; glutPostRedisplay(); break; case 'Y': Yangle -= 5.0; if (Yangle < 0.0) Yangle += 360.0; glutPostRedisplay(); break; case 'z': Zangle += 5.0; if (Zangle > 360.0) Zangle -= 360.0; glutPostRedisplay(); break; case 'Z': Zangle -= 5.0; if (Zangle < 0.0) Zangle += 360.0; glutPostRedisplay(); break; default: break; } } // Routine to output interaction instructions to the C++ window. void printInteraction(void) { cout << "Interaction:" << endl; cout << "Press x, X, y, Y, z, Z to turn the tetrahedron." << endl; } // Main routine. int main(int argc, char **argv) { printInteraction(); glutInit(&argc, argv); glutInitContextVersion(4, 3); glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(500, 500); glutInitWindowPosition(100, 100); glutCreateWindow("tetrahedron.cpp"); glutDisplayFunc(drawScene); glutReshapeFunc(resize); glutKeyboardFunc(keyInput); glewExperimental = GL_TRUE; glewInit(); setup(); glutMainLoop(); } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Habs hinbekommen aber einfach anderst programmiert. Poste den Code bald.Da hast Du wohl vergessen die passende Bibliothek zu linken.
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 2 3 4 |
int main(int _argc, char** _argv) noexcept { asm volatile("lock cmpxchg8b %eax"); return 0; } // ::main |
Wenn man für jeden Linker-Error-Thread einen Groschen bekäme...
C-/C++-Quelltext |
|
1 2 3 4 |
int main(int _argc, char** _argv) noexcept { asm volatile("lock cmpxchg8b %eax"); return 0; } // ::main |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Evrey« (12.12.2014, 15:32)
Werbeanzeige