Add first Code
This commit is contained in:
parent
358616ed1f
commit
4c8461f62a
7 changed files with 123 additions and 0 deletions
49
.gitignore
vendored
49
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
# Verzeichnisse
|
# Verzeichnisse
|
||||||
Mitschriften/
|
Mitschriften/
|
||||||
|
build
|
||||||
|
|
||||||
# Dateien
|
# Dateien
|
||||||
*_Mitschrift.tex
|
*_Mitschrift.tex
|
||||||
|
@ -216,3 +217,51 @@ TSWLatexianTemp*
|
||||||
|
|
||||||
# expex forward references with \gathertags
|
# expex forward references with \gathertags
|
||||||
*-tags.tex
|
*-tags.tex
|
||||||
|
|
||||||
|
|
||||||
|
# Cmake
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles
|
||||||
|
CMakeScripts
|
||||||
|
Testing
|
||||||
|
Makefile
|
||||||
|
cmake_install.cmake
|
||||||
|
install_manifest.txt
|
||||||
|
compile_commands.json
|
||||||
|
CTestTestfile.cmake
|
||||||
|
CMakeLists.txt.user
|
||||||
|
|
||||||
|
# C++
|
||||||
|
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
|
6
Code/.clang-format
Normal file
6
Code/.clang-format
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: WebKit
|
||||||
|
ColumnLimit: 100
|
||||||
|
FixNamespaceComments: true
|
||||||
|
...
|
10
Code/CMakeLists.txt
Normal file
10
Code/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
|
||||||
|
if ( CMAKE_COMPILER_IS_GNUCC )
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(GLUT REQUIRED)
|
||||||
|
|
||||||
|
add_subdirectory(hello_world)
|
5
Code/hello_world/CMakeLists.txt
Normal file
5
Code/hello_world/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
|
||||||
|
add_executable (hello_world helloWorld.c)
|
||||||
|
target_include_directories(hello_world PRIVATE ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
|
||||||
|
target_link_libraries(hello_world ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
|
53
Code/hello_world/helloWorld.c
Normal file
53
Code/hello_world/helloWorld.c
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include <GL/glut.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int width = 640;
|
||||||
|
int height = 480;
|
||||||
|
|
||||||
|
void init(int argc, char** argv)
|
||||||
|
{
|
||||||
|
glutInit(&argc, argv); // Initialisierung der GLUT Bibliothek
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE); // Initialisierung des Single Buffer Modes
|
||||||
|
glutInitWindowSize(width, height); // Fenstergröße in Pixel (Breite, Hoehe)
|
||||||
|
glutInitWindowPosition(
|
||||||
|
100, 100); // Fensterposition in Pixel, ausgehend vom Ursprung des Window Systems
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glutCreateWindow("Hello world"); // Erstellen des Fensters
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluOrtho2D(0, width, 0, height);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void display(void)
|
||||||
|
{
|
||||||
|
const char* myText = "Hello World!";
|
||||||
|
int j;
|
||||||
|
|
||||||
|
glClear(GL_COLOR);
|
||||||
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glVertex3f((width / 2) - (width / 4), (height / 2) - (height / 4), 0.0);
|
||||||
|
glVertex3f((width / 2) + (width / 4), (height / 2) - (height / 4), 0.0);
|
||||||
|
glVertex3f((width / 2) + (width / 4), (height / 2) + (height / 4), 0.0);
|
||||||
|
glVertex3f((width / 2) - (width / 4), (height / 2) + (height / 4), 0.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
|
glRasterPos2i((width / 2) - (width / 4) + 10, (height / 2) - (height / 4) + 10);
|
||||||
|
for (j = 0; j < strlen(myText); j++) {
|
||||||
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, myText[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
init(argc, argv);
|
||||||
|
glutDisplayFunc(display); // Callback-Funktion für das Fenster
|
||||||
|
glutMainLoop(); // Abgabe der Kontrolle an GLUT-Bibliothek
|
||||||
|
return 0;
|
||||||
|
}
|
Binary file not shown.
BIN
Folien/Vorlesungsfolien_2018_10_10.pdf
Normal file
BIN
Folien/Vorlesungsfolien_2018_10_10.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue