35 #include <Base/Image/ImageIO.hh>
36 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
37 #include <OpenGLFramework/Base/glfException.hh>
38 #include <OpenGLFramework/Base/glfBatch.hh>
39 #include <OpenGLFramework/Base/glfScreen.hh>
40 #include <OpenGLFramework/Base/glfViewport.hh>
41 #include <OpenGLFramework/Base/glfVertexBuffer.hh>
42 #include <OpenGLFramework/Base/glfElementBuffer.hh>
53 Vertex(
float x,
float y,
float z,
unsigned char r,
unsigned char g,
unsigned char b) {
64 unsigned char color[4];
68 int main(
int argc,
char* argv[])
96 cout <<
"--- Requested Config ---" << endl;
98 cout << endl <<
"--- Real Config ---" << endl;
102 glfScreen& screen = glfScreen::GetInstance();
107 vector<Vertex> vertices;
108 vertices.push_back(Vertex( 0.0f, -0.5f, 0.5f, 255, 0, 0));
109 vertices.push_back(Vertex(-0.5f, 0.5f, 0.5f, 255, 0, 0));
110 vertices.push_back(Vertex( 0.5f, 0.5f, 0.5f, 255, 0, 0));
111 vertices.push_back(Vertex( 0.2f, -0.2f, 0.8f, 0, 255, 0));
112 vertices.push_back(Vertex( 0.0f, 0.2f, 0.8f, 0, 255, 0));
113 vertices.push_back(Vertex( 0.6f, 0.2f, 0.8f, 0, 255, 0));
117 vertexFormat.
AddAttribute(glfVertexFormat::ATTRIB_POSITION, GL_FLOAT, 3);
118 vertexFormat.
AddAttribute(glfVertexFormat::ATTRIB_COLOR, GL_UNSIGNED_BYTE, 4);
122 vertexBuffer.
Create(vertices, vertexFormat);
125 std::vector<unsigned char> indices;
126 indices.push_back(0);
127 indices.push_back(1);
128 indices.push_back(2);
129 indices.push_back(3);
130 indices.push_back(4);
131 indices.push_back(5);
132 indices.push_back(6);
134 elementBuffer.
Create(indices, GL_TRIANGLES);
155 context->
Grab(image, glfRenderingContext::GRAB_COLOR);
158 if (ImageIO::Save(
"color.mip", image) != 0) {
161 context->
Grab(image, glfRenderingContext::GRAB_DEPTH);
163 if (ImageIO::Save(
"depth.mip", image) != 0) {
166 context->
Grab(image, glfRenderingContext::GRAB_STENCIL);
168 if (ImageIO::Save(
"stencil.mip", image) != 0) {
An element buffer contains vertex indices that form primitives.
void SetVertexBuffer(const glfVertexBuffer *vertexBuffer)
Sets the vertex buffer.
void Dump(std::ostream &out=std::cout)
Defines the usage of the depth buffer.
void SetDepthBufferMode(const glfDepthBufferMode *depthBufferMode)
Sets the depth buffer mode.
void Draw()
Draws the batch.
A vertex buffer contains an array of vertices that can be used for rendering.
Exception class used for run-time errors in the OpenGLFramework.
A batch represents a single Draw call including all parameters (render states).
Represents the default render target of the current OpenGL context, i.e.
void Create(int numVertices, const glfVertexFormat &format, const void *data=NULL, bool useBufferIfPossible=true)
Creates the vertex buffer for the given number of vertices and vertex format.
const std::string & GetMessageString() const
Returns the description of the error including the file name and line number where the error occured...
Interface for OpenGL rendering contexts.
void SetViewport(const glfViewport *viewport)
Sets the viewport.
class for setting viewports
GLX pbuffer rendering context.
virtual void GetConfig(glfRenderingContextConfig &config)=0
Gets the currently used config of the rendering context.
void ClearDepthBuffer(float depth=1.0f)
Clears the depth buffer of the render target with the given value.
void Create(int numIndices, GLenum type, GLenum mode, const void *indices)
Creates the element buffer for the given number of indices.
void SetDepthTest(bool enable)
Sets whether to use depth buffer tests.
void SetSize(int width, int height)
Sets the size of the viewport in pixel coordinates.
void SetOrigin(int x, int y)
Sets the position of the upper-left corner of the viewport in pixel coordinates.
void SetElementBuffer(const glfElementBuffer *elementBuffer)
Sets the element buffer.
void ClearColorBuffer(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=0.0f)
Clears the color buffer of the render target with the given color.
virtual void Destroy()=0
Uninitializes the rendering context.
void Grab(BIAS::Image< unsigned char > &image, GrabSource source=GRAB_COLOR, int x=0, int y=0, int width=0, int height=0)
Copies the contents of the framebuffer to an image.
Configuration for a rendering context.
virtual void Init(const glfRenderingContextConfig &config)=0
Initializes the rendering context with the given configuration.