#include <Base/Image/ImageIO.hh>
#include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
#include <OpenGLFramework/Base/glfException.hh>
#include <OpenGLFramework/Base/glfBatch.hh>
#include <OpenGLFramework/Base/glfScreen.hh>
#include <OpenGLFramework/Base/glfViewport.hh>
#include <OpenGLFramework/Base/glfVertexBuffer.hh>
#include <OpenGLFramework/Base/glfElementBuffer.hh>
#include <vector>
using namespace std;
using namespace BIAS;
struct Vertex {
Vertex(float x, float y, float z, unsigned char r, unsigned char g, unsigned char b) {
position[0] = x;
position[1] = y;
position[2] = z;
color[0] = r;
color[1] = g;
color[2] = b;
color[3] = 255;
}
float position[3];
unsigned char color[4];
};
int main(int argc, char* argv[])
{
try {
cout << "--- Requested Config ---" << endl;
cout << endl << "--- Real Config ---" << endl;
glfScreen& screen = glfScreen::GetInstance();
vector<Vertex> vertices;
vertices.push_back(Vertex( 0.0f, -0.5f, 0.5f, 255, 0, 0));
vertices.push_back(Vertex(-0.5f, 0.5f, 0.5f, 255, 0, 0));
vertices.push_back(Vertex( 0.5f, 0.5f, 0.5f, 255, 0, 0));
vertices.push_back(Vertex( 0.2f, -0.2f, 0.8f, 0, 255, 0));
vertices.push_back(Vertex( 0.0f, 0.2f, 0.8f, 0, 255, 0));
vertices.push_back(Vertex( 0.6f, 0.2f, 0.8f, 0, 255, 0));
vertexFormat.
AddAttribute(glfVertexFormat::ATTRIB_POSITION, GL_FLOAT, 3);
vertexFormat.
AddAttribute(glfVertexFormat::ATTRIB_COLOR, GL_UNSIGNED_BYTE, 4);
vertexBuffer.
Create(vertices, vertexFormat);
std::vector<unsigned char> indices;
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(3);
indices.push_back(4);
indices.push_back(5);
indices.push_back(6);
elementBuffer.
Create(indices, GL_TRIANGLES);
context->
Grab(image, glfRenderingContext::GRAB_COLOR);
if (ImageIO::Save("color.mip", image) != 0) {
return -1;
}
context->
Grab(image, glfRenderingContext::GRAB_DEPTH);
if (ImageIO::Save("depth.mip", image) != 0) {
return -1;
}
context->
Grab(image, glfRenderingContext::GRAB_STENCIL);
if (ImageIO::Save("stencil.mip", image) != 0) {
return -1;
}
return -1;
}
return 0;
}