Skip to content
Snippets Groups Projects
Commit a0095c0f authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispielprogramme und Tafelbild Klausurtutorium 31.1.2017

parent c106f135
Branches
Tags
No related merge requests found
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "opengl-magic.h"
#include "textured-spheres.h"
float t = 0.0;
GLuint earth_texture, moon_texture;
void draw_earth (void)
{
glPushMatrix ();
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (100.0 * t, 0.0, 0.0, 1.0);
draw_textured_sphere (earth_texture, 0.25512, 63, 20);
glPopMatrix ();
}
void draw_moon (void)
{
glPushMatrix ();
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (-90, 0.0, 0.0, 1.0);
draw_textured_sphere (moon_texture, 0.06952, 31, 10);
glPopMatrix ();
}
void draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRotatef (23.44, 1.0, 0.0, -1.0);
draw_earth ();
glRotatef (5.145, 0.0, 1.0, 1.0);
glRotatef (30.0 * t, 0.0, -1.0, 0.0);
glTranslatef (0.9, 0.0, 0.0);
draw_moon ();
glFlush ();
glutSwapBuffers ();
}
void timer_handler (int value)
{
t += 0.05;
glutPostRedisplay ();
glutTimerFunc (50, timer_handler, 0);
}
int main (int argc, char **argv)
{
init_opengl (&argc, argv, "Orbit");
init_texture ("earth-texture.png", &earth_texture);
init_texture ("moon-texture.png", &moon_texture);
glutDisplayFunc (draw);
glutTimerFunc (50, timer_handler, 0);
glutMainLoop ();
return 0;
}
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "opengl-magic.h"
#include "textured-spheres.h"
float t = 0.0;
GLuint earth_texture, moon_texture;
void draw_earth (void)
{
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (100.0 * t, 0.0, 0.0, 1.0);
draw_textured_sphere (earth_texture, 0.25512, 63, 20);
}
void draw_moon (void)
{
glPushMatrix ();
glRotatef (90, 1.0, 0.0, 0.0);
glRotatef (-90, 0.0, 0.0, 1.0);
draw_textured_sphere (moon_texture, 0.06952, 31, 10);
glPopMatrix ();
}
void draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glRotatef (23.44, 1.0, 0.0, -1.0);
draw_earth ();
glRotatef (5.145, 0.0, 1.0, 1.0);
glRotatef (30.0 * t, 0.0, -1.0, 0.0);
glTranslatef (0.9, 0.0, 0.0);
draw_moon ();
glPopMatrix ();
glFlush ();
glutSwapBuffers ();
}
void timer_handler (int value)
{
t += 0.05;
glutPostRedisplay ();
glutTimerFunc (50, timer_handler, 0);
}
int main (int argc, char **argv)
{
init_opengl (&argc, argv, "Orbit");
init_texture ("earth-texture.png", &earth_texture);
init_texture ("moon-texture.png", &moon_texture);
glutDisplayFunc (draw);
glutTimerFunc (50, timer_handler, 0);
glutMainLoop ();
return 0;
}
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fclose.txt", "w");
fprintf (f, "Hello, world!\n");
while (1);
return 0;
}
#include <stdio.h>
int main (void)
{
FILE *f = fopen ("fclose.txt", "w");
fprintf (f, "Hello, world!\n");
fclose (f);
while (1);
return 0;
}
20170130/photo-20170130-130345.jpg

151 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment