Giter Site home page Giter Site logo

learnopengl's Introduction

LearnOpenGL

This repo is for documenting my progress with the LearnOpenGL chapters

Getting Started

Triangle

In the first few chapters I learned how to set up GLFW and GLAD, create a window, and draw a triangle.

I also learned how to set up CMake in the process which allowed me to have multiple .exe applications within different folders so I can make seperate applications for the chapters and exercises to showcase and document each and every step of my progress.

First Triangle

First thing I did was specify my triangle's vertices and define them in a float array, then I create a VBO (Vertex Buffer Object) and a VAO (Vertex Array Object), bind and assign data to a buffer for OpenGL to use, setting a pointer to where it should start looking at my vertices. And lastly, I create a Shader Program and attach the variables that contain my vertex shader and fragment shader to it, activate the program and bind the VBO and VAO to draw my triangle, then delete all these resources once it's done before closing the glfw window.

Triangle

Triangle Exercises

First Exercise

Drawing 2 triangles next to each other.

two_triangles

Second Exercise

Drawing 2 triangles with different Vertex Array Objects and Vertex Buffer Objects.

Third Exercise

Creating 2 shader programs where the programs use different fragment shaders that output different colors.

diff_triangles

Shaders

In this chapter I learned how to understand, write and work with vertex shaders and fragment shaders, as well as organizing my source files, header files and shader files.

tricolored

Shaders Exercises

First Exercise

Adjusting the vertex shader so that the triangle is upside down by simply putting a negative sign in front of the y value aPos.y in the vertex shader file.

upsidedown

Second Exercise

Creating a horizontal offset via a uniform float within the ShaderClass source file using the setFloat() method, and then moving the triangle to the right side of the screen in the vertex shader using this offset value by adding it to the x value aPos.x in the vertex shader file.

rightside

Third Exercise

Outputing the vertex position to the fragment shader using the out keyword and setting the fragment color to this vertex position, noticing in the process that the bottom left corner of the triangle was black due to the vertex position having negative values and the RGB values' range is 0-1 so the negative values always clamp to 0.0f within the RGB context.

blackcorner

learnopengl's People

Contributors

dietcokechan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.