-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 460 core | ||
|
||
out vec4 FragColor; | ||
|
||
void main() | ||
{ | ||
FragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#version 460 core | ||
|
||
layout (location = 0) in vec2 aPos; | ||
|
||
void main() | ||
{ | ||
gl_Position = vec4(aPos, 0.0f, 1.0f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/******************************************************************************** | ||
* * | ||
* HSGIL - Handy Scalable Graphics Integration Library * | ||
* Copyright (c) 2019-2023 Adrian Bedregal * | ||
* * | ||
* This software is provided 'as-is', without any express or implied * | ||
* warranty. In no event will the authors be held liable for any damages * | ||
* arising from the use of this software. * | ||
* * | ||
* Permission is granted to anyone to use this software for any purpose, * | ||
* including commercial applications, and to alter it and redistribute it * | ||
* freely, subject to the following restrictions: * | ||
* * | ||
* 1. The origin of this software must not be misrepresented; you must not * | ||
* claim that you wrote the original software. If you use this software * | ||
* in a product, an acknowledgment in the product documentation would be * | ||
* appreciated but is not required. * | ||
* 2. Altered source versions must be plainly marked as such, and must not be * | ||
* misrepresented as being the original software. * | ||
* 3. This notice may not be removed or altered from any source distribution. * | ||
* * | ||
********************************************************************************/ | ||
|
||
#include <HSGIL/hsgil.hpp> | ||
|
||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
gil::RenderingWindow window(800, 600, "Shader Tester"); | ||
if (!window.isReady()) | ||
{ | ||
std::cerr << "Window is not ready, something went wrong" << std::endl; | ||
return -1; | ||
} | ||
|
||
gil::InputHandler inputHandler; | ||
window.setInputHandler(inputHandler); | ||
|
||
gil::Shader shader("test"); | ||
float vertexData[] = | ||
{ | ||
// Position | ||
-0.5f, -0.5f, | ||
0.5f, -0.5f, | ||
0.0f, 0.5f | ||
}; | ||
gil::uint32 VAO, VBO; | ||
glGenVertexArrays(1, &VAO); | ||
glGenBuffers(1, &VBO); | ||
|
||
glBindVertexArray(VAO); | ||
|
||
glBindBuffer(GL_ARRAY_BUFFER, VBO); | ||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); | ||
|
||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (const void*)0); | ||
glEnableVertexAttribArray(0); | ||
|
||
glBindVertexArray(0); | ||
|
||
gil::Timer timer; | ||
while (window.isActive()) | ||
{ | ||
window.pollEvents(); | ||
if (inputHandler.onKeyDown(gil::KEY_ESCAPE)) | ||
{ | ||
window.close(); | ||
} | ||
|
||
shader.use(); | ||
glClearColor(0.2f, 0.5f, 1.0f, 1.0f); | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
glBindVertexArray(VAO); | ||
glDrawArrays(GL_TRIANGLES, 0, sizeof(vertexData) / sizeof(float)); | ||
glBindVertexArray(0); | ||
|
||
window.swapBuffers(); | ||
timer.tick(); | ||
} | ||
|
||
return 0; | ||
} |