ini
This commit is contained in:
commit
e4c8917154
16 changed files with 319 additions and 0 deletions
38
.vscode/glut_template.code-snippets
vendored
Normal file
38
.vscode/glut_template.code-snippets
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"Template Base GLUT": {
|
||||||
|
"prefix": "glut-base",
|
||||||
|
"body": [
|
||||||
|
"#include <GL/glut.h>",
|
||||||
|
"",
|
||||||
|
"void display() {",
|
||||||
|
"\tglClear(GL_COLOR_BUFFER_BIT);",
|
||||||
|
"\t$4 // O teu desenho fica aqui",
|
||||||
|
"\tglFlush();",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"void init() {",
|
||||||
|
"\t// Define a cor de fundo (R, G, B, Alpha) - Preto por omissao",
|
||||||
|
"\tglClearColor(0.0f, 0.0f, 0.0f, 1.0f);",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"int main(int argc, char** argv) {",
|
||||||
|
"\tglutInit(&argc, argv);",
|
||||||
|
"\t",
|
||||||
|
"\t// Configuracoes basicas da janela",
|
||||||
|
"\tglutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);",
|
||||||
|
"\tglutInitWindowSize(${1:800}, ${2:600});",
|
||||||
|
"\tglutInitWindowPosition(100, 100);",
|
||||||
|
"\t",
|
||||||
|
"\t// Cria a janela com o prefixo obrigatorio",
|
||||||
|
"\tglutCreateWindow(\"GLUT: ${3:Titulo da Janela}\");",
|
||||||
|
"\t",
|
||||||
|
"\tinit();",
|
||||||
|
"\tglutDisplayFunc(display);",
|
||||||
|
"\tglutMainLoop();",
|
||||||
|
"\t",
|
||||||
|
"\treturn 0;",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Template GLUT com configuracoes basicas (tamanho, cor) e prefixo obrigatorio"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug C++ (CodeLLDB)",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"preLaunchTask": "Build C++ (g++)",
|
||||||
|
"terminal": "integrated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
31
.vscode/tasks.json
vendored
Normal file
31
.vscode/tasks.json
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build C++ (g++)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "/usr/bin/g++",
|
||||||
|
"args": [
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-lGL",
|
||||||
|
"-lGLU",
|
||||||
|
"-lglut"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "silent"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
AULA1/main
Executable file
BIN
AULA1/main
Executable file
Binary file not shown.
15
AULA1/main.cpp
Normal file
15
AULA1/main.cpp
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include <GL/glut.h>
|
||||||
|
void display(void) {
|
||||||
|
glClearColor(0, 1, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(500, 500);
|
||||||
|
glutCreateWindow("GLUT: Exercicio 0");
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
AULA2/main
Executable file
BIN
AULA2/main
Executable file
Binary file not shown.
35
AULA2/main.cpp
Normal file
35
AULA2/main.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
void display(void)
|
||||||
|
{
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glColor3f(0,0,0);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluOrtho2D(-2, 2, -2, 2);
|
||||||
|
|
||||||
|
glBegin(GL_POINTS);
|
||||||
|
glVertex2f(-0.5, -0.5);
|
||||||
|
glVertex2f(-0.5, 0.5);
|
||||||
|
glVertex2f(0.5,0.5);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(500, 500);
|
||||||
|
glutCreateWindow("GLUT: Exercicio 1");
|
||||||
|
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
28
AULA2/main2.cpp
Normal file
28
AULA2/main2.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
void display(void) {
|
||||||
|
|
||||||
|
glClearColor(0, 1, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the rendering state
|
||||||
|
void SetupRC(void) {
|
||||||
|
// Set clear color to blue
|
||||||
|
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(500, 500);
|
||||||
|
glutCreateWindow("GLUT: Simple");
|
||||||
|
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
AULA2/main3
Executable file
BIN
AULA2/main3
Executable file
Binary file not shown.
51
AULA2/main3.cpp
Normal file
51
AULA2/main3.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include <GL/freeglut_std.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
// Called to draw scene
|
||||||
|
void RenderScene(void) {
|
||||||
|
// Clear the window with current clearing color
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
// Set current drawing color to red :R G B
|
||||||
|
glColor3f(1.0f, 0.0f, 0.0f);
|
||||||
|
// Draw a filled rectangle with current color
|
||||||
|
glRectd(100.0f, 150.0f, 150.0f, 100.0f);
|
||||||
|
// Flush drawing commands
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the rendering state
|
||||||
|
void SetupRC(void) {
|
||||||
|
// Set clear color to blue
|
||||||
|
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
// Called by GLUT library when the window has cahnge size
|
||||||
|
void ChangeSize(GLsizei w, GLsizei h) {
|
||||||
|
// Prevent a divide by zero
|
||||||
|
if (h == 0)
|
||||||
|
h = 1;
|
||||||
|
// Set Viewport to window dimensions
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
// Reset coordinate system
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
// Establish clipping volume (len, right, booom, top,near, far)
|
||||||
|
if (w <= h)
|
||||||
|
glOrtho (0.0f, 250.0f, 0.0f, 250.0f*h/w, 1.0, -1.0);
|
||||||
|
else glOrtho(0.0f, 250.0f * w / h, 0.0f, 250.0f, 1.0, -1.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main program entry point
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(400, 350);
|
||||||
|
glutInitWindowPosition( 10, 10);
|
||||||
|
glutCreateWindow("GLUT: GLRect");
|
||||||
|
glutDisplayFunc(RenderScene);
|
||||||
|
glutReshapeFunc(ChangeSize);
|
||||||
|
SetupRC();
|
||||||
|
glutMainLoop();
|
||||||
|
}
|
||||||
BIN
AULA3/main
Executable file
BIN
AULA3/main
Executable file
Binary file not shown.
38
AULA3/main.cpp
Normal file
38
AULA3/main.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
|
||||||
|
void draw_face(int size){
|
||||||
|
GLint i;
|
||||||
|
glLineWidth(size);
|
||||||
|
glColor3f(0, 0, 1);
|
||||||
|
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
glVertex2f(1.0,0.0);
|
||||||
|
for (i = 1; i < CIRCLE_STEPS ; inc-expression) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void display() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
// O teu desenho fica aqui
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
// Configuracoes basicas da janela
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(500, 500);
|
||||||
|
|
||||||
|
// Cria a janela com o prefixo obrigatorio
|
||||||
|
glutCreateWindow("GLUT: Titulo da Janela");
|
||||||
|
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
AULA3/main2
Executable file
BIN
AULA3/main2
Executable file
Binary file not shown.
38
AULA3/main2.cpp
Normal file
38
AULA3/main2.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
void display() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glColor3f(1, 0, 0);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2f(150,150);
|
||||||
|
glVertex2f(250, 150);
|
||||||
|
glVertex2f(50, 50);
|
||||||
|
glVertex2f(,);
|
||||||
|
glEnd();
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
// Define a cor de fundo (R, G, B, Alpha) - Preto por omissao
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
// Configuracoes basicas da janela
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(400,400);
|
||||||
|
|
||||||
|
// Cria a janela com o prefixo obrigatorio
|
||||||
|
glutCreateWindow("GLUT: Ex2");
|
||||||
|
|
||||||
|
|
||||||
|
gluOrtho2D(0, 400, 400, 0);
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
30
AULA3/main3.cpp
Normal file
30
AULA3/main3.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
void display() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
// O teu desenho fica aqui
|
||||||
|
glFlush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
// Define a cor de fundo (R, G, B, Alpha) - Preto por omissao
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
|
// Configuracoes basicas da janela
|
||||||
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
|
||||||
|
glutInitWindowSize(800, 600);
|
||||||
|
glutInitWindowPosition(100, 100);
|
||||||
|
|
||||||
|
// Cria a janela com o prefixo obrigatorio
|
||||||
|
glutCreateWindow("GLUT: Titulo da Janela");
|
||||||
|
|
||||||
|
init();
|
||||||
|
glutDisplayFunc(display);
|
||||||
|
glutMainLoop();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
CG.zip
Normal file
BIN
CG.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue