Added folder for opengl lessons

This commit is contained in:
Vitor Fernandes 2020-06-17 00:04:14 +01:00
parent 11fc1a33d8
commit 20fa19ad53
No known key found for this signature in database
GPG key ID: EBFB4EE09F348A26
6 changed files with 52 additions and 5 deletions

View file

@ -1 +1,2 @@
add_subdirectory(core)
add_subdirectory(opengl)

View file

@ -2,7 +2,7 @@
#define CORE_CPU_TYPES_H
/*
* Types for x86 arquitectures
* Types for x86 architectures
*/
#if defined(__x86_64__)
//Signed type alias

View file

@ -4,8 +4,6 @@
#include <iostream>
#include "types.hpp"
using namespace::std;
namespace Core {
namespace Cpu {

View file

@ -0,0 +1,5 @@
find_package(glfw3 3.3 REQUIRED)
find_package(OpenGL REQUIRED)
add_executable(gl1 gl1.cpp)
target_link_libraries(gl1 glfw)
target_link_libraries(gl1 OpenGL::GL)

43
src/opengl/gl1.cpp Normal file
View file

@ -0,0 +1,43 @@
#include <GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-1.0f,-1.0f);
glVertex2f(0.0f,1.0f);
glVertex2f(1.0f,-1.0f);
glEnd();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}