/*
 * Copyright © 2009 Intel Corporation
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of the copyright holders not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  The copyright holders make no representations
 * about the suitability of this software for any purpose.  It is provided "as
 * is" without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

#ifndef _UGL_H
#define _UGL_H

/*
 * What and why:
 *
 * - with FBOs and a way to present the color buffer to the underlying
 *   window system, we don't need EGLSurfaces or EGLConfigs.  We don't
 *   need EGLSwapBuffer or all the entry points and extensions to
 *   control its behaviour.  The ugl application will manage double
 *   buffering and presentation itself by binding and unbinding render
 *   buffers and passing them to the window system.
 *
 * We need:
 *
 * - events; async glReadPixels result, integrating sync objects with
 *   main loop, async glFinish?
 */


struct udev_device;

struct ugl_device;
struct ugl_context;
struct ugl_surface;

struct ugl_device *ugl_device_create(struct udev_device *device);
struct ugl_device *ugl_device_create_from_fd(int fd);
void ugl_device_destroy(struct ugl_device *device);
int ugl_device_get_fd(struct ugl_device *device);

struct ugl_context *ugl_context_create(struct ugl_device *device);
void ugl_context_destroy(struct ugl_context *context);
int ugl_context_make_current(struct ugl_context *context);
struct ugl_context *ugl_context_get_current(void);


enum {
	UGL_SURFACE_SCANOUT = 0x01
};

void ugl_surface_create(GLint width, GLint height,
			GLint internal_format, const EGLint *attrib_list);
void ugl_surface_destroy(struct ugl_surface *surface);
GLuint ugl_surface_get_handle(struct ugl_surface *surface);
GLuint ugl_surface_get_name(struct ugl_surface *surface);
GLuint ugl_surface_get_stride(struct ugl_surface *surface);
void ugl_surface_attach(GLenum target);
				/* GL_TEXTURE_2D or GL_RENDERBUFFER_EXT */



#endif

