Ejemplo n.º 1
0
/*
 * Return the color buffer associated with an OSMesa context.
 * Input:  c - the OSMesa context
 * Output:  width, height - size of buffer in pixels
 *          format - buffer format (OSMESA_FORMAT)
 *          buffer - pointer to depth buffer values
 * Return:  GL_TRUE or GL_FALSE to indicate success or failure.
 *
 * New in Mesa 3.3.
 */
func GetColorBuffer(c Context, width *int, height *int,
	format *Format, buffer *unsafe.Pointer) {

	var width_ C.GLint
	var height_ C.GLint
	var format_ C.GLint
	var buffer_ unsafe.Pointer

	C.OSMesaGetDepthBuffer(C.OSMesaContext(c), &width_, &height_,
		&format_, &buffer_)

	*width = int(width_)
	*height = int(height_)
	*format = Format(format_)
	*buffer = buffer_

}
Ejemplo n.º 2
0
/*
 * Return the depth buffer associated with an OSMesa context.
 * Input:  c - the OSMesa context
 * Output:  width, height - size of buffer in pixels
 *          bytesPerValue - bytes per depth value (2 or 4)
 *          buffer - pointer to depth buffer values
 * Return:  GL_TRUE or GL_FALSE to indicate success or failure.
 *
 * New in Mesa 2.4.
 */
func GetDepthBuffer(c Context, width *int, height *int,
	bytesPerValue *int, buffer *unsafe.Pointer) {

	var width_ C.GLint
	var height_ C.GLint
	var bytesPerValue_ C.GLint
	var buffer_ unsafe.Pointer

	C.OSMesaGetDepthBuffer(C.OSMesaContext(c), &width_, &height_,
		&bytesPerValue_, &buffer_)

	*width = int(width_)
	*height = int(height_)
	*bytesPerValue = int(bytesPerValue_)
	*buffer = buffer_

}
Ejemplo n.º 3
0
/*
 * Bind an osmesa.Context to an image buffer.  The image buffer is just a
 * block of memory which the client provides.  Its size must be at least
 * as large as width*height*sizeof(type).  Its address should be a multiple
 * of 4 if using RGBA mode.
 *
 * Image data is stored in the order of glDrawPixels:  row-major order
 * with the lower-left image pixel stored in the first array position
 * (ie. bottom-to-top).
 *
 * Since the only type initially supported is GL_UNSIGNED_BYTE, if the
 * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA
 * value.  If the context is in color indexed mode, each pixel will be
 * stored as a 1-byte value.
 *
 * If the context's viewport hasn't been initialized yet, it will now be
 * initialized to (0,0,width,height).
 *
 * Input:  ctx - the rendering context
 *         buffer - the image buffer memory
 *         type - data type for pixel components, only GL_UNSIGNED_BYTE
 *                supported now
 *         width, height - size of image buffer in pixels, at least 1
 * Return:  GL_TRUE if success, GL_FALSE if error because of invalid ctx,
 *          invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1,
 *          width>internal limit or height>internal limit.
 */
func MakeCurrent(ctx Context, buffer unsafe.Pointer, type_ PixelType,
	width int, height int) bool {

	return 0 != C.OSMesaMakeCurrent(C.OSMesaContext(ctx), buffer, C.GLenum(type_),
		C.GLsizei(width), C.GLsizei(height))
}
Ejemplo n.º 4
0
/*
 * Destroy an Off-Screen Mesa rendering context.
 *
 * Input:  ctx - the context to destroy
 */
func DestroyContext(ctx Context) {
	C.OSMesaDestroyContext(C.OSMesaContext(ctx))
}
Ejemplo n.º 5
0
/*
 * Create an Off-Screen Mesa rendering context and specify desired
 * size of depth buffer, stencil buffer and accumulation buffer.
 * If you specify zero for depthBits, stencilBits, accumBits you
 * can save some memory.
 *
 * New in Mesa 3.5
 */
func CreateContextExt(format Format, depthBits int, stencilBits int,
	accumBits int, sharelist Context) Context {
	return Context(C.OSMesaCreateContextExt(C.GLenum(format), C.GLint(depthBits), C.GLint(stencilBits),
		C.GLint(accumBits), C.OSMesaContext(sharelist)))
}
Ejemplo n.º 6
0
/*
 * Create an Off-Screen Mesa rendering context.  The only attribute needed is
 * an RGBA vs Color-Index mode flag.
 *
 * Input:  format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA,
 *                  OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR.
 *         sharelist - specifies another osmesa.Context with which to share
 *                     display lists.  NULL indicates no sharing.
 * Return:  an osmesa.Context or 0 if error
 */
func CreateContext(format Format, sharelist Context) Context {
	return Context(C.OSMesaCreateContext(C.GLenum(format), C.OSMesaContext(sharelist)))

}