/OpenGL_Learn

Trying to learn OpenGL...

Primary LanguageHTML

External Libraries

Configuration Properties Path
C/C++ > General > Additional Include Directories $(SolutionDir)External_lib/GLEW/include
$(SolutionDir)External_lib/GLFW/include
$(SolutionDir)External_lib/GLM
Linker > General > Additional Library Directories Dependencies $(SolutionDir)External_lib/GLEW/lib/Release/Win32
$(SolutionDir)External_lib/GLFW/lib-vc2015
Linker > Input > Additional Dependencies opengl32.lib
glfw3.lib
glew32.lib

Camera

Dependencies

GL/glew.h , GLFW/glfw3.h , glm/glm.hpp , glm/gtc/matrix_transform.hpp

Variables

access type name purpose
private glm::vec3 position Current position of camera
private glm::vec3 front Direction vector indicating the direction player is facing
private glm::vec3 up Direction vector indicating the top of the player
private glm::vec3 right Direction vector indicating the right of the player
private glm::vec3 worldUp Direction vector of where the top of the world is
private GLfloat yaw Rotation of camera about the z axis
private GLfloat pitch Rotation of camera about the y axis
private GLfloat moveSpeed Movement speed
private GLfloat turnSpeed Turning speedo

Constructors

parameter purpose
void Default constructor
glm::vec3 startPosition
glm::vec3 startUp
GLfloat startYaw
GLfloat startPitch
GLfloat startMoveSpeed
GLfloat startTurnSpeed
Comprehensive constructor which initialises variables

Methods

private

return type name parameter purpose
void update void Update front based on yaw & pitch
Update right based on front & worldUp
Update up based on right & front

public

return type name parameter purpose
void keyControl bool* keys
GLfloat deltaTime
Set events based on keys.
Move player based on deltaTime
void mouseControl GLfloat xChange
GLfloat yChange
Change pitch and yaw based on mouse movement
glm::mat4 calculateViewMatrix void Using glm::lookAt, calculate view matrix
based on position , position + front & up

Destructors

parameter purpose
void Default destructor

Mesh

Dependencies

GL/glew.h

Variables

access type name purpose
private GLuint VAO Vertex Array Object. Stores information of a complete render object
private GLuint VBO Vertex Buffer Object. Memory buffer to hold
private GLuint IBO Index Buffer Object. Store indexes of render object

Constructors

parameter purpose
void Default constructor

Methods

public

return type name parameter purpose
void create unsigned int numOfVertices
GLfloat* vertices
unsigned int numOfIndices
unsigned int* indices
Generates VAO, IBO & VBO.
Assign vertices and indices data to buffers.
Sets Vertex Attribute Poitner.
void render void Binds VAO and IBO and draws object.
void clear void Deletes buffer and VAO, and set them to 0.

Destructors

parameter purpose
void Default destructor

Shader

Dependencies

stdio.h , string , fstream , GL/glew.h

Variables

access type name purpose
private GLuint ID ID of shader program.
private GLuint uniformProjection Location of projection matrix in shader.
private GLuint uniformModel Location of model matrix in shader.
private GLuint uniformView Location of view matrix in shader.

Constructors

parameter purpose
void Default constructor

Methods

private

return type name parameter purpose
void addShader GLuint program
const char* code
GLenum type
Create shader of type.
Attach the source code.
Compile.
Attach to program.
void compileShaders const char* vertexCode
const char* fragmentCode
Create program.
Add shaders.
Link program.
Validate program.
Get location of matrices.
std::string fileContents const char* file Returns content of file.

public

return type name parameter purpose
void create const char* vertexFile
const char* fragmentFile
Gets code from files and compiles them.
GLuint getProjectionLocation void Returns uniformProjection.
GLuint getModelLocation void Returns uniformModel.
GLuint getViewLocation void Returns uniformView.
void use void Uses this program.
void clear void Deletes program and sets variables to 0.

Destructors

parameter purpose
void Default destructor

Window

Dependencies

stdio.h , GL/glew.h , GLFW/glfw3.h

Variables

access type name purpose
private GLFWwindow* main Main window.
private GLint width Width of window.
private GLint height Height of window.
private GLint bufferWidth Buffer width of window.
private GLint bufferHeight Buffer height of window.
private bool [1024] keys State of keys.
private GLfloat lastX Last X position of mouse.
private GLfloat lastY Last Y position of mouse.
private GLfloat xChange X difference from lastX and current X.
private GLfloat yChange Y difference from lastY and current Y.
private bool mouseFirstMoved Indicates if this is mouse first position.

Constructors

parameter purpose
void Default constructor
GLint w
GLint h
Initialise width & height

Methods

private

return type name parameter purpose
void createCallbacks void Sets key an cursor position callbacks.
void static handleKeys GLFWwindow* w
int key
int code
int action
int mode
Set keys to true based on which are pressed.
void static handleMouse GLFWwindow* w
double xPos
double yPos
Set xChange and yChange based on mouse movmements.

public

return type name parameter purpose
void create const char* vertexFile
const char* fragmentFile
Gets code from files and compiles them.

Destructors

parameter purpose
void Default destructor