+++ DYNRPG - THE RM2K3 PLUGIN SDK +++

Posts

Technically, anything's possible if you know how to do it. A lot of that would require experimenting with RPG::battleData, which can be pretty tiresome and finicky. You also have to work around internal 2k3 functions that get called upon victory/defeat that haven't been written for DynRPG yet (and might not since I don't have documentation for them).

Continue the battle screen after victory
You might be able to partially do this with RPG::battleData->battlePhase by keeping it valued at BPHASE_VICTORY and then setting it to BPHASE_END when you need to, but it could just loop the existing code for the rewards. RPG::battleData->battlEndTimer is another one to try experimenting with. Try setting that to a high value, although it might just be the timer between the last enemy being defeated and the rewards.

Stop experience/gold awards
Stop the battle
I think you can do this with:
if (RPG::battleData->battlePhase == RPG::BPHASE_VICTORY) RPG::battleData->battlePhase = RPG::BPHASE_END;
(onFrame)

BPHASE_END is essentially the start of the transition from the battle scene to the map scene I believe, although some stuff might break if the enemies in the monster group still exist... idk.

Record experience/gold etc if desired (for an out of battle awards system)
This is probably one of those function issues where the MonsterGroup gets sent to a function and 2k3 spits out whatever gets added to your inventory, and then draws it as an image in a window class. Whether those end values get stored temporarily somewhere that can be pulled from, I don't know.

Add a custom awards message if desired (either the narrow battle message or the standard text box)
You could try using the RPG::Window classes (or write your own with RPG::Image), but it gets really hairy.
Small update to DynBattleChoices: Created a workaround to avoid a DynRPG bug which caused problems when a battler targets itself with a skill that uses more than half of its remaining MP.

For other DynRPG developers, take heed of the weird bug I ran across: if a battler uses a skill that consumes more than half of its remaining MP and targets itself with it (which could be either a self-targeting or single ally-targeting skill), then by the time the function onBattlerActionDone is called, the value of battler->action->kind will be RPG::AK_NONE instead of RPG::AK_SKILL like it should be. I've already notified Cherry about this. I was able to work around this problem by recording the battler-action data (all of it just to be safe) in the onDoBattlerAction function and then looking it up again when onBattlerActionDone is called.
I need something for put values in screen based in bitmaps pictures,
for make a gold counter of 9,999,999 for example, that manually
adding every picture for every number it's a crazy idea (and a lot of years of work).
I will have to wait for easyrpg editor or something, some day.
hey folks, sorry about the long hiatus but there was some stuff i needed to take care of :P

I've recently come across a small bug in the ResistControlBugIn plugin by Bugmenot

the @get_cdefault_hero X, Y, Z command, which finds the Y status resistance of hero X and writes it into the Z variable; now as I understood from the readme, the value is supposed to include both the normal hero resistance (which depends from the A-B-C-D-E status scaling) and whatever resist percentage is added by equipments, instead the variable Z only gets the normal resistance, ignoring the eqipments.

I apologize if the topic has already been adressed elsewhere, as I said I haven't been around lately, maybe I'm just using an older version... every help will be apreciated :P
I generally just write out the resistances including equipment myself, just to make doubly sure that it takes them into consideration. Means more coding, yes, but it makes damned sure that it works right!

This may or may not be because I don't understand how to REALLY use anything the thing says though. ^^;
author=Xenomic
I generally just write out the resistances including equipment myself, just to make doubly sure that it takes them into consideration. Means more coding, yes, but it makes damned sure that it works right!


yeah i'm doing this myself too now, insted of putting the X% resistance in the accessory entry in the database, I call a common event upon exiting the equipment screen, which detects which accessories do you have and edits the variable accordingly
I have the resistance left on all of the equipment just in case it does register them after reverting things. Can never tell, ya?
author=Xenomic
I have the resistance left on all of the equipment just in case it does register them after reverting things. Can never tell, ya?


good point, and it's also a quick way to take note of how much an equipment protects your characters :D
New source version:
http://www.rewking.com/dynrpg/changelog.html
(Get from the Main Page or https://github.com/PepsiOtaku/DynRPG)

Some additions of note: RPG::Battler::getAttackPower(), RPG::Battler::getSkillPower(), RPG::WindowMessage::text, "Play Movie" related stuff in RPG::Screen, & area rectangle variables in RPG::MapTreeProperties
Does the latest version have compatibility for counting the monster party size?
RPG::dbMonsterGroups[RPG::battleData->monsterGroupId]->monsterList.count()

Would get the monster count in the current battle.
Sigh... nvm.

I honestly don't know how to code this to do what I want.
Hello PepsiOtaku.
First of all, I really want to thank you for all your work.

I wanna ask you about the OpenGL render you were talking about in page 66, are you still working on it? Do you plan on sharing it in the end?
This is actually a good question. Two questions:

1. Who else here have issues with DirectDraw Error (DDERR_UNSUPPORTED) on Windows 8.1 or higher when on full screen mode? I had to use AlwaysWindowed.ips to bypass this.

2. Can people post some of the stuff mentioned on here? I'm trying to update my Big List sticky and there's a few plugins mentioned.
author=Zam
Hello PepsiOtaku.
First of all, I really want to thank you for all your work.

I wanna ask you about the OpenGL render you were talking about in page 66, are you still working on it? Do you plan on sharing it in the end?


Hopefully soon. I ended up starting another SFML project and have been working on that since August and have learned a ton of new stuff about the library, so I ended up going back and optimizing a bunch of things in the OpenGL plugin literally a couple weekends ago based on that newly learned stuff. There were some crash-to-desktop issues that I fixed as well as performance fixes.

It still doesn't support 2k3's "Play Movie" command, which I have sort of half figured out at this point, but there's an issue of whether or not I need to use something like ffmpeg for decoding since I can't redraw the video playing from the original directdraw renderer. I can block it like I'm doing with the regular canvas though, and just get the movie's filename for later use. I've also been going back/forth about adding a DynRPG-controlled UI for graphic settings. At the moment, it just uses comment commands and you have to build the UI yourself.
One thing you might be able to do is run it as if it were a battle animation (using the Play Movie command, but basically loading it as if it were a bunch of pictures). Whatever displays those may be able to be gerryrigged to run other stuff. Or running it using Windows Media codecs. Probably neither of these are right (I don't understand how this stuff runs), just throwing out ideas here to see if one is decent.

You should probably try to build OpenGL usage into a new DynRPG patch. Why? Well, aside from the last patch being 0.20, DirectDraw is deprecated (it literally causes crashes). So it might eventually be needed to keep 2k3 in running order as Windows continues to "upgrade" removing features.
author=bulmabriefs144
You should probably try to build OpenGL usage into a new DynRPG patch. Why? Well, aside from the last patch being 0.20, DirectDraw is deprecated (it literally causes crashes). So it might eventually be needed to keep 2k3 in running order as Windows continues to "upgrade" removing features.
Zam just referred to it in his post... <_<
https://rpgmaker.net/forums/topics/10254/?post=747512#post747512

Here's a video of it in action: https://www.youtube.com/watch?v=auqBuH24P6c

author=bulmabriefs144
One thing you might be able to do is run it as if it were a battle animation (using the Play Movie command, but basically loading it as if it were a bunch of pictures). Whatever displays those may be able to be gerryrigged to run other stuff. Or running it using Windows Media codecs. Probably neither of these are right (I don't understand how this stuff runs), just throwing out ideas here to see if one is decent.
It's way more complicated than that unfortunately.

On the 2k3 end: Play Movie outputs to a separate HWND (handler for a window or sub-window), which operates outside of onFrame & onDrawScreen, so you basically can't fetch the existing pixels and redraw it using those callbacks. What happens is that as soon as the movie starts, the movie's HWND is enabled and the other one with the callbacks we need is paused essentially. Which means it'd be easier to block it using onEventCommand for RPG::EVCMD_PLAY_MOVIE, "return false" and rewrite it entirely.

On the SFML end: The library doesn't support video playback, so you have to use an external library. VX Ace used one called Theora for example, and ffmpeg is another popular one, but both are written for C instead of C++, which complicates things. Next you need to either implement one of those libraries either in raw OpenGL or use one that someone else wrote. From there it just gets a lot more technical. There are two SFML wrappers for those video libraries, but one is dead (no site anymore, downloads, or documentation), and the other was built for visual studio and requires some ugly build process if you want to use it with any other IDE. It's probably a lost cause altogether honestly, so when I finally do release the plugin, it probably just won't have support for the Play Movie command.
author=PepsiOtaku
author=bulmabriefs144
You should probably try to build OpenGL usage into a new DynRPG patch. Why? Well, aside from the last patch being 0.20, DirectDraw is deprecated (it literally causes crashes). So it might eventually be needed to keep 2k3 in running order as Windows continues to "upgrade" removing features.
Zam just referred to it in his post... <_<
https://rpgmaker.net/forums/topics/10254/?post=747512#post747512

Here's a video of it in action: https://www.youtube.com/watch?v=auqBuH24P6c

author=bulmabriefs144
One thing you might be able to do is run it as if it were a battle animation (using the Play Movie command, but basically loading it as if it were a bunch of pictures). Whatever displays those may be able to be gerryrigged to run other stuff. Or running it using Windows Media codecs. Probably neither of these are right (I don't understand how this stuff runs), just throwing out ideas here to see if one is decent.

It's way more complicated than that unfortunately.

On the 2k3 end: Play Movie outputs to a separate HWND (handler for a window or sub-window), which operates outside of onFrame & onDrawScreen, so you basically can't fetch the existing pixels and redraw it using those callbacks. What happens is that as soon as the movie starts, the movie's HWND is enabled and the other one with the callbacks we need is paused essentially. Which means it'd be easier to block it using onEventCommand for RPG::EVCMD_PLAY_MOVIE, "return false" and rewrite it entirely.

On the SFML end: The library doesn't support video playback, so you have to use an external library. VX Ace used one called Theora for example, and ffmpeg is another popular one, but both are written for C instead of C++, which complicates things. Next you need to either implement one of those libraries either in raw OpenGL or use one that someone else wrote. From there it just gets a lot more technical. There are two SFML wrappers for those video libraries, but one is dead (no site anymore, downloads, or documentation), and the other was built for visual studio and requires some ugly build process if you want to use it with any other IDE. It's probably a lost cause altogether honestly, so when I finally do release the plugin, it probably just won't have support for the Play Movie command.


That definitely won't do. I have at least one video in each of my games, Oracle of Tao having a video play multiple times. Since the windowed mode of Direct Draw seems to work, would there be a way to switch to window mode from full/window to run videos, then switch back to whatever mode? Or just keep it windowed, and use whatever it runs on?

In the mean time, this webforum has links that may help. The video as texture idea seems interesting.

https://www.opengl.org/discussion_boards/showthread.php/156765-how-to-play-video-in-opengl

Scrounging around, this appears to be "render to texture" code (unless I got the wrong one).

// Include standard headers

#include <stdio.h>
#include <stdlib.h>
#include <vector>

// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <glfw3.h>
GLFWwindow* window;

// Include GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
using namespace glm;

#include <common/shader.hpp>
#include <common/texture.hpp>
#include <common/controls.hpp>
#include <common/objloader.hpp>
#include <common/vboindexer.hpp>

int main( void )
{
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
getchar();
return -1;
}

glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

// Open a window and create its OpenGL context
window = glfwCreateWindow( 1024, 768, "Tutorial 14 - Render To Texture", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
getchar();
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);

// We would expect width and height to be 1024 and 768
int windowWidth = 1024;
int windowHeight = 768;
// But on MacOS X with a retina screen it'll be 1024*2 and 768*2, so we get the actual framebuffer size:
glfwGetFramebufferSize(window, &windowWidth, &windowHeight);

// Initialize GLEW
glewExperimental = true; // Needed for core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
getchar();
glfwTerminate();
return -1;
}

// Ensure we can capture the escape key being pressed below
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
// Hide the mouse and enable unlimited mouvement
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

// Set the mouse at the center of the screen
glfwPollEvents();
glfwSetCursorPos(window, 1024/2, 768/2);

// Dark blue background
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);

// Enable depth test
glEnable(GL_DEPTH_TEST);
// Accept fragment if it closer to the camera than the former one
glDepthFunc(GL_LESS);

// Cull triangles which normal is not towards the camera
glEnable(GL_CULL_FACE);

GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);

// Create and compile our GLSL program from the shaders
GLuint programID = LoadShaders( "StandardShadingRTT.vertexshader", "StandardShadingRTT.fragmentshader" );

// Get a handle for our "MVP" uniform
GLuint MatrixID = glGetUniformLocation(programID, "MVP");
GLuint ViewMatrixID = glGetUniformLocation(programID, "V");
GLuint ModelMatrixID = glGetUniformLocation(programID, "M");

// Load the texture
GLuint Texture = loadDDS("uvmap.DDS");

// Get a handle for our "myTextureSampler" uniform
GLuint TextureID = glGetUniformLocation(programID, "myTextureSampler");

// Read our .obj file
std::vector<glm::vec3> vertices;
std::vector<glm::vec2> uvs;
std::vector<glm::vec3> normals;
bool res = loadOBJ("suzanne.obj", vertices, uvs, normals);

std::vector<unsigned short> indices;
std::vector<glm::vec3> indexed_vertices;
std::vector<glm::vec2> indexed_uvs;
std::vector<glm::vec3> indexed_normals;
indexVBO(vertices, uvs, normals, indices, indexed_vertices, indexed_uvs, indexed_normals);

// Load it into a VBO

GLuint vertexbuffer;
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_vertices.size() * sizeof(glm::vec3), &indexed_vertices[0], GL_STATIC_DRAW);

GLuint uvbuffer;
glGenBuffers(1, &uvbuffer);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_uvs.size() * sizeof(glm::vec2), &indexed_uvs[0], GL_STATIC_DRAW);

GLuint normalbuffer;
glGenBuffers(1, &normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_normals.size() * sizeof(glm::vec3), &indexed_normals[0], GL_STATIC_DRAW);

// Generate a buffer for the indices as well
GLuint elementbuffer;
glGenBuffers(1, &elementbuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short), &indices[0], GL_STATIC_DRAW);

// Get a handle for our "LightPosition" uniform
glUseProgram(programID);
GLuint LightID = glGetUniformLocation(programID, "LightPosition_worldspace");


// ---------------------------------------------
// Render to Texture - specific code begins here
// ---------------------------------------------

// The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
GLuint FramebufferName = 0;
glGenFramebuffers(1, &FramebufferName);
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);

// The texture we're going to render to
GLuint renderedTexture;
glGenTextures(1, &renderedTexture);

// "Bind" the newly created texture : all future texture functions will modify this texture
glBindTexture(GL_TEXTURE_2D, renderedTexture);

// Give an empty image to OpenGL ( the last "0" means "empty" )
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, windowWidth, windowHeight, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);

// Poor filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// The depth buffer
GLuint depthrenderbuffer;
glGenRenderbuffers(1, &depthrenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, windowWidth, windowHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthrenderbuffer);

//// Alternative : Depth texture. Slower, but you can sample it later in your shader
//GLuint depthTexture;
//glGenTextures(1, &depthTexture);
//glBindTexture(GL_TEXTURE_2D, depthTexture);
//glTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT24, 1024, 768, 0,GL_DEPTH_COMPONENT, GL_FLOAT, 0);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

// Set "renderedTexture" as our colour attachement #0
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);

//// Depth texture alternative :
//glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthTexture, 0);


// Set the list of draw buffers.
GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers

// Always check that our framebuffer is ok
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
return false;


// The fullscreen quad's FBO
static const GLfloat g_quad_vertex_buffer_data[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
};

GLuint quad_vertexbuffer;
glGenBuffers(1, &quad_vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, quad_vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_quad_vertex_buffer_data), g_quad_vertex_buffer_data, GL_STATIC_DRAW);

// Create and compile our GLSL program from the shaders
GLuint quad_programID = LoadShaders( "Passthrough.vertexshader", "WobblyTexture.fragmentshader" );
GLuint texID = glGetUniformLocation(quad_programID, "renderedTexture");
GLuint timeID = glGetUniformLocation(quad_programID, "time");


do{
// Render to our framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
glViewport(0,0,windowWidth,windowHeight); // Render on the whole framebuffer, complete from the lower left corner to the upper right

// Clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Use our shader
glUseProgram(programID);

// Compute the MVP matrix from keyboard and mouse input
computeMatricesFromInputs();
glm::mat4 ProjectionMatrix = getProjectionMatrix();
glm::mat4 ViewMatrix = getViewMatrix();
glm::mat4 ModelMatrix = glm::mat4(1.0);
glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;

// Send our transformation to the currently bound shader,
// in the "MVP" uniform
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]);
glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]);

glm::vec3 lightPos = glm::vec3(4,4,4);
glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z);

// Bind our texture in Texture Unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture);
// Set our "myTextureSampler" sampler to user Texture Unit 0
glUniform1i(TextureID, 0);

// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);

// 2nd attribute buffer : UVs
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(
1, // attribute
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);

// 3rd attribute buffer : normals
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glVertexAttribPointer(
2, // attribute
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);

// Index buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);

// Draw the triangles !
glDrawElements(
GL_TRIANGLES, // mode
indices.size(), // count
GL_UNSIGNED_SHORT, // type
(void*)0 // element array buffer offset
);

glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glDisableVertexAttribArray(2);



// Render to the screen
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Render on the whole framebuffer, complete from the lower left corner to the upper right
glViewport(0,0,windowWidth,windowHeight);

// Clear the screen
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Use our shader
glUseProgram(quad_programID);

// Bind our texture in Texture Unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, renderedTexture);
// Set our "renderedTexture" sampler to user Texture Unit 0
glUniform1i(texID, 0);

glUniform1f(timeID, (float)(glfwGetTime()*10.0f) );

// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, quad_vertexbuffer);
glVertexAttribPointer(
0, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);

// Draw the triangles !
glDrawArrays(GL_TRIANGLES, 0, 6); // 2*3 indices starting at 0 -> 2 triangles

glDisableVertexAttribArray(0);


// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();

} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );

// Cleanup VBO and shader
glDeleteBuffers(1, &vertexbuffer);
glDeleteBuffers(1, &uvbuffer);
glDeleteBuffers(1, &normalbuffer);
glDeleteBuffers(1, &elementbuffer);
glDeleteProgram(programID);
glDeleteTextures(1, &TextureID);

glDeleteFramebuffers(1, &FramebufferName);
glDeleteTextures(1, &renderedTexture);
glDeleteRenderbuffers(1, &depthrenderbuffer);
glDeleteBuffers(1, &quad_vertexbuffer);
glDeleteVertexArrays(1, &VertexArrayID);


// Close OpenGL window and terminate GLFW
glfwTerminate();

return 0;
}