Skip to content

Commit

Permalink
Other cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Cheng committed Nov 4, 2022
1 parent 4c30964 commit 587a85d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 38 deletions.
27 changes: 20 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
cmake_minimum_required(VERSION 3.16)

# Sets project name
project(lab09 LANGUAGES CXX C)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# Sets C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Specifies required Qt components
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS OpenGL)
find_package(Qt6 REQUIRED COMPONENTS OpenGLWidgets)
find_package(Qt6 REQUIRED COMPONENTS Gui)

# Allows you to include files from within those directories, without prefixing their filepaths
include_directories(src)

# Specifies .cpp and .h files to be passed to the compiler
add_executable(${PROJECT_NAME}
src/main.cpp
src/glrenderer.cpp
src/mainwindow.cpp
src/main.cpp

src/glrenderer.h
src/mainwindow.h
src/shaderloader.h
src/debug.h
src/glrenderer.cpp
src/mainwindow.cpp

src/glrenderer.h
src/mainwindow.h
src/shaderloader.h
src/debug.h
)

# Specifies other files
qt_add_resources(${PROJECT_NAME} "Resources"
PREFIX
Expand All @@ -33,9 +43,11 @@ qt_add_resources(${PROJECT_NAME} "Resources"
resources/shaders/default.vert
resources/shaders/default.frag
)

# GLEW: this creates its library and allows you to `#include "GL/glew.h"`
add_library(StaticGLEW STATIC glew/src/glew.c)
include_directories(${PROJECT_NAME} PRIVATE glew/include)

# Specifies libraries to be linked (Qt components, glew, etc)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt::Core
Expand All @@ -59,6 +71,7 @@ endif()
if (MSVC OR MSYS OR MINGW)
set(CMAKE_CXX_FLAGS "-Wno-volatile")
endif()

# Set this flag to silence warnings on MacOS
if (APPLE)
set(CMAKE_CXX_FLAGS "-Wno-deprecated-volatile")
Expand Down
8 changes: 4 additions & 4 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Debug
{
// TASK 2: Add file name and line number parameters
inline void glErrorCheck(){
// Task 2: Add file name and line number parameters
inline void glErrorCheck() {
GLenum error = glGetError();
while(error != GL_NO_ERROR){
while (error != GL_NO_ERROR) {
// Task 2: Edit this print statement to be more descriptive
std::cout<<error<<std::endl;
std::cout << error << std::endl;
error = glGetError();
}
}
Expand Down
20 changes: 8 additions & 12 deletions src/glrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ GLRenderer::GLRenderer(QWidget *parent)
void GLRenderer::finish()
{
makeCurrent();
// Task 19: Clean up you VBO and VAO memory here

// Task 19: Clean up your VBO and VAO memory here

glDeleteProgram(m_shader);
doneCurrent();
Expand All @@ -30,10 +31,10 @@ void GLRenderer::initializeGL()

// Task 4: Set the clear color here

m_shader = ShaderLoader::createShaderProgram(":/Resources/Shaders/default.vert", ":/Resources/Shaders/default.frag"); // Shader setup (DO NOT EDIT)

// Shader setup (DO NOT EDIT)
m_shader = ShaderLoader::createShaderProgram(":/resources/shaders/default.vert", ":/resources/shaders/default.frag");

// Vertex Buffer Objects //
// ================== Vertex Buffer Objects

// Task 5: Generate a VBO here and store it in m_vbo

Expand All @@ -43,17 +44,15 @@ void GLRenderer::initializeGL()

// Task 9: Pass the triangle vector into your VBO here


// Vertex Array Objects //
// ================== Vertex Array Objects

// Task 11: Generate a VAO here and store it in m_vao

// Task 12: Bind the VAO you created here

// Task 13: Add position and color attributes to your VAO here


// Returning to Default State //
// ================== Returning to Default State

// Task 14: Unbind your VBO and VAO here
}
Expand All @@ -73,7 +72,4 @@ void GLRenderer::paintGL()
glUseProgram(0);
}

void GLRenderer::resizeGL(int w, int h)
{

}
void GLRenderer::resizeGL(int w, int h) {}
17 changes: 7 additions & 10 deletions src/glrenderer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef GLRENDERER_H
#define GLRENDERER_H
#pragma once

#include "GL/glew.h"
#include <QOpenGLWidget>
Expand All @@ -12,14 +11,12 @@ class GLRenderer : public QOpenGLWidget
void finish();

protected:
void initializeGL() override; //Called once at the start of the program
void paintGL() override; //Called every frame in a loop
void resizeGL(int width, int height) override; //Called when window size changes
void initializeGL() override; // Called once at the start of the program
void paintGL() override; // Called every frame in a loop
void resizeGL(int width, int height) override; // Called when window size changes

private:
GLuint m_shader; //Stores id for shader program
GLuint m_vbo; //Stores id for vbo
GLuint m_vao; //Stores id for vao
GLuint m_shader; // Stores id of shader program
GLuint m_vbo; // Stores id of VBO
GLuint m_vao; // Stores id of VAO
};

#endif // GLRENDERER_H
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QCoreApplication::setApplicationName("Lab 9: VBOs/VAOs");
QCoreApplication::setOrganizationName("QtProject");
QCoreApplication::setApplicationName("Lab 9: VBOs & VAOs");
QCoreApplication::setOrganizationName("CS 1230");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);

QSurfaceFormat fmt;
Expand Down
4 changes: 1 addition & 3 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#pragma once

#include <QMainWindow>
#include "glrenderer.h"
Expand All @@ -15,4 +14,3 @@ class MainWindow : public QWidget
private:
GLRenderer *glRenderer;
};
#endif // MAINWINDOW_H

0 comments on commit 587a85d

Please sign in to comment.