93 lines
1.8 KiB
C++
93 lines
1.8 KiB
C++
/*
|
|
==============================================================================
|
|
|
|
OpenGLUtils.h
|
|
Created: 17 Jan 2026 11:41:12am
|
|
Author: esca
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#pragma once
|
|
#include <vector>
|
|
//random shit for convenience
|
|
|
|
// fragcolour = vec4(colour.xyz, colour.w*pow(10, -(position.x*position.y)));
|
|
|
|
|
|
#define VERTEXSHADER R"(#version 330 core
|
|
in vec2 position;
|
|
in vec4 colour;
|
|
out vec4 fragcolour;
|
|
void main()
|
|
{
|
|
gl_Position = vec4(position, 1, 1);
|
|
fragcolour = colour;
|
|
if(position.x<0){
|
|
fragcolour.a = position.x+1;
|
|
}
|
|
else{
|
|
fragcolour.a = 1-position.x;
|
|
}
|
|
}
|
|
)"
|
|
|
|
#define FRAGSHADER R"(#version 330 core
|
|
in vec4 fragcolour;
|
|
void main()
|
|
{
|
|
gl_FragColor = fragcolour;
|
|
}
|
|
)"
|
|
|
|
#define VERTEXSHADERBACKGROUND R"(#version 330 core
|
|
layout (location = 0) in vec3 aPos;
|
|
layout (location = 1) in vec3 aColor;
|
|
layout (location = 2) in vec2 aTexCoord;
|
|
|
|
out vec3 ourColor;
|
|
out vec2 TexCoord;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = vec4(aPos, 1.0);
|
|
ourColor = aColor;
|
|
TexCoord = aTexCoord;
|
|
}
|
|
)"
|
|
|
|
#define FRAGSHADERBACKGROUND R"(#version 330 core
|
|
out vec4 FragColor;
|
|
|
|
in vec3 ourColor;
|
|
in vec2 TexCoord;
|
|
|
|
uniform sampler2D ourTexture;
|
|
|
|
void main()
|
|
{
|
|
FragColor = texture(ourTexture, TexCoord);
|
|
}
|
|
)"
|
|
|
|
struct Vertex{
|
|
float position[2];
|
|
float colour[4];
|
|
};
|
|
|
|
struct VertexTexture{
|
|
float position[2];
|
|
float colour[4];
|
|
float texturePosition[2];
|
|
};
|
|
|
|
void svCol(Vertex &v, float newColour[4]);
|
|
|
|
void setColour(std::vector<Vertex> &verticeList, float newColour[4]);
|
|
|
|
void vTransform(std::vector<Vertex> &verticeList, float x, float y);
|
|
|
|
void vScale(std::vector<Vertex> & verticeList, float x, float y);
|
|
|
|
std::vector<Vertex> generateSineWave(int numVertices, float angle, float startingColour[4]);
|