-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial shader support, add "High" effect
- Loading branch information
1 parent
db3d1ce
commit 72a0ca5
Showing
19 changed files
with
33,214 additions
and
7 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,23 @@ | ||
#include "includes.h" | ||
|
||
void CFeatureHigh::Init() | ||
{ | ||
CChaosFeature::Init(); | ||
} | ||
|
||
void CFeatureHigh::ActivateFeature() | ||
{ | ||
CChaosFeature::ActivateFeature(); | ||
g_bActivatedShader = true; | ||
} | ||
|
||
void CFeatureHigh::DeactivateFeature() | ||
{ | ||
CChaosFeature::DeactivateFeature(); | ||
g_bActivatedShader = false; | ||
} | ||
|
||
const char* CFeatureHigh::GetFeatureName() | ||
{ | ||
return "High"; | ||
} |
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,37 @@ | ||
/** | ||
* Copyright - ScriptedSnark, 2024. | ||
* CFeatureHigh.h | ||
* | ||
* Project (GSChaos) header file | ||
* Authors: ScriptedSnark. | ||
* Do not delete this comment block. Respect others' work! | ||
*/ | ||
|
||
#ifdef CFEATUREHIGH_H_RECURSE_GUARD | ||
#error Recursive header files inclusion detected in CFeatureHigh.h | ||
#else //CFEATUREHIGH_H_RECURSE_GUARD | ||
|
||
#define CFEATUREHIGH_H_RECURSE_GUARD | ||
|
||
#ifndef CFEATUREHIGH_H_GUARD | ||
#define CFEATUREHIGH_H_GUARD | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
|
||
class CFeatureHigh : public CChaosFeature | ||
{ | ||
void Init() override; | ||
void ActivateFeature() override; | ||
void DeactivateFeature() override; | ||
const char* GetFeatureName() override; | ||
}; | ||
|
||
#else //!__cplusplus | ||
#error C++ compiler required to compile CFeatureHigh.h | ||
#endif //__cplusplus | ||
|
||
#endif //CFEATUREHIGH_H_GUARD | ||
|
||
#undef CFEATUREHIGH_H_RECURSE_GUARD | ||
#endif //CFEATUREHIGH_H_RECURSE_GUARD |
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
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,115 @@ | ||
#include "includes.h" | ||
|
||
namespace OpenGLShader | ||
{ | ||
std::string loadShaderFromFile(const std::string& fileName) | ||
{ | ||
std::ifstream shaderFile(fileName); | ||
std::stringstream shaderStream; | ||
shaderStream << shaderFile.rdbuf(); | ||
return shaderStream.str(); | ||
} | ||
|
||
GLuint CreateVertexShader(const std::string& fileName) | ||
{ | ||
std::string shaderSource = loadShaderFromFile(fileName); | ||
const char* shaderSourceCStr = shaderSource.c_str(); | ||
|
||
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); | ||
glShaderSource(vertexShader, 1, &shaderSourceCStr, NULL); | ||
glCompileShader(vertexShader); | ||
|
||
// checking for errors | ||
GLint success; | ||
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success); | ||
if (!success) | ||
{ | ||
char infoLog[512]; | ||
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog); | ||
printf("Error compiling vertex shader: %s\n", infoLog); | ||
return 0; | ||
} | ||
|
||
return vertexShader; | ||
} | ||
|
||
GLuint CreateFragmentShader(const std::string& fileName) | ||
{ | ||
std::string shaderSource = loadShaderFromFile(fileName); | ||
const char* shaderSourceCStr = shaderSource.c_str(); | ||
|
||
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); | ||
glShaderSource(fragmentShader, 1, &shaderSourceCStr, NULL); | ||
glCompileShader(fragmentShader); | ||
|
||
// checking for errors | ||
GLint success; | ||
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success); | ||
if (!success) | ||
{ | ||
char infoLog[512]; | ||
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog); | ||
printf("Error compiling fragment shader: %s\n", infoLog); | ||
return 0; | ||
} | ||
|
||
return fragmentShader; | ||
} | ||
|
||
GLuint CreateProgram(GLuint vertexShader, GLuint fragmentShader) | ||
{ | ||
// shader program creation | ||
GLuint shaderProgram = glCreateProgram(); | ||
|
||
if (vertexShader) | ||
glAttachShader(shaderProgram, vertexShader); | ||
|
||
if (fragmentShader) | ||
glAttachShader(shaderProgram, fragmentShader); | ||
|
||
glLinkProgram(shaderProgram); | ||
|
||
// checking for compiler & linker errors | ||
GLint success; | ||
GLchar infoLog[512]; | ||
|
||
if (vertexShader) | ||
{ | ||
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success); | ||
|
||
if (!success) | ||
{ | ||
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog); | ||
printf("Error compiling vertex shader: %s\n", infoLog); | ||
} | ||
} | ||
|
||
if (fragmentShader) | ||
{ | ||
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success); | ||
|
||
if (!success) | ||
{ | ||
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog); | ||
printf("Error compiling fragment shader: %s\n", infoLog); | ||
} | ||
} | ||
|
||
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success); | ||
|
||
if (!success) | ||
{ | ||
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog); | ||
printf("Error linking shader program: %s\n", infoLog); | ||
} | ||
|
||
return shaderProgram; | ||
} | ||
|
||
void Cleanup(GLuint vertexShader, GLuint fragmentShader) | ||
{ | ||
// cleaning up shaders | ||
glDeleteShader(vertexShader); | ||
glDeleteShader(fragmentShader); | ||
} | ||
}; |
Oops, something went wrong.