commit e4c8917154f7eb8c26ef6fe2438379a34b646768 Author: lipe89 Date: Thu Mar 12 09:39:09 2026 +0000 ini diff --git a/.vscode/glut_template.code-snippets b/.vscode/glut_template.code-snippets new file mode 100644 index 0000000..fd9811e --- /dev/null +++ b/.vscode/glut_template.code-snippets @@ -0,0 +1,38 @@ +{ + "Template Base GLUT": { + "prefix": "glut-base", + "body": [ + "#include ", + "", + "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" + } +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b7406b0 --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5e2c505 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + ] + } + ] +} \ No newline at end of file diff --git a/AULA1/main b/AULA1/main new file mode 100755 index 0000000..5268521 Binary files /dev/null and b/AULA1/main differ diff --git a/AULA1/main.cpp b/AULA1/main.cpp new file mode 100644 index 0000000..764de5b --- /dev/null +++ b/AULA1/main.cpp @@ -0,0 +1,15 @@ +#include +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; +} \ No newline at end of file diff --git a/AULA2/main b/AULA2/main new file mode 100755 index 0000000..ea2daa5 Binary files /dev/null and b/AULA2/main differ diff --git a/AULA2/main.cpp b/AULA2/main.cpp new file mode 100644 index 0000000..2797262 --- /dev/null +++ b/AULA2/main.cpp @@ -0,0 +1,35 @@ +#include + +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; +} \ No newline at end of file diff --git a/AULA2/main2.cpp b/AULA2/main2.cpp new file mode 100644 index 0000000..1cbebcd --- /dev/null +++ b/AULA2/main2.cpp @@ -0,0 +1,28 @@ +#include + +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; +} \ No newline at end of file diff --git a/AULA2/main3 b/AULA2/main3 new file mode 100755 index 0000000..69a44af Binary files /dev/null and b/AULA2/main3 differ diff --git a/AULA2/main3.cpp b/AULA2/main3.cpp new file mode 100644 index 0000000..7e3b0d6 --- /dev/null +++ b/AULA2/main3.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +// 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(); +} \ No newline at end of file diff --git a/AULA3/main b/AULA3/main new file mode 100755 index 0000000..9c0847c Binary files /dev/null and b/AULA3/main differ diff --git a/AULA3/main.cpp b/AULA3/main.cpp new file mode 100644 index 0000000..0de6bb3 --- /dev/null +++ b/AULA3/main.cpp @@ -0,0 +1,38 @@ +#include +#include + + +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; +} \ No newline at end of file diff --git a/AULA3/main2 b/AULA3/main2 new file mode 100755 index 0000000..d7acde7 Binary files /dev/null and b/AULA3/main2 differ diff --git a/AULA3/main2.cpp b/AULA3/main2.cpp new file mode 100644 index 0000000..87aa2c5 --- /dev/null +++ b/AULA3/main2.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +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; +} \ No newline at end of file diff --git a/AULA3/main3.cpp b/AULA3/main3.cpp new file mode 100644 index 0000000..9388492 --- /dev/null +++ b/AULA3/main3.cpp @@ -0,0 +1,30 @@ +#include + +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; +} \ No newline at end of file diff --git a/CG.zip b/CG.zip new file mode 100644 index 0000000..411a8df Binary files /dev/null and b/CG.zip differ