Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
*.vsidx
.vs/CMake-GDGRAP1/v17/Browse.VC.db
*.db
*.db-wal
*.sqlite
*.db
Binary file modified .vs/CMake-GDGRAP1/CopilotIndices/17.14.1368.60722/CodeChunks.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/CMake-GDGRAP1/v17/.wsuo
Binary file not shown.
Binary file modified .vs/CMake-GDGRAP1/v17/Browse.VC.db-wal
Binary file not shown.
37 changes: 30 additions & 7 deletions .vs/CMake-GDGRAP1/v17/DocumentLayout.backup.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeProjectGRAP1.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CMakeProjectGRAP1.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}"
}
],
"DocumentGroupContainers": [
Expand All @@ -13,13 +17,9 @@
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"DockedWidth": 338,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Document",
"DocumentIndex": 0,
Expand All @@ -28,10 +28,33 @@
"RelativeDocumentMoniker": "CMakeProjectGRAP1.cpp",
"ToolTip": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeProjectGRAP1.cpp",
"RelativeToolTip": "CMakeProjectGRAP1.cpp",
"ViewState": "AgIAAEMAAAAAAAAAAAAiwGEAAAABAAAAAAAAAA==",
"ViewState": "AgIAAFIAAAAAAAAAAAAwwGsAAAAPAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2026-01-07T08:10:56.672Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "CMakeLists.txt",
"DocumentMoniker": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt",
"RelativeDocumentMoniker": "CMakeLists.txt",
"ToolTip": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt",
"RelativeToolTip": "CMakeLists.txt",
"ViewState": "AgIAACQAAAAAAAAAAAAAAD8AAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003109|",
"WhenOpened": "2026-01-12T05:16:45.201Z",
"EditorCaption": ""
}
]
},
{
"DockedWidth": 62,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
}
]
}
Expand Down
37 changes: 30 additions & 7 deletions .vs/CMake-GDGRAP1/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeProjectGRAP1.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CMakeProjectGRAP1.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}"
}
],
"DocumentGroupContainers": [
Expand All @@ -13,13 +17,9 @@
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"DockedWidth": 338,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Document",
"DocumentIndex": 0,
Expand All @@ -28,10 +28,33 @@
"RelativeDocumentMoniker": "CMakeProjectGRAP1.cpp",
"ToolTip": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeProjectGRAP1.cpp",
"RelativeToolTip": "CMakeProjectGRAP1.cpp",
"ViewState": "AgIAAEMAAAAAAAAAAAAiwGEAAAABAAAAAAAAAA==",
"ViewState": "AgIAAFIAAAAAAAAAAAAwwGsAAAAPAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2026-01-07T08:10:56.672Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "CMakeLists.txt",
"DocumentMoniker": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt",
"RelativeDocumentMoniker": "CMakeLists.txt",
"ToolTip": "C:\\Users\\Erica Barundia\\source\\repos\\CMake-GDGRAP1\\CMakeLists.txt",
"RelativeToolTip": "CMakeLists.txt",
"ViewState": "AgIAACQAAAAAAAAAAAAAAD8AAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003109|",
"WhenOpened": "2026-01-12T05:16:45.201Z",
"EditorCaption": ""
}
]
},
{
"DockedWidth": 62,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
}
]
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
]
},
"ExpandedNodes": [
""
"",
"\\thirdparty"
],
"SelectedNode": "\\CMakeLists.txt",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/cmake.db
Binary file not shown.
12 changes: 12 additions & 0 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "CMakeProjectGRAP1.exe",
"name": "CMakeProjectGRAP1.exe"
}
]
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
24 changes: 22 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# project specific logic here.
#
cmake_minimum_required(VERSION 3.10)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Enable Hot Reload for MSVC compilers if supported.
Expand Down Expand Up @@ -38,16 +37,37 @@ set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
# Set GLFW for this project
FetchContent_MakeAvailable(glfw)

# Get Glad v2
FetchContent_Declare(
glad
GIT_REPOSITORY https://github.com/Dav1dde/glad.git
GIT_TAG v2.0.6
SOURCE_SUBDIR cmake
)

# Set glad for this project
FetchContent_MakeAvailable(glad)

# Generate Glad library for OpenGL 4.6 Core
glad_add_library(glad_gl_core_46 STATIC
REPRODUCIBLE
LOADER
API gl:core=4.6
)

# OpenGL should be preinstalled
find_package(OpenGL REQUIRED)

# Add source to this project's executable.

add_executable(CMakeProjectGRAP1 "CMakeProjectGRAP1.cpp" "CMakeProjectGRAP1.h")

# Link the required libraries - FIXED: Changed GDGRAP-CMake to CMakeProjectGRAP1

# Link the required libraries
target_link_libraries(CMakeProjectGRAP1
glfw
OpenGL::GL
glad_gl_core_46
)

if (CMAKE_VERSION VERSION_GREATER 3.12)
Expand Down
139 changes: 78 additions & 61 deletions CMakeProjectGRAP1.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <GLFW/glfw3.h>
#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <math.h>

#ifndef M_PI
Expand All @@ -20,79 +21,95 @@ int main(void)
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);

GLfloat vertices[]{
0.f, 0.5f, 0.f, //> [0] (0, 0.5, 0) top vertex
-1.f, -0.5f, 0.f, //> [1] (-1, -0.5, 0) bottom left verteex
0.5f, -0.5f, 0.f //> [2] (0.5, -0.5, 0) bottom right vertex

};

GLuint indices[]{
0,1,2
};

GLuint VAO, VBO, EBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);

// Strictly in order

// currVAO = null
glBindVertexArray(VAO);
// currVAO = VAO

// currVBO = null
glBindBuffer(GL_ARRAY_BUFFER, VBO);
// currVBO = VBO <- GL_ARRAY_BUFFER
// currVAO.push(currVBO)

// Assigns vertex data to buffer (currVBO)
glBufferData(GL_ARRAY_BUFFER, // What type of buffer
sizeof(vertices), // Size of data in bytes
vertices, // data
// Optimization only
GL_STATIC_DRAW // Static if almost no movement, Dynamic if constantly moving
);

// Tells OpenGL how to interpret vertex data (currVAO)
glVertexAttribPointer(
0, // Index/Buffer Index (0 reserved for positions)
3, // size (num components) = 3 (x,y,z)
GL_FLOAT, // type of data
GL_FALSE, // normalized?
3 * sizeof(GLfloat), // stride (size of data per vertex)
(void*)0 // array buffer offset
);

// Enable index 0
glEnableVertexAttribArray(0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(indices),
indices,
GL_STATIC_DRAW
);

glBindBuffer(GL_ARRAY_BUFFER, 0);
// currVBO = null
glBindVertexArray(0);
// currVAO = null
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);

// Calculate nonagon vertices
float radius = 0.9f;
float centerX = 0.0f;
float centerY = 1.0f - radius; // Position so top vertices touch y=1.0
float angleOffset = M_PI / 2.0f + M_PI / 9.0f; // Top side horizontal

float vertices[9][2];
for (int i = 0; i < 9; i++) {
float angle = angleOffset + (2.0f * M_PI * i) / 9.0f;
vertices[i][0] = centerX + radius * cos(angle);
vertices[i][1] = centerY + radius * sin(angle);
}

// Draw triangles from center to each edge
glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[0][0], vertices[0][1]);
glVertex2f(vertices[1][0], vertices[1][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[1][0], vertices[1][1]);
glVertex2f(vertices[2][0], vertices[2][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[2][0], vertices[2][1]);
glVertex2f(vertices[3][0], vertices[3][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[3][0], vertices[3][1]);
glVertex2f(vertices[4][0], vertices[4][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[4][0], vertices[4][1]);
glVertex2f(vertices[5][0], vertices[5][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[5][0], vertices[5][1]);
glVertex2f(vertices[6][0], vertices[6][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[6][0], vertices[6][1]);
glVertex2f(vertices[7][0], vertices[7][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[7][0], vertices[7][1]);
glVertex2f(vertices[8][0], vertices[8][1]);

glBegin(GL_TRIANGLES);
glVertex2f(centerX, centerY);
glVertex2f(vertices[8][0], vertices[8][1]);
glVertex2f(vertices[0][0], vertices[0][1]);

glEnd();
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, sizeof(indices), GL_UNSIGNED_INT, 0);

/*
// Primitive type, start index, number of vertices
glDrawArrays(GL_TRIANGLES, 0, 3);
*/


/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}

// Clean-up
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
glDeleteBuffers(1, &EBO);

glfwTerminate();
return 0;
}
Loading