Cross-platform rendering engine built from the ground up.
For current engine architecture and other features, see przet.com.
See also the releases.
struct MenuScreenPrototypeData
{
unsigned int VAO = 0;
unsigned int shaderProgram = 0;
unsigned int texture = 0;
bool button1 = false;
bool button2 = false;
};
struct Scene1Data
{
unsigned int VAO = 0;
unsigned int shaderProgram = 0;
unsigned int texture = 0;
};
struct SceneData
{
MenuScreenPrototypeData menuScreenPrototypeData;
Scene1Data scene1Data;
}sceneData;
enum E_DISPLAY_STATE
{
MENU_SCREEN_PROTOTYPE,
SCENE_1,
//... etc,
}DISPLAY_STATE;
void display(SceneData* sceneData)
{
switch(DISPLAY_STATE)
{
case MENU_SCREEN_PROTOTYPE:
display2DMenuPrototype(&sceneData->menuScreenPrototypeData.VAO,
&sceneData->menuScreenPrototypeData.shaderProgram,
&sceneData->menuScreenPrototypeData.texture,
sceneData->menuScreenPrototypeData.button1,
sceneData->menuScreenPrototypeData.button2);
break;
case SCENE_1:
displayScene1(&sceneData->scene1Data.VAO,
&sceneData->scene1Data.shaderProgram,
&sceneData->scene1Data.texture);
break;
// etc...
default:
break;
}
}
if (DISPLAY_STATE == MENU_SCREEN_PROTOTYPE)
{
// Example - this will later set shader uniform when rendering
// to attachments of currently bound framebuffer.
sceneData.menuScreenPrototypeData.button2 = true;
}
// Render to attachments of currently bound framebuffer
display(&sceneData)
If there is no VAO do the following for each scene display, once only, inside a frame:
- Create model vertex data - i.e. the model
- Write your shaders
- Make the shader program
- Specify the vertices
unsigned int compileVertexShader(const char* vertexShaderSource);
unsigned int compileFragmentShader(const char* fragmentShaderSource);
unsigned int compileComputeShader(const char* computeShaderSource);
unsigned int linkShaders(
unsigned int vertexShader,
unsigned int fragmentShader);
unsigned int linkShaders(unsigned int computeShader);
*shaderProgram = linkShaders(compileVertexShader(vs), compileFragmentShader(fs));
- Keyboard input with rising/falling edge handling
- 3D camera system (pitch, roll, yaw) and strafe
Phong Reflection:
Phong Exponent,
Ambient | Diffuse | Specular | ||
---|---|---|---|---|
yes | yes | yes | 32 | ![]() |
no | yes | yes | 32 | ![]() |
no | no | yes | 32 | ![]() |
yes | yes | yes | 16 | ![]() |
yes | yes | yes | 64 | ![]() |
Post-processing implemented by executing two render passes - the first one is an off screen render pass that renders the screen to a texture. This is achieved by creating a framebuffer and binding to that (using renderbuffers for when we don't need to sample depth and stencil buffers):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureTarget, 0);
// Create renderbuffer for attaching depth to currently bound framebuffer
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 600);
assert(glGetError() == 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
CheckFramebufferStatus();
There is:
- Inversion
- Grey-scale (simple average)
- Grey-scale (weighted average, eye)
- A scrolling effect
- Multiple Kernel effects: sharpen, blur, edge detection.
- Rear view mirror
- LearnOpenGL
- Fundamentals Of Computer Graphics 4th Edition (Marschner, S. and Shirley, P., 2018. Fundamentals of computer graphics. CRC Press.)
- Real Time Rendering 4th Edition (Akenine-Moller, T., Haines, E. and Hoffman, N., 2019. Real-time rendering. AK Peters/crc Press.)
- [Computer Graphcis with Modern OpenGL](https://www.udemy.com/course/graphics- with-modern-opengl/)