Skip to content

emmatle/Computer_graphics_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

Installation

On Windows

When opening the project for the first time, select the Visual Studio toolchain and not MinGW.

Install vcpkg if you don't have it on your Windows system pasting this line below in the terminal:

git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

Then install the dependencies (you should be in the vcpkg folder)

.\vcpkg.exe install freetype:x64-windows assimp:x64-windows glfw3:x64-windows openal-soft:x64-windows libsndfile:x64-windows

ATTENTION: It could take some minutes.

After the installation, in your Project Folder, run:

cmake -B build -DCMAKE_TOOLCHAIN_FILE= your_vcpkg_path+"scripts/buildsystems/vcpkg.cmake"
cmake --build build

IMPORTANT: If the cmake command is not found, in the Installation folder, there is the .msi file to install it.

On macOS

You need Homebrew to install dependencies. If you don't have it, install it by running this command in the terminal:

  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

To check if everything is correct, run (after reopening the terminal):

  brew --version

If the installation was successful it should print something like: Homebrew 4.x.x

Use brew to install dependencies:

  brew install assimp glfw freetype libsndfile

To Change your App Name, go to the CmakeLists.txt at line 8 and change the name of the project. And in the Main at line 48.

Usage

Project structure

The project is structured in the following way:

The Main.cpp file is the entry point of the project. It creates the window, the OpenGL context, and some global variables.

From here, it loads the Main View Controller. This is the first screen of the game. Right now there is a template background and a button to start the game (Not implemented yet).

In the Game Classes folder (now empty), you can add your own classes for the game, such as Player, GameManager, etc.

In the Data Classes folder, there are some classes used to load resources, such as the shader.h. In addition, here, there are:

IMPORTANT: You can change this structure, but do not move the CMakeLists.txt, Main.cpp, app_icon.rc, the resources' folder, the glad and glm-master folders. If you do, you will have to change the path in the CMakeLists.txt file.

Loading Resources

To make the project work, keep the directories struct of glad and glm-master in the root directory. Then in the OpenGLApp/OpenGLApp you can find your Main.cpp file and in this directory you can add all your costume files.

IMPORTANT: The resources directory must be in the same directory as the Main.cpp file. To load a resource, you have to add ../ before the path: ../resources/your_object.obj and not resources/your_object.obj.

If you want to change this structure, you can change the CmakeLists.txt file.

Icon (Optional)

On Windows

Convert the Icon file to a file .ico. You can use this website to do it.

Remember to save the .ico file in the Icon directory. If not, you have to change the path in the app_icon.rc

On macOS

To use a costume icon, create a file named icon.png in the resources' directory. Then in the terminal, from the project directory, run:

    mkdir -p OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset
    cp OpenGLApp/OpenGLApp/resources/Icon/Icon.png OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_512x512.png
    sips -z 16 16     OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_512x512.png --out OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_16x16.png
    sips -z 32 32     OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_512x512.png --out OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_16x16@2x.png
    sips -z 128 128   OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_512x512.png --out OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_128x128.png
    sips -z 256 256   OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_512x512.png --out OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset/icon_128x128@2x.png
    iconutil -c icns OpenGLApp/OpenGLApp/resources/Icon/Icon.iconset

If everything went well, you should have a file named Icon.icns in the here.

Build and Run

Once you have built the project, it will create a folder named cmake-build-debug on macOS, and cmake-build-debug-visual-studio in the root directory. In this folder, you can run the executable file with your APP name.

You can also execute it directly from the IDE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published