Merge commit 'origin/master' into 1.0-integration
Conflicts: clutter/clutter-texture.c clutter/cogl/gl/cogl-fbo.c
This commit is contained in:
commit
b9cde2c6f4
50
Makefile.am
50
Makefile.am
@ -20,3 +20,53 @@ pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = $(pc_files)
|
||||
|
||||
CLEANFILES = $(pc_files)
|
||||
|
||||
AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||
|
||||
cogl_headers = \
|
||||
$(top_srcdir)/clutter/cogl/cogl-bitmap.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-color.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-debug.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-fixed.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-material.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-matrix.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-path.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-types.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h
|
||||
|
||||
# HACK - gobject-introspection can't scan a library in another directory
|
||||
# so we create a libclutter-cogl.la that's just identical to the one
|
||||
# in the subdir
|
||||
noinst_LTLIBRARIES = libclutter-cogl.la
|
||||
libclutter_cogl_la_LIBADD = $(CLUTTER_COGL)/libclutter-cogl.la
|
||||
libclutter_cogl_la_SOURCES = $(cogl_headers)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclutter-cogl.la
|
||||
$(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \
|
||||
--namespace Cogl --nsversion=@CLUTTER_API_VERSION@ \
|
||||
-I$(top_srcdir)/clutter/cogl \
|
||||
-I$(top_srcdir)/clutter/cogl/common \
|
||||
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
|
||||
-I$(top_builddir)/clutter \
|
||||
-DCLUTTER_COMPILATION \
|
||||
--include=GL-1.0 \
|
||||
--include=GObject-2.0 \
|
||||
--library=clutter-cogl \
|
||||
--libtool="$(top_builddir)/doltlibtool" \
|
||||
--pkg gobject-2.0 \
|
||||
--output $@ \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-@CLUTTER_COGL@.h \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(cogl_headers)
|
||||
|
||||
BUILT_GIRSOURCES = Cogl-@CLUTTER_API_VERSION@.gir
|
||||
|
||||
girdir = $(datadir)/gir-1.0
|
||||
gir_DATA = $(BUILT_GIRSOURCES)
|
||||
|
||||
CLEANFILES += $(BUILT_GIRSOURCES)
|
||||
endif
|
||||
|
78
cogl-bitmap.h
Normal file
78
cogl-bitmap.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __COGL_BITMAP_H__
|
||||
#define __COGL_BITMAP_H__
|
||||
|
||||
#include <cogl/cogl-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-bitmap
|
||||
* @short_description: Fuctions for loading images but not directly
|
||||
* into textures
|
||||
*
|
||||
* Cogl allows loading image data into memory as CoglBitmaps without
|
||||
* loading them immediately into GPU textures.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* cogl_bitmap_new_from_file:
|
||||
* @filename: the file to load.
|
||||
* @error: a #GError or %NULL.
|
||||
*
|
||||
* Load an image file from disk. This function can be safely called from
|
||||
* within a thread.
|
||||
*
|
||||
* Returns: A CoglBitmap to the new loaded image data, or %NULL if loading
|
||||
* the image failed.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglHandle cogl_bitmap_new_from_file (const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_get_size_from_file:
|
||||
* @filename: the file to check
|
||||
* @width: return location for the bitmap width
|
||||
* @height: return location for the bitmap height
|
||||
*
|
||||
* Parses an image file enough to extract the width and height
|
||||
* of the bitmap.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
gboolean cogl_bitmap_get_size_from_file (const gchar *filename,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_BITMAP_H__ */
|
12
cogl-color.h
12
cogl-color.h
@ -1,7 +1,9 @@
|
||||
/* cogl-color.h: Color type for COGL
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
|
26
cogl-debug.h
26
cogl-debug.h
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COGL_DEBUG_H__
|
||||
#define __COGL_DEBUG_H__
|
||||
|
||||
@ -13,7 +36,8 @@ typedef enum {
|
||||
COGL_DEBUG_OFFSCREEN = 1 << 4,
|
||||
COGL_DEBUG_DRAW = 1 << 5,
|
||||
COGL_DEBUG_PANGO = 1 << 6,
|
||||
COGL_DEBUG_RECTANGLES = 1 << 7
|
||||
COGL_DEBUG_RECTANGLES = 1 << 7,
|
||||
COGL_DEBUG_HANDLE = 1 << 8
|
||||
} CoglDebugFlags;
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
|
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef COGL_DEPRECATED_H
|
||||
|
||||
#define cogl_color cogl_color_REPLACED_BY_cogl_set_source_color
|
||||
|
14
cogl-fixed.h
14
cogl-fixed.h
@ -1,7 +1,9 @@
|
||||
/* cogl-fixed.h: Fixed point API
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
@ -725,7 +729,7 @@ CoglFixed cogl_angle_cos (CoglAngle angle);
|
||||
/*< private >*/
|
||||
|
||||
#if defined (G_CAN_INLINE)
|
||||
G_INLINE_FUNC CoglFixed
|
||||
G_INLINE_FUNC CoglFixed
|
||||
cogl_fixed_mul (CoglFixed a,
|
||||
CoglFixed b)
|
||||
{
|
||||
|
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
@ -86,7 +109,7 @@ void cogl_material_set_color (CoglHandle material, const CoglColor *color);
|
||||
*
|
||||
* This is the basic color of the material, used when no lighting is enabled.
|
||||
*
|
||||
* The default value is (1.0, 1.0, 1.0, 1.0)
|
||||
* The default value is (0xff, 0xff, 0xff, 0xff)
|
||||
*
|
||||
* Since 1.0
|
||||
*/
|
||||
@ -111,7 +134,7 @@ void cogl_material_set_color4ub (CoglHandle material,
|
||||
* Since 1.0
|
||||
*/
|
||||
void cogl_material_set_color4f (CoglHandle material,
|
||||
float red,
|
||||
float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha);
|
||||
|
@ -1,3 +1,29 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __COGL_MATRIX_H
|
||||
#define __COGL_MATRIX_H
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
/* cogl-offscreen.h: Offscreen objects
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
@ -31,43 +35,47 @@ G_BEGIN_DECLS
|
||||
/**
|
||||
* SECTION:cogl-offscreen
|
||||
* @short_description: Fuctions for creating and manipulating offscreen
|
||||
* frame buffer objects
|
||||
* frame buffer objects
|
||||
*
|
||||
* COGL allows creating and operating on FBOs (Framebuffer Objects).
|
||||
* Cogl allows creating and operating on offscreen render targets.
|
||||
*/
|
||||
|
||||
/* Offscreen api */
|
||||
|
||||
/**
|
||||
* cogl_offscreen_new_to_texture:
|
||||
* @texhandle:
|
||||
* @handle: A CoglHandle for a Cogl texture
|
||||
*
|
||||
* Returns:
|
||||
* This creates an offscreen buffer object using the given texture as the
|
||||
* primary color buffer. It doesn't just initialize the contents of the
|
||||
* offscreen buffer with the texture; they are tightly bound so that
|
||||
* drawing to the offscreen buffer effectivly updates the contents of the
|
||||
* given texture. You don't need to destroy the offscreen buffer before
|
||||
* you can use the texture again.
|
||||
*
|
||||
* Note: This does not work with sliced Cogl textures.
|
||||
*
|
||||
* Returns: a CoglHandle for the new offscreen buffer or COGL_INVALID_HANDLE
|
||||
* if it wasn't possible to create the buffer.
|
||||
*/
|
||||
CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle);
|
||||
|
||||
/**
|
||||
* cogl_offscreen_new_multisample:
|
||||
*
|
||||
*
|
||||
* Returns:
|
||||
*/
|
||||
CoglHandle cogl_offscreen_new_multisample (void);
|
||||
|
||||
/**
|
||||
* cogl_offscreen_ref:
|
||||
* @handle:
|
||||
* @handle: A CoglHandle for an offscreen buffer
|
||||
*
|
||||
* Returns:
|
||||
* Increments the reference count on the offscreen buffer.
|
||||
*
|
||||
* Returns: For convenience it returns the given CoglHandle
|
||||
*/
|
||||
CoglHandle cogl_offscreen_ref (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_is_offscreen:
|
||||
* @handle: A CoglHandle
|
||||
* @handle: A CoglHandle for an offscreen buffer
|
||||
*
|
||||
* Gets whether the given handle references an existing offscreen
|
||||
* buffer object.
|
||||
* Gets whether the given handle references an existing offscreen buffer
|
||||
* object.
|
||||
*
|
||||
* Returns: %TRUE if the handle references an offscreen buffer,
|
||||
* %FALSE otherwise
|
||||
@ -76,54 +84,13 @@ gboolean cogl_is_offscreen (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_offscreen_unref:
|
||||
* @handle:
|
||||
* @handle: A CoglHandle for an offscreen buffer
|
||||
*
|
||||
* Decreases the reference count for the offscreen buffer and frees it when
|
||||
* the count reaches 0.
|
||||
*/
|
||||
void cogl_offscreen_unref (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_offscreen_blit:
|
||||
* @src_buffer:
|
||||
* @dst_buffer:
|
||||
*
|
||||
*/
|
||||
void cogl_offscreen_blit (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer);
|
||||
|
||||
/**
|
||||
* cogl_offscreen_blit_region:
|
||||
* @src_buffer:
|
||||
* @dst_buffer:
|
||||
* @src_x:
|
||||
* @src_y:
|
||||
* @src_w:
|
||||
* @src_h:
|
||||
* @dst_x:
|
||||
* @dst_y:
|
||||
* @dst_w:
|
||||
* @dst_h:
|
||||
*
|
||||
*/
|
||||
void cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer,
|
||||
gint src_x,
|
||||
gint src_y,
|
||||
gint src_w,
|
||||
gint src_h,
|
||||
gint dst_x,
|
||||
gint dst_y,
|
||||
gint dst_w,
|
||||
gint dst_h);
|
||||
|
||||
/**
|
||||
* cogl_draw_buffer:
|
||||
* @target:
|
||||
* @offscreen:
|
||||
*
|
||||
*/
|
||||
void cogl_draw_buffer (CoglBufferTarget target,
|
||||
CoglHandle offscreen);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_OFFSCREEN_H__ */
|
||||
|
12
cogl-path.h
12
cogl-path.h
@ -1,7 +1,9 @@
|
||||
/* cogl-path.h: Path primitives
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
|
@ -1,7 +1,9 @@
|
||||
/* cogl-shader.h: Shaders and programmable pipeline
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
@ -24,7 +28,7 @@
|
||||
#ifndef __COGL_SHADER_H__
|
||||
#define __COGL_SHADER_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <cogl/cogl-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -38,6 +42,17 @@ G_BEGIN_DECLS
|
||||
* The only supported format is GLSL shaders.
|
||||
*/
|
||||
|
||||
/**
|
||||
* CoglShaderType:
|
||||
* @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices
|
||||
* @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments
|
||||
*/
|
||||
typedef enum _CoglShaderType
|
||||
{
|
||||
COGL_SHADER_TYPE_VERTEX,
|
||||
COGL_SHADER_TYPE_FRAGMENT
|
||||
} CoglShaderType;
|
||||
|
||||
/**
|
||||
* cogl_create_shader:
|
||||
* @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER.
|
||||
@ -47,7 +62,7 @@ G_BEGIN_DECLS
|
||||
*
|
||||
* Returns: a new shader handle.
|
||||
*/
|
||||
CoglHandle cogl_create_shader (COGLenum shader_type);
|
||||
CoglHandle cogl_create_shader (CoglShaderType shader_type);
|
||||
|
||||
/**
|
||||
* cogl_shader_ref:
|
||||
@ -87,8 +102,8 @@ gboolean cogl_is_shader (CoglHandle handle);
|
||||
* Replaces the current GLSL source associated with a shader with a new
|
||||
* one.
|
||||
*/
|
||||
void cogl_shader_source (CoglHandle shader,
|
||||
const gchar *source);
|
||||
void cogl_shader_source (CoglHandle shader,
|
||||
const char *source);
|
||||
/**
|
||||
* cogl_shader_compile:
|
||||
* @handle: #CoglHandle for a shader.
|
||||
@ -109,22 +124,26 @@ void cogl_shader_compile (CoglHandle handle);
|
||||
* messages that caused a shader to not compile correctly, mainly useful for
|
||||
* debugging purposes.
|
||||
*/
|
||||
void cogl_shader_get_info_log (CoglHandle handle,
|
||||
guint size,
|
||||
gchar *buffer);
|
||||
void cogl_shader_get_info_log (CoglHandle handle,
|
||||
size_t size,
|
||||
char *buffer);
|
||||
|
||||
/**
|
||||
* cogl_shader_get_parameteriv:
|
||||
* cogl_shader_get_type:
|
||||
* @handle: #CoglHandle for a shader.
|
||||
* @pname: the named COGL parameter to retrieve.
|
||||
* @dest: storage location for COGLint return value.
|
||||
*
|
||||
* Retrieve a named parameter from a shader can be used to query to compile
|
||||
* satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname.
|
||||
* Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
|
||||
* or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
|
||||
*/
|
||||
void cogl_shader_get_parameteriv (CoglHandle handle,
|
||||
COGLenum pname,
|
||||
COGLint *dest);
|
||||
CoglShaderType cogl_shader_get_type (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_shader_is_compiled:
|
||||
* @handle: #CoglHandle for a shader.
|
||||
*
|
||||
* Returns: TRUE if the shader object has sucessfully be compiled else FALSE
|
||||
*/
|
||||
gboolean cogl_shader_is_compiled (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_create_program:
|
||||
@ -209,9 +228,9 @@ void cogl_program_use (CoglHandle handle);
|
||||
* This uniform can be set using cogl_program_uniform_1f() when the
|
||||
* program is in use.
|
||||
*/
|
||||
COGLint cogl_program_get_uniform_location
|
||||
(CoglHandle handle,
|
||||
const gchar *uniform_name);
|
||||
int cogl_program_get_uniform_location
|
||||
(CoglHandle handle,
|
||||
const char *uniform_name);
|
||||
|
||||
/**
|
||||
* cogl_program_uniform_1f:
|
||||
@ -221,8 +240,8 @@ COGLint cogl_program_get_uniform_location
|
||||
* Changes the value of a floating point uniform in the currently
|
||||
* used (see cogl_program_use()) shader program.
|
||||
*/
|
||||
void cogl_program_uniform_1f (COGLint uniform_no,
|
||||
gfloat value);
|
||||
void cogl_program_uniform_1f (int uniform_no,
|
||||
float value);
|
||||
|
||||
/**
|
||||
* cogl_program_uniform_1i:
|
||||
@ -232,8 +251,8 @@ void cogl_program_uniform_1f (COGLint uniform_no,
|
||||
* Changes the value of an integer uniform in the currently
|
||||
* used (see cogl_program_use()) shader program.
|
||||
*/
|
||||
void cogl_program_uniform_1i (COGLint uniform_no,
|
||||
gint value);
|
||||
void cogl_program_uniform_1i (int uniform_no,
|
||||
int value);
|
||||
|
||||
/**
|
||||
* cogl_program_uniform_float:
|
||||
@ -245,9 +264,9 @@ void cogl_program_uniform_1i (COGLint uniform_no,
|
||||
* Changes the value of a float vector uniform, or uniform array in the
|
||||
* currently used (see #cogl_program_use) shader program.
|
||||
*/
|
||||
void cogl_program_uniform_float (COGLint uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
void cogl_program_uniform_float (int uniform_no,
|
||||
int size,
|
||||
int count,
|
||||
const GLfloat *value);
|
||||
|
||||
/**
|
||||
@ -260,10 +279,10 @@ void cogl_program_uniform_float (COGLint uniform_no,
|
||||
* Changes the value of a int vector uniform, or uniform array in the
|
||||
* currently used (see cogl_program_use()) shader program.
|
||||
*/
|
||||
void cogl_program_uniform_int (COGLint uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const COGLint *value);
|
||||
void cogl_program_uniform_int (int uniform_no,
|
||||
int size,
|
||||
int count,
|
||||
const int *value);
|
||||
|
||||
/**
|
||||
* cogl_program_uniform_matrix:
|
||||
@ -277,11 +296,11 @@ void cogl_program_uniform_int (COGLint uniform_no,
|
||||
* currently used (see cogl_program_use()) shader program. The @size
|
||||
* parameter is used to determine the square size of the matrix.
|
||||
*/
|
||||
void cogl_program_uniform_matrix (COGLint uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
gboolean transpose,
|
||||
const GLfloat *value);
|
||||
void cogl_program_uniform_matrix (int uniform_no,
|
||||
int size,
|
||||
int count,
|
||||
gboolean transpose,
|
||||
const float *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
115
cogl-texture.h
115
cogl-texture.h
@ -1,7 +1,9 @@
|
||||
/* cogl-texture.h: Texture objects
|
||||
* This file is part of Clutter
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -14,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
@ -24,10 +28,10 @@
|
||||
#ifndef __COGL_TEXTURE_H__
|
||||
#define __COGL_TEXTURE_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <cogl/cogl-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* SECTION:cogl-texture
|
||||
* @short_description: Fuctions for creating and manipulating textures
|
||||
@ -142,21 +146,21 @@ CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle,
|
||||
|
||||
/**
|
||||
* cogl_texture_new_from_bitmap:
|
||||
* @bitmap: a #CoglBitmap
|
||||
* @bmp_handle: A CoglBitmap handle
|
||||
* @max_waste: maximum extra horizontal and|or vertical margin pixels
|
||||
* to make the texture fit GPU limitations
|
||||
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
|
||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||
* texture
|
||||
*
|
||||
* Creates a COGL texture from a #CoglBitmap.
|
||||
* Creates a COGL texture from a CoglBitmap.
|
||||
*
|
||||
* Return value: a #CoglHandle to the newly created texture or
|
||||
* %COGL_INVALID_HANDLE on failure
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||
CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
|
||||
gint max_waste,
|
||||
CoglTextureFlags flags,
|
||||
CoglPixelFormat internal_format);
|
||||
@ -224,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle);
|
||||
*/
|
||||
gint cogl_texture_get_max_waste (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* CoglTextureFilter:
|
||||
* @COGL_TEXTURE_FILTER_NEAREST: Measuring in manhatten distance from the,
|
||||
* current pixel center, use the nearest texture
|
||||
* texel.
|
||||
* @COGL_TEXTURE_FILTER_LINEAR: Use the weighted average of the 4 texels
|
||||
* nearest the current pixel center.
|
||||
* @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST: Select the mimap level whose
|
||||
* texel size most closely matches
|
||||
* the current pixel, and use the
|
||||
* COGL_TEXTURE_FILTER_NEAREST
|
||||
* criterion.
|
||||
* @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST: Select the mimap level whose
|
||||
* texel size most closely matches
|
||||
* the current pixel, and use the
|
||||
* COGL_TEXTURE_FILTER_LINEAR
|
||||
* criterion.
|
||||
* @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR: Select the two mimap levels
|
||||
* whose texel size most closely
|
||||
* matches the current pixel, use
|
||||
* the COGL_TEXTURE_FILTER_NEAREST
|
||||
* criterion on each one and take
|
||||
* their weighted average.
|
||||
* @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR: Select the two mimap levels
|
||||
* whose texel size most closely
|
||||
* matches the current pixel, use
|
||||
* the COGL_TEXTURE_FILTER_LINEAR
|
||||
* criterion on each one and take
|
||||
* their weighted average.
|
||||
*
|
||||
* Texture filtering is used whenever the current pixel maps either to more
|
||||
* than one texture element (texel) or less than one. These filter enums
|
||||
* correspond to different strategies used to come up with a pixel color, by
|
||||
* possibly referring to multiple neighbouring texels and taking a weighted
|
||||
* average or simply using the nearest texel.
|
||||
*/
|
||||
typedef enum _CoglTextureFilter
|
||||
{
|
||||
COGL_TEXTURE_FILTER_NEAREST = GL_NEAREST,
|
||||
COGL_TEXTURE_FILTER_LINEAR = GL_LINEAR,
|
||||
COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,
|
||||
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
|
||||
COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
|
||||
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR
|
||||
} CoglTextureFilter;
|
||||
|
||||
/**
|
||||
* cogl_texture_get_min_filter:
|
||||
* @handle: a #CoglHandle for a texture.
|
||||
@ -232,7 +282,7 @@ gint cogl_texture_get_max_waste (CoglHandle handle);
|
||||
*
|
||||
* Returns: the current downscaling filter for a cogl texture.
|
||||
*/
|
||||
COGLenum cogl_texture_get_min_filter (CoglHandle handle);
|
||||
CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_texture_get_mag_filter:
|
||||
@ -242,7 +292,7 @@ COGLenum cogl_texture_get_min_filter (CoglHandle handle);
|
||||
*
|
||||
* Returns: the current downscaling filter for a cogl texture.
|
||||
*/
|
||||
COGLenum cogl_texture_get_mag_filter (CoglHandle handle);
|
||||
CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_texture_is_sliced:
|
||||
@ -303,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle,
|
||||
* drawn at other scales than 100%.
|
||||
*/
|
||||
void cogl_texture_set_filters (CoglHandle handle,
|
||||
COGLenum min_filter,
|
||||
COGLenum mag_filter);
|
||||
CoglTextureFilter min_filter,
|
||||
CoglTextureFilter mag_filter);
|
||||
|
||||
|
||||
/**
|
||||
@ -359,45 +409,6 @@ CoglHandle cogl_texture_ref (CoglHandle handle);
|
||||
*/
|
||||
void cogl_texture_unref (CoglHandle handle);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_new_from_file:
|
||||
* @filename: the file to load.
|
||||
* @error: a #GError or %NULL.
|
||||
*
|
||||
* Load an image file from disk. This function can be safely called from
|
||||
* within a thread.
|
||||
*
|
||||
* Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading
|
||||
* the image failed.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_get_size_from_file:
|
||||
* @filename: the file to check
|
||||
* @width: return location for the bitmap width
|
||||
* @height: return location for the bitmap height
|
||||
*
|
||||
* Parses an image file enough to extract the width and height
|
||||
* of the bitmap.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
gboolean cogl_bitmap_get_size_from_file (const gchar *filename,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
/**
|
||||
* cogl_bitmap_free:
|
||||
* @bmp: a #CoglBitmap.
|
||||
*
|
||||
* Frees a #CoglBitmap.
|
||||
*/
|
||||
void cogl_bitmap_free (CoglBitmap *bmp);
|
||||
|
||||
/**
|
||||
* cogl_rectangle_with_texture_coords:
|
||||
* @x1: x coordinate upper left on screen.
|
||||
|
32
cogl-types.h
32
cogl-types.h
@ -1,13 +1,14 @@
|
||||
/* cogl-types.h: Shared COGL types
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* This file is part of Clutter
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -15,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
@ -29,13 +32,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* CoglBitmap:
|
||||
*
|
||||
* Type used for storing image data.
|
||||
*/
|
||||
typedef struct _CoglBitmap CoglBitmap;
|
||||
|
||||
/**
|
||||
* CoglHandle:
|
||||
*
|
||||
@ -137,7 +133,7 @@ typedef enum
|
||||
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
|
||||
COGL_PIXEL_FORMAT_YUV = 7,
|
||||
COGL_PIXEL_FORMAT_G_8 = 8,
|
||||
|
||||
|
||||
COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24,
|
||||
|
||||
COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 |
|
||||
@ -178,7 +174,7 @@ typedef enum
|
||||
COGL_PREMULT_BIT |
|
||||
COGL_BGR_BIT |
|
||||
COGL_AFIRST_BIT),
|
||||
|
||||
|
||||
COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 |
|
||||
COGL_A_BIT |
|
||||
COGL_PREMULT_BIT),
|
||||
@ -186,8 +182,8 @@ typedef enum
|
||||
COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 |
|
||||
COGL_A_BIT |
|
||||
COGL_PREMULT_BIT),
|
||||
|
||||
|
||||
|
||||
|
||||
} CoglPixelFormat;
|
||||
|
||||
#define COGL_TYPE_PIXEL_FORMAT (cogl_pixel_format_get_type ())
|
||||
@ -232,7 +228,6 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
|
||||
/**
|
||||
* CoglBufferTarget:
|
||||
* @COGL_WINDOW_BUFFER: FIXME
|
||||
* @COGL_MASK_BUFFER: FIXME
|
||||
* @COGL_OFFSCREEN_BUFFER: FIXME
|
||||
*
|
||||
* Target flags for FBOs.
|
||||
@ -242,8 +237,7 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
|
||||
typedef enum
|
||||
{
|
||||
COGL_WINDOW_BUFFER = (1 << 1),
|
||||
COGL_MASK_BUFFER = (1 << 2),
|
||||
COGL_OFFSCREEN_BUFFER = (1 << 3)
|
||||
COGL_OFFSCREEN_BUFFER = (1 << 2)
|
||||
} CoglBufferTarget;
|
||||
|
||||
#define COGL_TYPE_BUFFER_TARGET (cogl_buffer_target_get_type ())
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* Cogl.
|
||||
* Cogl
|
||||
*
|
||||
* An OpenGL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Vertex Buffer API: Handle extensible arrays of vertex attributes
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
*
|
||||
* Authored by: Robert Bragg <robert@linux.intel.com>
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,7 +16,12 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
|
81
cogl.h.in
81
cogl.h.in
@ -1,13 +1,12 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
@ -41,6 +40,7 @@
|
||||
#include <cogl/cogl-material.h>
|
||||
#include <cogl/cogl-path.h>
|
||||
#include <cogl/cogl-shader.h>
|
||||
#include <cogl/cogl-bitmap.h>
|
||||
#include <cogl/cogl-texture.h>
|
||||
#include <cogl/cogl-types.h>
|
||||
#include <cogl/cogl-debug.h>
|
||||
@ -363,14 +363,29 @@ void cogl_set_fog (const CoglColor *fog_color,
|
||||
*/
|
||||
void cogl_disable_fog (void);
|
||||
|
||||
/**
|
||||
* CoglBufferBit:
|
||||
* @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer
|
||||
* @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer
|
||||
* @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer
|
||||
*/
|
||||
typedef enum _CoglBufferBit
|
||||
{
|
||||
COGL_BUFFER_BIT_COLOR = 1L<<0,
|
||||
COGL_BUFFER_BIT_DEPTH = 1L<<1,
|
||||
COGL_BUFFER_BIT_STENCIL = 1L<<2
|
||||
} CoglBufferBit;
|
||||
|
||||
/**
|
||||
* cogl_clear:
|
||||
* @color: Background color to clear to
|
||||
* @buffers: A mask of @CoglBufferBit<!-- -->'s identifying which auxiliary
|
||||
* buffers to clear
|
||||
*
|
||||
* Clears the color buffer to @color. The depth buffer and stencil
|
||||
* buffers are also cleared.
|
||||
* Clears all the auxiliary buffers identified in the @buffers mask, and if
|
||||
* that includes the color buffer then the specified @color is used.
|
||||
*/
|
||||
void cogl_clear (const CoglColor *color);
|
||||
void cogl_clear (const CoglColor *color, gulong buffers);
|
||||
|
||||
/**
|
||||
* cogl_set_source:
|
||||
@ -475,6 +490,27 @@ void cogl_set_source_texture (CoglHandle texture_handle);
|
||||
* intersected with the previous region.
|
||||
*/
|
||||
|
||||
/**
|
||||
* cogl_clip_push_window_rect:
|
||||
* @x_offset: left edge of the clip rectangle in window coordinates
|
||||
* @y_offset: top edge of the clip rectangle in window coordinates
|
||||
* @width: width of the clip rectangle
|
||||
* @height: height of the clip rectangle
|
||||
*
|
||||
* Specifies a rectangular clipping area for all subsequent drawing
|
||||
* operations. Any drawing commands that extend outside the rectangle
|
||||
* will be clipped so that only the portion inside the rectangle will
|
||||
* be displayed. The rectangle dimensions are not transformed by the
|
||||
* current model-view matrix.
|
||||
*
|
||||
* The rectangle is intersected with the current clip region. To undo
|
||||
* the effect of this function, call cogl_clip_pop().
|
||||
*/
|
||||
void cogl_clip_push_window_rect (float x_offset,
|
||||
float y_offset,
|
||||
float width,
|
||||
float height);
|
||||
|
||||
/**
|
||||
* cogl_clip_push:
|
||||
* @x_offset: left edge of the clip rectangle
|
||||
@ -563,6 +599,35 @@ void cogl_clip_stack_save (void);
|
||||
*/
|
||||
void cogl_clip_stack_restore (void);
|
||||
|
||||
/**
|
||||
* cogl_set_draw_buffer:
|
||||
* @target: A #CoglBufferTarget that specifies what kind of draw buffer you
|
||||
* are setting as the render target.
|
||||
* @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER
|
||||
* then this is a CoglHandle for the offscreen buffer.
|
||||
*
|
||||
* This redirects all subsequent drawing to the specified draw buffer. This
|
||||
* can either be an offscreen buffer created with
|
||||
* cogl_offscreen_new_to_texture () or you can revert to your original
|
||||
* on screen window buffer.
|
||||
*/
|
||||
void cogl_set_draw_buffer (CoglBufferTarget target,
|
||||
CoglHandle offscreen);
|
||||
|
||||
/**
|
||||
* cogl_push_draw_buffer:
|
||||
*
|
||||
* Save cogl_set_draw_buffer() state.
|
||||
*/
|
||||
void cogl_push_draw_buffer (void);
|
||||
|
||||
/**
|
||||
* cogl_pop_draw_buffer:
|
||||
*
|
||||
* Restore cogl_set_draw_buffer() state.
|
||||
*/
|
||||
void cogl_pop_draw_buffer (void);
|
||||
|
||||
/**
|
||||
* cogl_flush_gl_state:
|
||||
* @flags: flags controlling what is flushed; currently unused, pass in 0
|
||||
|
@ -2,27 +2,25 @@ INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/clutter \
|
||||
-I$(top_srcdir)/clutter/cogl \
|
||||
-I$(top_srcdir)/clutter/cogl/common \
|
||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||
-I$(top_builddir)/clutter \
|
||||
-I$(top_builddir)/clutter/cogl \
|
||||
-DG_LOG_DOMAIN=\"Cogl-Common\" \
|
||||
-DCLUTTER_COMPILATION \
|
||||
$(CLUTTER_CFLAGS) \
|
||||
$(CLUTTER_DEBUG_CFLAGS) \
|
||||
$(MAINTAINER_CFLAGS) \
|
||||
$(GCC_FLAGS)
|
||||
|
||||
LDADD = $(CLUTTER_LIBS)
|
||||
-DCLUTTER_COMPILATION
|
||||
|
||||
noinst_LTLIBRARIES = libclutter-cogl-common.la
|
||||
EXTRA_DIST = stb_image.c
|
||||
|
||||
libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||
libclutter_cogl_common_la_LIBADD = -lm $(CLUTTER_LIBS)
|
||||
libclutter_cogl_common_la_SOURCES = \
|
||||
cogl-handle.h \
|
||||
cogl-internal.h \
|
||||
cogl.c \
|
||||
cogl-util.h \
|
||||
cogl-util.c \
|
||||
cogl-bitmap.h \
|
||||
cogl-bitmap-private.h \
|
||||
cogl-bitmap.c \
|
||||
cogl-bitmap-fallback.c \
|
||||
cogl-current-matrix.c \
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,7 +27,7 @@
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -164,7 +162,7 @@ inline static void
|
||||
_cogl_unpremult_alpha_last (const guchar *src, guchar *dst)
|
||||
{
|
||||
guchar alpha = src[3];
|
||||
|
||||
|
||||
dst[0] = ((((gulong) src[0] >> 16) & 0xff) * 255 ) / alpha;
|
||||
dst[1] = ((((gulong) src[1] >> 8) & 0xff) * 255 ) / alpha;
|
||||
dst[2] = ((((gulong) src[2] >> 0) & 0xff) * 255 ) / alpha;
|
||||
@ -175,7 +173,7 @@ inline static void
|
||||
_cogl_unpremult_alpha_first (const guchar *src, guchar *dst)
|
||||
{
|
||||
guchar alpha = src[0];
|
||||
|
||||
|
||||
dst[0] = alpha;
|
||||
dst[1] = ((((gulong) src[1] >> 16) & 0xff) * 255 ) / alpha;
|
||||
dst[2] = ((((gulong) src[2] >> 8) & 0xff) * 255 ) / alpha;
|
||||
@ -187,23 +185,23 @@ _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
|
||||
{
|
||||
if (src == dst)
|
||||
return FALSE;
|
||||
|
||||
|
||||
switch (src & COGL_UNORDERED_MASK)
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_G_8:
|
||||
case COGL_PIXEL_FORMAT_24:
|
||||
case COGL_PIXEL_FORMAT_32:
|
||||
|
||||
|
||||
if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 &&
|
||||
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 &&
|
||||
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8)
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -224,11 +222,11 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||
gint dst_bpp;
|
||||
gint x,y;
|
||||
guchar temp_rgba[4] = {0,0,0,0};
|
||||
|
||||
|
||||
/* Make sure conversion supported */
|
||||
if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format))
|
||||
return FALSE;
|
||||
|
||||
|
||||
src_bpp = _cogl_get_format_bpp (bmp->format);
|
||||
dst_bpp = _cogl_get_format_bpp (dst_format);
|
||||
|
||||
@ -237,18 +235,18 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
|
||||
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
|
||||
(dst_format & COGL_UNPREMULT_MASK));
|
||||
|
||||
|
||||
/* Allocate a new buffer to hold converted data */
|
||||
dst_bmp->data = g_malloc (sizeof(guchar)
|
||||
* dst_bmp->height
|
||||
* dst_bmp->rowstride);
|
||||
|
||||
|
||||
/* FIXME: Optimize */
|
||||
for (y = 0; y < bmp->height; y++)
|
||||
{
|
||||
src = (guchar*)bmp->data + y * bmp->rowstride;
|
||||
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
|
||||
|
||||
|
||||
for (x = 0; x < bmp->width; x++)
|
||||
{
|
||||
/* FIXME: Would be nice to at least remove this inner
|
||||
@ -273,7 +271,7 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch (dst_format & COGL_UNPREMULT_MASK)
|
||||
{
|
||||
case COGL_PIXEL_FORMAT_G_8:
|
||||
@ -293,12 +291,12 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
src += src_bpp;
|
||||
dst += dst_bpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -310,28 +308,28 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
|
||||
guchar *dst;
|
||||
gint bpp;
|
||||
gint x,y;
|
||||
|
||||
|
||||
/* Make sure format supported for un-premultiplication */
|
||||
if (!_cogl_bitmap_fallback_can_unpremult (bmp->format))
|
||||
return FALSE;
|
||||
|
||||
|
||||
bpp = _cogl_get_format_bpp (bmp->format);
|
||||
|
||||
|
||||
/* Initialize destination bitmap */
|
||||
*dst_bmp = *bmp;
|
||||
dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK);
|
||||
|
||||
|
||||
/* Allocate a new buffer to hold converted data */
|
||||
dst_bmp->data = g_malloc (sizeof(guchar)
|
||||
* dst_bmp->height
|
||||
* dst_bmp->rowstride);
|
||||
|
||||
|
||||
/* FIXME: Optimize */
|
||||
for (y = 0; y < bmp->height; y++)
|
||||
{
|
||||
src = (guchar*)bmp->data + y * bmp->rowstride;
|
||||
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
|
||||
|
||||
|
||||
for (x = 0; x < bmp->width; x++)
|
||||
{
|
||||
/* FIXME: Would be nice to at least remove this inner
|
||||
@ -351,12 +349,12 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
|
||||
else
|
||||
_cogl_unpremult_alpha_last (src, dst);
|
||||
}
|
||||
|
||||
|
||||
src += bpp;
|
||||
dst += bpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,7 +27,7 @@
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -222,7 +220,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
guchar *out_data;
|
||||
guchar *out;
|
||||
gint r;
|
||||
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
if (bmp == NULL)
|
||||
@ -232,7 +230,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename, error);
|
||||
if (pixbuf == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
/* Get pixbuf properties */
|
||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||
color_space = gdk_pixbuf_get_colorspace (pixbuf);
|
||||
@ -241,10 +239,10 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
||||
bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
|
||||
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
|
||||
|
||||
|
||||
/* The docs say this is the right way */
|
||||
last_row_size = width * ((n_channels * bits_per_sample + 7) / 8);
|
||||
|
||||
|
||||
/* According to current docs this should be true and so
|
||||
* the translation to cogl pixel format below valid */
|
||||
g_assert (bits_per_sample == 8);
|
||||
@ -253,7 +251,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
g_assert (n_channels == 4);
|
||||
else
|
||||
g_assert (n_channels == 3);
|
||||
|
||||
|
||||
/* Translate to cogl pixel format */
|
||||
switch (color_space)
|
||||
{
|
||||
@ -263,19 +261,19 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888 :
|
||||
COGL_PIXEL_FORMAT_RGB_888;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
/* Ouch, spec changed! */
|
||||
g_object_unref (pixbuf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: Any way to destroy pixbuf but retain pixel data? */
|
||||
|
||||
|
||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
out_data = (guchar*) g_malloc (height * rowstride);
|
||||
out = out_data;
|
||||
|
||||
|
||||
/* Copy up to last row */
|
||||
for (r = 0; r < height-1; ++r)
|
||||
{
|
||||
@ -283,13 +281,13 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
pixels += rowstride;
|
||||
out += rowstride;
|
||||
}
|
||||
|
||||
|
||||
/* Copy last row */
|
||||
memcpy (out, pixels, last_row_size);
|
||||
|
||||
|
||||
/* Destroy GdkPixbuf object */
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
|
||||
/* Store bitmap info */
|
||||
bmp->data = out_data; /* The stored data the same alignment constraints as a
|
||||
* gdkpixbuf but stores a full rowstride in the last
|
||||
@ -299,7 +297,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
bmp->rowstride = rowstride;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -335,14 +333,14 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
||||
|
||||
if (bmp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
/* Load from file using stb */
|
||||
pixels = stbi_load (filename,
|
||||
&width, &height, &stb_pixel_format,
|
||||
STBI_rgb_alpha);
|
||||
if (pixels == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
/* Store bitmap info */
|
||||
bmp->data = g_memdup (pixels, height * width * 4);
|
||||
bmp->format = COGL_PIXEL_FORMAT_RGBA_8888;
|
||||
|
@ -28,14 +28,17 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct _CoglBitmap
|
||||
#include "cogl-handle.h"
|
||||
|
||||
typedef struct _CoglBitmap
|
||||
{
|
||||
CoglHandleObject _parent;
|
||||
guchar *data;
|
||||
CoglPixelFormat format;
|
||||
gint width;
|
||||
gint height;
|
||||
gint rowstride;
|
||||
};
|
||||
} CoglBitmap;
|
||||
|
||||
gboolean
|
||||
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst);
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -29,10 +27,21 @@
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static void _cogl_bitmap_free (CoglBitmap *bmp);
|
||||
|
||||
COGL_HANDLE_DEFINE (Bitmap, bitmap);
|
||||
|
||||
static void
|
||||
_cogl_bitmap_free (CoglBitmap *bmp)
|
||||
{
|
||||
g_free (bmp->data);
|
||||
g_free (bmp);
|
||||
}
|
||||
|
||||
gint
|
||||
_cogl_get_format_bpp (CoglPixelFormat format)
|
||||
{
|
||||
@ -47,7 +56,7 @@ _cogl_get_format_bpp (CoglPixelFormat format)
|
||||
2, /* YUV */
|
||||
1 /* G_8 */
|
||||
};
|
||||
|
||||
|
||||
return bpp_lut [format & COGL_UNORDERED_MASK];
|
||||
}
|
||||
|
||||
@ -59,7 +68,7 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||
CoglBitmap tmp_bmp = *bmp;
|
||||
CoglBitmap new_bmp = *bmp;
|
||||
gboolean new_bmp_owner = FALSE;
|
||||
|
||||
|
||||
/* Is base format different (not considering premult status)? */
|
||||
if ((bmp->format & COGL_UNPREMULT_MASK) !=
|
||||
(dst_format & COGL_UNPREMULT_MASK))
|
||||
@ -71,12 +80,12 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||
if (!_cogl_bitmap_fallback_convert (&new_bmp, &tmp_bmp, dst_format))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Update bitmap with new data */
|
||||
new_bmp = tmp_bmp;
|
||||
new_bmp_owner = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Do we need to unpremultiply */
|
||||
if ((bmp->format & COGL_PREMULT_BIT) == 0 &&
|
||||
(dst_format & COGL_PREMULT_BIT) > 0)
|
||||
@ -89,19 +98,19 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||
{
|
||||
if (new_bmp_owner)
|
||||
g_free (new_bmp.data);
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Update bitmap with new data */
|
||||
if (new_bmp_owner)
|
||||
g_free (new_bmp.data);
|
||||
|
||||
|
||||
new_bmp = tmp_bmp;
|
||||
new_bmp_owner = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Do we need to premultiply */
|
||||
if ((bmp->format & COGL_PREMULT_BIT) > 0 &&
|
||||
(dst_format & COGL_PREMULT_BIT) == 0)
|
||||
@ -109,13 +118,13 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
|
||||
/* FIXME: implement premultiplication */
|
||||
if (new_bmp_owner)
|
||||
g_free (new_bmp.data);
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Output new bitmap info */
|
||||
*dst_bmp = new_bmp;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -133,14 +142,14 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
|
||||
guchar *dstdata;
|
||||
gint bpp;
|
||||
gint line;
|
||||
|
||||
|
||||
/* Intended only for fast copies when format is equal! */
|
||||
g_assert (src->format == dst->format);
|
||||
bpp = _cogl_get_format_bpp (src->format);
|
||||
|
||||
|
||||
srcdata = src->data + src_y * src->rowstride + src_x * bpp;
|
||||
dstdata = dst->data + dst_y * dst->rowstride + dst_x * bpp;
|
||||
|
||||
|
||||
for (line=0; line<height; ++line)
|
||||
{
|
||||
memcpy (dstdata, srcdata, width * bpp);
|
||||
@ -157,12 +166,13 @@ cogl_bitmap_get_size_from_file (const gchar *filename,
|
||||
return _cogl_bitmap_get_size_from_file (filename, width, height);
|
||||
}
|
||||
|
||||
CoglBitmap *
|
||||
CoglHandle
|
||||
cogl_bitmap_new_from_file (const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
CoglBitmap bmp;
|
||||
|
||||
CoglBitmap *ret;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
||||
|
||||
/* Try loading with imaging backend */
|
||||
@ -177,13 +187,8 @@ cogl_bitmap_new_from_file (const gchar *filename,
|
||||
*error = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (CoglBitmap *) g_memdup (&bmp, sizeof (CoglBitmap));
|
||||
|
||||
ret = g_memdup (&bmp, sizeof (CoglBitmap));
|
||||
return _cogl_bitmap_handle_new (ret);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_bitmap_free (CoglBitmap *bmp)
|
||||
{
|
||||
g_free (bmp->data);
|
||||
g_free (bmp);
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -28,10 +26,14 @@
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-clip-stack.h"
|
||||
#include "cogl-primitives.h"
|
||||
#include "cogl-context.h"
|
||||
#include "cogl-internal.h"
|
||||
|
||||
/* These are defined in the particular backend (float in GL vs fixed
|
||||
in GL ES) */
|
||||
@ -57,11 +59,13 @@ void _cogl_set_matrix (const CoglMatrix *matrix);
|
||||
typedef struct _CoglClipStack CoglClipStack;
|
||||
|
||||
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
|
||||
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
|
||||
typedef struct _CoglClipStackEntryPath CoglClipStackEntryPath;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COGL_CLIP_STACK_RECT,
|
||||
COGL_CLIP_STACK_WINDOW_RECT,
|
||||
COGL_CLIP_STACK_PATH
|
||||
} CoglClipStackEntryType;
|
||||
|
||||
@ -72,7 +76,7 @@ struct _CoglClipStack
|
||||
|
||||
struct _CoglClipStackEntryRect
|
||||
{
|
||||
CoglClipStackEntryType type;
|
||||
CoglClipStackEntryType type;
|
||||
|
||||
/* The rectangle for this clip */
|
||||
float x_offset;
|
||||
@ -84,20 +88,126 @@ struct _CoglClipStackEntryRect
|
||||
CoglMatrix matrix;
|
||||
};
|
||||
|
||||
struct _CoglClipStackEntryWindowRect
|
||||
{
|
||||
CoglClipStackEntryType type;
|
||||
|
||||
/* The window space rectangle for this clip */
|
||||
float x0;
|
||||
float y0;
|
||||
float x1;
|
||||
float y1;
|
||||
};
|
||||
|
||||
struct _CoglClipStackEntryPath
|
||||
{
|
||||
CoglClipStackEntryType type;
|
||||
CoglClipStackEntryType type;
|
||||
|
||||
/* The matrix that was current when the clip was set */
|
||||
CoglMatrix matrix;
|
||||
CoglMatrix matrix;
|
||||
|
||||
floatVec2 path_nodes_min;
|
||||
floatVec2 path_nodes_max;
|
||||
|
||||
guint path_size;
|
||||
CoglPathNode path[1];
|
||||
guint path_size;
|
||||
CoglPathNode path[1];
|
||||
};
|
||||
|
||||
void
|
||||
cogl_clip_push_window_rect (float x_offset,
|
||||
float y_offset,
|
||||
float width,
|
||||
float height)
|
||||
{
|
||||
CoglClipStackEntryWindowRect *entry;
|
||||
CoglClipStack *stack;
|
||||
float v[4];
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
stack = (CoglClipStack *) ctx->clip.stacks->data;
|
||||
|
||||
cogl_get_viewport (v);
|
||||
|
||||
entry = g_slice_new (CoglClipStackEntryWindowRect);
|
||||
|
||||
/* We convert from coords with (0,0) at top left to coords
|
||||
* with (0,0) at bottom left. */
|
||||
entry->type = COGL_CLIP_STACK_WINDOW_RECT;
|
||||
entry->x0 = x_offset;
|
||||
entry->y0 = v[3] - y_offset - height;
|
||||
entry->x1 = x_offset + width;
|
||||
entry->y1 = v[3] - y_offset;
|
||||
|
||||
/* Store it in the stack */
|
||||
stack->stack_top = g_list_prepend (stack->stack_top, entry);
|
||||
|
||||
ctx->clip.stack_dirty = TRUE;
|
||||
}
|
||||
|
||||
/* Scale from OpenGL <-1,1> coordinates system to window coordinates
|
||||
* <0,window-size> with (0,0) being top left. */
|
||||
#define VIEWPORT_SCALE_X(x, w, width, origin) \
|
||||
((((((x) / (w)) + 1.0) / 2) * (width)) + (origin))
|
||||
#define VIEWPORT_SCALE_Y(y, w, height, origin) \
|
||||
((height) - (((((y) / (w)) + 1.0) / 2) * (height)) + (origin))
|
||||
|
||||
static void
|
||||
transform_point (CoglMatrix *matrix_mv,
|
||||
CoglMatrix *matrix_p,
|
||||
float *viewport,
|
||||
float *x,
|
||||
float *y)
|
||||
{
|
||||
float z = 0;
|
||||
float w = 1;
|
||||
|
||||
/* Apply the model view matrix */
|
||||
cogl_matrix_transform_point (matrix_mv, x, y, &z, &w);
|
||||
|
||||
/* Apply the projection matrix */
|
||||
cogl_matrix_transform_point (matrix_p, x, y, &z, &w);
|
||||
/* Apply viewport transform */
|
||||
*x = VIEWPORT_SCALE_X (*x, w, viewport[2], viewport[0]);
|
||||
*y = VIEWPORT_SCALE_Y (*y, w, viewport[3], viewport[1]);
|
||||
}
|
||||
|
||||
#undef VIEWPORT_SCALE_X
|
||||
#undef VIEWPORT_SCALE_Y
|
||||
|
||||
/* Try to push a rectangle given in object coordinates as a rectangle in window
|
||||
* coordinates instead of object coordinates */
|
||||
gboolean
|
||||
try_pushing_rect_as_window_rect (float x_offset,
|
||||
float y_offset,
|
||||
float width,
|
||||
float height)
|
||||
{
|
||||
CoglMatrix matrix;
|
||||
CoglMatrix matrix_p;
|
||||
float v[4];
|
||||
float _x0 = x_offset;
|
||||
float _y0 = y_offset;
|
||||
float _x1 = x_offset + width;
|
||||
float _y1 = y_offset + height;
|
||||
|
||||
cogl_get_modelview_matrix (&matrix);
|
||||
|
||||
if (matrix.xy != 0 || matrix.xz != 0 ||
|
||||
matrix.yx != 0 || matrix.yz != 0 ||
|
||||
matrix.zx != 0 || matrix.zy != 0)
|
||||
return FALSE;
|
||||
|
||||
cogl_get_projection_matrix (&matrix_p);
|
||||
cogl_get_viewport (v);
|
||||
|
||||
transform_point (&matrix, &matrix_p, v, &_x0, &_y0);
|
||||
transform_point (&matrix, &matrix_p, v, &_x1, &_y1);
|
||||
|
||||
cogl_clip_push_window_rect (_x0, _y0, _x1 - _x0, _y1 - _y0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_clip_push (float x_offset,
|
||||
float y_offset,
|
||||
@ -109,6 +219,11 @@ cogl_clip_push (float x_offset,
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
/* Try and catch window space rectangles so we can redirect to
|
||||
* cogl_clip_push_window_rect which will use scissoring. */
|
||||
if (try_pushing_rect_as_window_rect (x_offset, y_offset, width, height))
|
||||
return;
|
||||
|
||||
stack = (CoglClipStack *) ctx->clip.stacks->data;
|
||||
|
||||
entry = g_slice_new (CoglClipStackEntryRect);
|
||||
@ -169,6 +284,7 @@ cogl_clip_pop (void)
|
||||
{
|
||||
gpointer entry;
|
||||
CoglClipStack *stack;
|
||||
CoglClipStackEntryType type;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -177,10 +293,13 @@ cogl_clip_pop (void)
|
||||
g_return_if_fail (stack->stack_top != NULL);
|
||||
|
||||
entry = stack->stack_top->data;
|
||||
type = *(CoglClipStackEntryType *) entry;
|
||||
|
||||
/* Remove the top entry from the stack */
|
||||
if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_RECT)
|
||||
if (type == COGL_CLIP_STACK_RECT)
|
||||
g_slice_free (CoglClipStackEntryRect, entry);
|
||||
else if (type == COGL_CLIP_STACK_WINDOW_RECT)
|
||||
g_slice_free (CoglClipStackEntryWindowRect, entry);
|
||||
else
|
||||
g_free (entry);
|
||||
|
||||
@ -198,6 +317,10 @@ _cogl_clip_stack_rebuild (void)
|
||||
gboolean using_stencil_buffer = FALSE;
|
||||
GList *node;
|
||||
CoglClipStack *stack;
|
||||
guint scissor_x0 = 0;
|
||||
guint scissor_y0 = 0;
|
||||
guint scissor_x1 = G_MAXUINT;
|
||||
guint scissor_y1 = G_MAXUINT;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -208,6 +331,7 @@ _cogl_clip_stack_rebuild (void)
|
||||
|
||||
_cogl_disable_clip_planes ();
|
||||
_cogl_disable_stencil_buffer ();
|
||||
GE (glDisable (GL_SCISSOR_TEST));
|
||||
|
||||
/* If the stack is empty then there's nothing else to do */
|
||||
if (stack->stack_top == NULL)
|
||||
@ -220,8 +344,9 @@ _cogl_clip_stack_rebuild (void)
|
||||
for (; node; node = node->prev)
|
||||
{
|
||||
gpointer entry = node->data;
|
||||
CoglClipStackEntryType type = *(CoglClipStackEntryType *) entry;
|
||||
|
||||
if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_PATH)
|
||||
if (type == COGL_CLIP_STACK_PATH)
|
||||
{
|
||||
CoglClipStackEntryPath *path = (CoglClipStackEntryPath *) entry;
|
||||
|
||||
@ -241,7 +366,7 @@ _cogl_clip_stack_rebuild (void)
|
||||
/* We can't use clip planes any more */
|
||||
has_clip_planes = FALSE;
|
||||
}
|
||||
else
|
||||
else if (type == COGL_CLIP_STACK_RECT)
|
||||
{
|
||||
CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry;
|
||||
|
||||
@ -272,6 +397,16 @@ _cogl_clip_stack_rebuild (void)
|
||||
|
||||
cogl_pop_matrix ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the intersection of all window space rectangles in the clip
|
||||
* stack */
|
||||
CoglClipStackEntryWindowRect *window_rect = entry;
|
||||
scissor_x0 = MAX (scissor_x0, window_rect->x0);
|
||||
scissor_y0 = MAX (scissor_y0, window_rect->y0);
|
||||
scissor_x1 = MIN (scissor_x1, window_rect->x1);
|
||||
scissor_y1 = MIN (scissor_y1, window_rect->y1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Enabling clip planes is delayed to now so that they won't affect
|
||||
@ -279,6 +414,18 @@ _cogl_clip_stack_rebuild (void)
|
||||
if (using_clip_planes)
|
||||
_cogl_enable_clip_planes ();
|
||||
|
||||
if (scissor_x0 >= scissor_x1 || scissor_y0 >= scissor_y1)
|
||||
scissor_x0 = scissor_y0 = scissor_x1 = scissor_y1 = 0;
|
||||
|
||||
if (!(scissor_x0 == 0 && scissor_y0 == 0 &&
|
||||
scissor_x1 == G_MAXUINT && scissor_y1 == G_MAXUINT))
|
||||
{
|
||||
GE (glEnable (GL_SCISSOR_TEST));
|
||||
GE (glScissor (scissor_x0, scissor_y0,
|
||||
scissor_x1 - scissor_x0,
|
||||
scissor_y1 - scissor_y0));
|
||||
}
|
||||
|
||||
ctx->clip.stencil_used = using_stencil_buffer;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Havoc Pennington <hp@pobox.com> for litl
|
||||
*
|
||||
* Copyright (C) 2009 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,6 +19,9 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Havoc Pennington <hp@pobox.com> for litl
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Havoc Pennington <hp@pobox.com> for litl
|
||||
*
|
||||
* Copyright (C) 2009 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,6 +19,9 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Havoc Pennington <hp@pobox.com> for litl
|
||||
*/
|
||||
|
||||
#ifndef __COGL_CURRENT_MATRIX_H
|
||||
|
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -15,7 +38,8 @@ static const GDebugKey cogl_debug_keys[] = {
|
||||
{ "offscreen", COGL_DEBUG_OFFSCREEN },
|
||||
{ "draw", COGL_DEBUG_DRAW },
|
||||
{ "pango", COGL_DEBUG_PANGO },
|
||||
{ "rectangles", COGL_DEBUG_RECTANGLES }
|
||||
{ "rectangles", COGL_DEBUG_RECTANGLES },
|
||||
{ "handle", COGL_DEBUG_HANDLE }
|
||||
};
|
||||
|
||||
static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys);
|
||||
|
@ -1,3 +1,26 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define G_IMPLEMENT_INLINES
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -48,65 +46,60 @@ typedef struct _CoglHandleObject
|
||||
/* Helper macro to encapsulate the common code for COGL reference
|
||||
counted handles */
|
||||
|
||||
#if COGL_DEBUG
|
||||
#ifdef COGL_HANDLE_DEBUG
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
|
||||
printf ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
|
||||
(obj), (obj)->ref_count)
|
||||
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
|
||||
COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
|
||||
(obj), (obj)->ref_count)
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \
|
||||
do { \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
printf ("COGL %s REF %p %i\n", \
|
||||
g_quark_to_string ((obj)->klass->type), \
|
||||
(obj), (obj)->ref_count); \
|
||||
} while (0)
|
||||
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \
|
||||
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
|
||||
COGL_NOTE (HANDLE, "COGL %s REF %p %i\n", \
|
||||
g_quark_to_string ((__obj)->klass->type), \
|
||||
(__obj), (__obj)->ref_count); } G_STMT_END
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \
|
||||
do { \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
printf ("COGL %s UNREF %p %i\n", \
|
||||
g_quark_to_string ((obj)->klass->type), \
|
||||
(obj), (obj)->ref_count - 1); \
|
||||
} while (0)
|
||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \
|
||||
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
|
||||
COGL_NOTE (HANDLE, "COGL %s UNREF %p %i\n", \
|
||||
g_quark_to_string ((__obj)->klass->type), \
|
||||
(__obj), (__obj)->ref_count - 1); } G_STMT_END
|
||||
|
||||
#define COGL_HANDLE_DEBUG_FREE(obj) \
|
||||
printf ("COGL %s FREE %p\n", \
|
||||
g_quark_to_string ((obj)->klass->type), (obj)) \
|
||||
#define COGL_HANDLE_DEBUG_FREE(obj) \
|
||||
COGL_NOTE (HANDLE, "COGL %s FREE %p\n", \
|
||||
g_quark_to_string ((obj)->klass->type), (obj))
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
#else /* !COGL_HANDLE_DEBUG */
|
||||
|
||||
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj)
|
||||
#define _COGL_HANDLE_DEBUG_REF(type_name, obj)
|
||||
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
|
||||
#define COGL_HANDLE_DEBUG_FREE(obj)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
#endif /* COGL_HANDLE_DEBUG */
|
||||
|
||||
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
|
||||
\
|
||||
static CoglHandleClass _cogl_##type_name##_class; \
|
||||
static CoglHandleClass _cogl_##type_name##_class; \
|
||||
\
|
||||
static GQuark \
|
||||
_cogl_##type_name##_get_type (void) \
|
||||
{ \
|
||||
static GQuark type = 0; \
|
||||
if (!type) \
|
||||
type = g_quark_from_static_string ("Cogl"#TypeName); \
|
||||
return type; \
|
||||
} \
|
||||
static GQuark \
|
||||
_cogl_##type_name##_get_type (void) \
|
||||
{ \
|
||||
static GQuark type = 0; \
|
||||
if (!type) \
|
||||
type = g_quark_from_static_string ("Cogl"#TypeName); \
|
||||
return type; \
|
||||
} \
|
||||
\
|
||||
static CoglHandle \
|
||||
_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \
|
||||
{ \
|
||||
CoglHandleObject *obj = &new_obj->_parent; \
|
||||
obj->ref_count = 1; \
|
||||
static CoglHandle \
|
||||
_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \
|
||||
{ \
|
||||
CoglHandleObject *obj = &new_obj->_parent; \
|
||||
obj->ref_count = 1; \
|
||||
\
|
||||
obj->klass = &_cogl_##type_name##_class; \
|
||||
if (!obj->klass->type) \
|
||||
{ \
|
||||
obj->klass->type = \
|
||||
_cogl_##type_name##_get_type (); \
|
||||
obj->klass = &_cogl_##type_name##_class; \
|
||||
if (!obj->klass->type) \
|
||||
{ \
|
||||
obj->klass->type = _cogl_##type_name##_get_type (); \
|
||||
obj->klass->virt_free = _cogl_##type_name##_free; \
|
||||
} \
|
||||
\
|
||||
@ -114,51 +107,50 @@ typedef struct _CoglHandleObject
|
||||
return (CoglHandle) new_obj; \
|
||||
} \
|
||||
\
|
||||
Cogl##TypeName * \
|
||||
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
|
||||
{ \
|
||||
return (Cogl##TypeName *) handle; \
|
||||
} \
|
||||
Cogl##TypeName * \
|
||||
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
|
||||
{ \
|
||||
return (Cogl##TypeName *) handle; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
cogl_is_##type_name (CoglHandle handle) \
|
||||
{ \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
gboolean \
|
||||
cogl_is_##type_name (CoglHandle handle) \
|
||||
{ \
|
||||
CoglHandleObject *obj = (CoglHandleObject *)handle; \
|
||||
\
|
||||
if (handle == COGL_INVALID_HANDLE) \
|
||||
return FALSE; \
|
||||
if (handle == COGL_INVALID_HANDLE) \
|
||||
return FALSE; \
|
||||
\
|
||||
return (obj->klass->type == \
|
||||
_cogl_##type_name##_get_type ()); \
|
||||
} \
|
||||
return (obj->klass->type == _cogl_##type_name##_get_type ()); \
|
||||
} \
|
||||
\
|
||||
CoglHandle G_GNUC_DEPRECATED \
|
||||
cogl_##type_name##_ref (CoglHandle handle) \
|
||||
{ \
|
||||
if (!cogl_is_##type_name (handle)) \
|
||||
return COGL_INVALID_HANDLE; \
|
||||
CoglHandle G_GNUC_DEPRECATED \
|
||||
cogl_##type_name##_ref (CoglHandle handle) \
|
||||
{ \
|
||||
if (!cogl_is_##type_name (handle)) \
|
||||
return COGL_INVALID_HANDLE; \
|
||||
\
|
||||
_COGL_HANDLE_DEBUG_REF (TypeName, handle); \
|
||||
_COGL_HANDLE_DEBUG_REF (TypeName, handle); \
|
||||
\
|
||||
cogl_handle_ref (handle); \
|
||||
cogl_handle_ref (handle); \
|
||||
\
|
||||
return handle; \
|
||||
} \
|
||||
return handle; \
|
||||
} \
|
||||
\
|
||||
void G_GNUC_DEPRECATED \
|
||||
cogl_##type_name##_unref (CoglHandle handle) \
|
||||
{ \
|
||||
if (!cogl_is_##type_name (handle)) \
|
||||
{ \
|
||||
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
|
||||
": Ignoring unref of Cogl handle " \
|
||||
"due to type missmatch"); \
|
||||
return; \
|
||||
} \
|
||||
void G_GNUC_DEPRECATED \
|
||||
cogl_##type_name##_unref (CoglHandle handle) \
|
||||
{ \
|
||||
if (!cogl_is_##type_name (handle)) \
|
||||
{ \
|
||||
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
|
||||
": Ignoring unref of Cogl handle " \
|
||||
"due to type mismatch"); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
_COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \
|
||||
_COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \
|
||||
\
|
||||
cogl_handle_unref (handle); \
|
||||
}
|
||||
cogl_handle_unref (handle); \
|
||||
}
|
||||
|
||||
#endif /* __COGL_HANDLE_H */
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007, 2008 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corp.
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -25,6 +24,8 @@
|
||||
#ifndef __COGL_INTERNAL_H
|
||||
#define __COGL_INTERNAL_H
|
||||
|
||||
#include "cogl-debug.h"
|
||||
|
||||
#ifdef HAVE_COGL_GLES2
|
||||
typedef enum {
|
||||
COGL_BOXED_NONE,
|
||||
@ -50,29 +51,25 @@ typedef struct _CoglBoxedValue
|
||||
} CoglBoxedValue;
|
||||
#endif
|
||||
|
||||
#define COGL_DEBUG 0
|
||||
#ifdef COGL_GL_DEBUG
|
||||
|
||||
#if COGL_DEBUG
|
||||
const gchar *cogl_gl_error_to_string (GLenum error_code);
|
||||
|
||||
#include <stdio.h>
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum __err; \
|
||||
(x); \
|
||||
while ((__err = glGetError ()) != GL_NO_ERROR) \
|
||||
{ \
|
||||
g_warning ("%s: GL error (%d): %s\n", \
|
||||
G_STRLOC, \
|
||||
cogl_gl_error_to_string (__err)); \
|
||||
} } G_STMT_END
|
||||
|
||||
const char *_cogl_error_string(GLenum errorCode);
|
||||
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum err; \
|
||||
(x); \
|
||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||
(char *)_cogl_error_string(err), \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
#else /* !COGL_GL_DEBUG */
|
||||
|
||||
#define GE(x) (x)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
#endif /* COGL_GL_DEBUG */
|
||||
|
||||
#define COGL_ENABLE_BLEND (1<<1)
|
||||
#define COGL_ENABLE_ALPHA_TEST (1<<2)
|
||||
@ -80,16 +77,10 @@ const char *_cogl_error_string(GLenum errorCode);
|
||||
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
|
||||
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
|
||||
|
||||
void
|
||||
_cogl_features_init (void);
|
||||
void _cogl_features_init (void);
|
||||
gint _cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
gint
|
||||
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
void
|
||||
cogl_enable (gulong flags);
|
||||
|
||||
gulong
|
||||
cogl_get_enable ();
|
||||
void cogl_enable (gulong flags);
|
||||
gulong cogl_get_enable (void);
|
||||
|
||||
#endif /* __COGL_INTERNAL_H */
|
||||
|
@ -1,3 +1,29 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __COGL_MATERIAL_PRIVATE_H
|
||||
#define __COGL_MATERIAL_PRIVATE_H
|
||||
|
||||
|
@ -1,3 +1,28 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -168,6 +193,18 @@ cogl_material_set_color4ub (CoglHandle handle,
|
||||
cogl_material_set_color (handle, &color);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_material_set_color4f (CoglHandle handle,
|
||||
float red,
|
||||
float green,
|
||||
float blue,
|
||||
float alpha)
|
||||
{
|
||||
CoglColor color;
|
||||
cogl_color_set_from_4f (&color, red, green, blue, alpha);
|
||||
cogl_material_set_color (handle, &color);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_material_get_ambient (CoglHandle handle,
|
||||
CoglColor *ambient)
|
||||
@ -619,7 +656,8 @@ cogl_material_set_layer_matrix (CoglHandle material_handle,
|
||||
static void
|
||||
_cogl_material_layer_free (CoglMaterialLayer *layer)
|
||||
{
|
||||
cogl_handle_unref (layer->texture);
|
||||
if (layer->texture != COGL_INVALID_HANDLE)
|
||||
cogl_handle_unref (layer->texture);
|
||||
g_free (layer);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Havoc Pennington <hp@pobox.com> for litl
|
||||
*
|
||||
* Copyright (C) 2009 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,6 +19,9 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Havoc Pennington <hp@pobox.com> for litl
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Havoc Pennington <hp@pobox.com> for litl
|
||||
*
|
||||
* Copyright (C) 2009 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,6 +19,9 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Havoc Pennington <hp@pobox.com> for litl
|
||||
*/
|
||||
|
||||
#ifndef __COGL_MATRIX_STACK_H
|
||||
|
@ -1,3 +1,29 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#include <cogl-matrix.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -374,9 +372,7 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf("=== Drawing Tex Quad (Sliced Mode) ===\n");
|
||||
#endif
|
||||
COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)");
|
||||
|
||||
/* We can't use hardware repeat so we need to set clamp to edge
|
||||
otherwise it might pull in edge pixels from the other side */
|
||||
@ -487,17 +483,21 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
|
||||
slice_tx2 /= iter_x.span->size;
|
||||
}
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
||||
printf("qx1: %f\n", (slice_qx1));
|
||||
printf("qy1: %f\n", (slice_qy1));
|
||||
printf("qx2: %f\n", (slice_qx2));
|
||||
printf("qy2: %f\n", (slice_qy2));
|
||||
printf("tx1: %f\n", (slice_tx1));
|
||||
printf("ty1: %f\n", (slice_ty1));
|
||||
printf("tx2: %f\n", (slice_tx2));
|
||||
printf("ty2: %f\n", (slice_ty2));
|
||||
#endif
|
||||
COGL_NOTE (DRAW,
|
||||
"~~~~~ slice (%d, %d)\n"
|
||||
"qx1: %f\t"
|
||||
"qy1: %f\n"
|
||||
"qx2: %f\t"
|
||||
"qy2: %f\n"
|
||||
"tx1: %f\t"
|
||||
"ty1: %f\n"
|
||||
"tx2: %f\t"
|
||||
"ty2: %f\n",
|
||||
iter_x.index, iter_y.index,
|
||||
slice_qx1, slice_qy1,
|
||||
slice_qx2, slice_qy2,
|
||||
slice_tx1, slice_ty1,
|
||||
slice_tx2, slice_ty2);
|
||||
|
||||
/* Pick and bind opengl texture object */
|
||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
|
||||
@ -1322,9 +1322,9 @@ cogl_path_fill_preserve (void)
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
cogl_clip_ensure ();
|
||||
|
||||
|
||||
if (ctx->path_nodes->len == 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
_cogl_path_fill_nodes ();
|
||||
}
|
||||
@ -1341,12 +1341,12 @@ void
|
||||
cogl_path_stroke_preserve (void)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
cogl_clip_ensure ();
|
||||
|
||||
if (ctx->path_nodes->len == 0)
|
||||
return;
|
||||
|
||||
|
||||
_cogl_path_stroke_nodes();
|
||||
}
|
||||
|
||||
@ -1355,14 +1355,14 @@ cogl_path_move_to (float x,
|
||||
float y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
/* FIXME: handle multiple contours maybe? */
|
||||
|
||||
|
||||
_cogl_path_add_node (TRUE, x, y);
|
||||
|
||||
|
||||
ctx->path_start.x = x;
|
||||
ctx->path_start.y = y;
|
||||
|
||||
|
||||
ctx->path_pen = ctx->path_start;
|
||||
}
|
||||
|
||||
@ -1371,7 +1371,7 @@ cogl_path_rel_move_to (float x,
|
||||
float y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
cogl_path_move_to (ctx->path_pen.x + x,
|
||||
ctx->path_pen.y + y);
|
||||
}
|
||||
@ -1381,9 +1381,9 @@ cogl_path_line_to (float x,
|
||||
float y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
_cogl_path_add_node (FALSE, x, y);
|
||||
|
||||
|
||||
ctx->path_pen.x = x;
|
||||
ctx->path_pen.y = y;
|
||||
}
|
||||
@ -1393,7 +1393,7 @@ cogl_path_rel_line_to (float x,
|
||||
float y)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
cogl_path_line_to (ctx->path_pen.x + x,
|
||||
ctx->path_pen.y + y);
|
||||
}
|
||||
@ -1402,7 +1402,7 @@ void
|
||||
cogl_path_close (void)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
_cogl_path_add_node (FALSE, ctx->path_start.x, ctx->path_start.y);
|
||||
ctx->path_pen = ctx->path_start;
|
||||
}
|
||||
@ -1430,9 +1430,9 @@ cogl_path_polyline (float *coords,
|
||||
gint num_points)
|
||||
{
|
||||
gint c = 0;
|
||||
|
||||
|
||||
cogl_path_move_to (coords[0], coords[1]);
|
||||
|
||||
|
||||
for (c = 1; c < num_points; ++c)
|
||||
cogl_path_line_to (coords[2*c], coords[2*c+1]);
|
||||
}
|
||||
@ -1473,17 +1473,17 @@ _cogl_path_arc (float center_x,
|
||||
float sina = 0x0;
|
||||
float px = 0x0;
|
||||
float py = 0x0;
|
||||
|
||||
|
||||
/* Fix invalid angles */
|
||||
|
||||
|
||||
if (angle_1 == angle_2 || angle_step == 0x0)
|
||||
return;
|
||||
|
||||
|
||||
if (angle_step < 0x0)
|
||||
angle_step = -angle_step;
|
||||
|
||||
|
||||
/* Walk the arc by given step */
|
||||
|
||||
|
||||
a = angle_1;
|
||||
while (a != angle_2)
|
||||
{
|
||||
@ -1492,12 +1492,12 @@ _cogl_path_arc (float center_x,
|
||||
|
||||
px = center_x + (cosa * radius_x);
|
||||
py = center_y + (sina * radius_y);
|
||||
|
||||
|
||||
if (a == angle_1 && move_first)
|
||||
cogl_path_move_to (px, py);
|
||||
else
|
||||
cogl_path_line_to (px, py);
|
||||
|
||||
|
||||
if (G_LIKELY (angle_2 > angle_1))
|
||||
{
|
||||
a += angle_step;
|
||||
@ -1513,7 +1513,7 @@ _cogl_path_arc (float center_x,
|
||||
}
|
||||
|
||||
/* Make sure the final point is drawn */
|
||||
|
||||
|
||||
cosa = cosf (angle_2 * (G_PI/180.0));
|
||||
sina = sinf (angle_2 * (G_PI/180.0));
|
||||
|
||||
@ -1530,7 +1530,7 @@ cogl_path_arc (float center_x,
|
||||
float radius_y,
|
||||
float angle_1,
|
||||
float angle_2)
|
||||
{
|
||||
{
|
||||
float angle_step = 10;
|
||||
/* it is documented that a move to is needed to create a freestanding
|
||||
* arc
|
||||
@ -1552,7 +1552,7 @@ cogl_path_arc_rel (float center_x,
|
||||
float angle_step)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
_cogl_path_arc (ctx->path_pen.x + center_x,
|
||||
ctx->path_pen.y + center_y,
|
||||
radius_x, radius_y,
|
||||
@ -1567,15 +1567,15 @@ cogl_path_ellipse (float center_x,
|
||||
float radius_y)
|
||||
{
|
||||
float angle_step = 10;
|
||||
|
||||
|
||||
/* FIXME: if shows to be slow might be optimized
|
||||
* by mirroring just a quarter of it */
|
||||
|
||||
|
||||
_cogl_path_arc (center_x, center_y,
|
||||
radius_x, radius_y,
|
||||
0, 360,
|
||||
angle_step, 1 /* move first */);
|
||||
|
||||
|
||||
cogl_path_close();
|
||||
}
|
||||
|
||||
@ -1589,7 +1589,7 @@ cogl_path_round_rectangle (float x_1,
|
||||
{
|
||||
float inner_width = x_2 - x_1 - radius * 2;
|
||||
float inner_height = y_2 - y_1 - radius * 2;
|
||||
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
cogl_path_move_to (x_1, y_1 + radius);
|
||||
@ -1598,7 +1598,7 @@ cogl_path_round_rectangle (float x_1,
|
||||
180,
|
||||
270,
|
||||
arc_step);
|
||||
|
||||
|
||||
cogl_path_line_to (ctx->path_pen.x + inner_width,
|
||||
ctx->path_pen.y);
|
||||
cogl_path_arc_rel (0, radius,
|
||||
@ -1606,7 +1606,7 @@ cogl_path_round_rectangle (float x_1,
|
||||
-90,
|
||||
0,
|
||||
arc_step);
|
||||
|
||||
|
||||
cogl_path_line_to (ctx->path_pen.x,
|
||||
ctx->path_pen.y + inner_height);
|
||||
|
||||
@ -1615,7 +1615,7 @@ cogl_path_round_rectangle (float x_1,
|
||||
0,
|
||||
90,
|
||||
arc_step);
|
||||
|
||||
|
||||
cogl_path_line_to (ctx->path_pen.x - inner_width,
|
||||
ctx->path_pen.y);
|
||||
cogl_path_arc_rel (0, -radius,
|
||||
@ -1623,7 +1623,7 @@ cogl_path_round_rectangle (float x_1,
|
||||
90,
|
||||
180,
|
||||
arc_step);
|
||||
|
||||
|
||||
cogl_path_close ();
|
||||
}
|
||||
|
||||
@ -1644,16 +1644,16 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
floatVec2 c4;
|
||||
floatVec2 c5;
|
||||
gint cindex;
|
||||
|
||||
|
||||
/* Put first curve on stack */
|
||||
cubics[0] = *cubic;
|
||||
cindex = 0;
|
||||
|
||||
|
||||
while (cindex >= 0)
|
||||
{
|
||||
c = &cubics[cindex];
|
||||
|
||||
|
||||
|
||||
|
||||
/* Calculate distance of control points from their
|
||||
* counterparts on the line between end points */
|
||||
dif1.x = (c->p2.x * 3) - (c->p1.x * 2) - c->p4.x;
|
||||
@ -1669,12 +1669,12 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
dif2.x = -dif2.x;
|
||||
if (dif2.y < 0)
|
||||
dif2.y = -dif2.y;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Pick the greatest of two distances */
|
||||
if (dif1.x < dif2.x) dif1.x = dif2.x;
|
||||
if (dif1.y < dif2.y) dif1.y = dif2.y;
|
||||
|
||||
|
||||
/* Cancel if the curve is flat enough */
|
||||
if (dif1.x + dif1.y <= 1.0 ||
|
||||
cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1)
|
||||
@ -1689,10 +1689,10 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Left recursion goes on top of stack! */
|
||||
cright = c; cleft = &cubics[++cindex];
|
||||
|
||||
|
||||
/* Subdivide into 2 sub-curves */
|
||||
c1.x = ((c->p1.x + c->p2.x) / 2);
|
||||
c1.y = ((c->p1.y + c->p2.y) / 2);
|
||||
@ -1700,21 +1700,21 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
|
||||
mm.y = ((c->p2.y + c->p3.y) / 2);
|
||||
c5.x = ((c->p3.x + c->p4.x) / 2);
|
||||
c5.y = ((c->p3.y + c->p4.y) / 2);
|
||||
|
||||
|
||||
c2.x = ((c1.x + mm.x) / 2);
|
||||
c2.y = ((c1.y + mm.y) / 2);
|
||||
c4.x = ((mm.x + c5.x) / 2);
|
||||
c4.y = ((mm.y + c5.y) / 2);
|
||||
|
||||
|
||||
c3.x = ((c2.x + c4.x) / 2);
|
||||
c3.y = ((c2.y + c4.y) / 2);
|
||||
|
||||
|
||||
/* Add left recursion to stack */
|
||||
cleft->p1 = c->p1;
|
||||
cleft->p2 = c1;
|
||||
cleft->p3 = c2;
|
||||
cleft->p4 = c3;
|
||||
|
||||
|
||||
/* Add right recursion to stack */
|
||||
cright->p1 = c3;
|
||||
cright->p2 = c4;
|
||||
@ -1761,7 +1761,7 @@ cogl_path_rel_curve_to (float x_1,
|
||||
float y_3)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
cogl_path_curve_to (ctx->path_pen.x + x_1,
|
||||
ctx->path_pen.y + y_1,
|
||||
ctx->path_pen.x + x_2,
|
||||
@ -1789,17 +1789,17 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
floatVec2 c2;
|
||||
floatVec2 c3;
|
||||
gint qindex;
|
||||
|
||||
|
||||
/* Put first curve on stack */
|
||||
quads[0] = *quad;
|
||||
qindex = 0;
|
||||
|
||||
|
||||
/* While stack is not empty */
|
||||
while (qindex >= 0)
|
||||
{
|
||||
|
||||
|
||||
q = &quads[qindex];
|
||||
|
||||
|
||||
/* Calculate distance of control point from its
|
||||
* counterpart on the line between end points */
|
||||
mid.x = ((q->p1.x + q->p3.x) / 2);
|
||||
@ -1808,7 +1808,7 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
dif.y = (q->p2.y - mid.y);
|
||||
if (dif.x < 0) dif.x = -dif.x;
|
||||
if (dif.y < 0) dif.y = -dif.y;
|
||||
|
||||
|
||||
/* Cancel if the curve is flat enough */
|
||||
if (dif.x + dif.y <= 1.0 ||
|
||||
qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1)
|
||||
@ -1818,10 +1818,10 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
_cogl_path_add_node (FALSE, q->p3.x, q->p3.y);
|
||||
--qindex; continue;
|
||||
}
|
||||
|
||||
|
||||
/* Left recursion goes on top of stack! */
|
||||
qright = q; qleft = &quads[++qindex];
|
||||
|
||||
|
||||
/* Subdivide into 2 sub-curves */
|
||||
c1.x = ((q->p1.x + q->p2.x) / 2);
|
||||
c1.y = ((q->p1.y + q->p2.y) / 2);
|
||||
@ -1829,12 +1829,12 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
|
||||
c3.y = ((q->p2.y + q->p3.y) / 2);
|
||||
c2.x = ((c1.x + c3.x) / 2);
|
||||
c2.y = ((c1.y + c3.y) / 2);
|
||||
|
||||
|
||||
/* Add left recursion onto stack */
|
||||
qleft->p1 = q->p1;
|
||||
qleft->p2 = c1;
|
||||
qleft->p3 = c2;
|
||||
|
||||
|
||||
/* Add right recursion onto stack */
|
||||
qright->p1 = c2;
|
||||
qright->p2 = c3;
|
||||
@ -1861,7 +1861,7 @@ cogl_path_curve2_to (float x_1,
|
||||
|
||||
/* Run subdivision */
|
||||
_cogl_path_bezier2_sub (&quad);
|
||||
|
||||
|
||||
/* Add last point */
|
||||
_cogl_path_add_node (FALSE, quad.p3.x, quad.p3.y);
|
||||
ctx->path_pen = quad.p3;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,18 +1,14 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By: Matthew Allum <mallum@openedhand.com>
|
||||
* Emmanuele Bassi <ebassi@linux.intel.com>
|
||||
*
|
||||
* Copyright (C) 2007, 2008 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corp.
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +16,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -181,7 +179,6 @@ cogl_buffer_target_get_type (void)
|
||||
{
|
||||
static const GFlagsValue values[] = {
|
||||
{ COGL_WINDOW_BUFFER, "COGL_WINDOW_BUFFER", "window-buffer" },
|
||||
{ COGL_MASK_BUFFER, "COGL_MASK_BUFFER", "mask-buffer" },
|
||||
{ COGL_OFFSCREEN_BUFFER, "COGL_OFFSCREEN_BUFFER", "offscreen-buffer" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,7 +24,7 @@
|
||||
#ifndef __COGL_UTIL_H
|
||||
#define __COGL_UTIL_H
|
||||
|
||||
int
|
||||
int
|
||||
cogl_util_next_p2 (int a);
|
||||
|
||||
#endif /* __COGL_UTIL_H */
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Cogl.
|
||||
* Cogl
|
||||
*
|
||||
* An OpenGL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008 Intel Corporation.
|
||||
*
|
||||
* Authored By: Robert Bragg <robert@linux.intel.com>
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -18,7 +16,12 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __COGL_VERTEX_BUFFER_H
|
||||
|
@ -1,13 +1,9 @@
|
||||
/*
|
||||
* Cogl.
|
||||
* Cogl
|
||||
*
|
||||
* An OpenGL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Vertex Buffer API: Handle extensible arrays of vertex attributes
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Intel Corporation.
|
||||
*
|
||||
* Authored by: Robert Bragg <robert@linux.intel.com>
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,7 +16,12 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
/* XXX: For an overview of the functionality implemented here, please
|
||||
@ -126,7 +127,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "cogl.h"
|
||||
#include "cogl-internal.h"
|
||||
@ -1775,4 +1776,3 @@ _cogl_vertex_buffer_free (CoglVertexBuffer *buffer)
|
||||
|
||||
g_slice_free (CoglVertexBuffer, buffer);
|
||||
}
|
||||
|
||||
|
124
common/cogl.c
124
common/cogl.c
@ -1,10 +1,9 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007, 2008 OpenedHand
|
||||
* Copyright (C) 2009 Intel Corp.
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -39,6 +38,7 @@
|
||||
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||
#endif
|
||||
|
||||
#include "cogl-debug.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-context.h"
|
||||
@ -47,67 +47,82 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
|
||||
#include "cogl-gles2-wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef COGL_GL_DEBUG
|
||||
/* GL error to string conversion */
|
||||
#if COGL_DEBUG
|
||||
struct token_string
|
||||
{
|
||||
GLuint Token;
|
||||
const char *String;
|
||||
};
|
||||
static const struct {
|
||||
GLuint error_code;
|
||||
const gchar *error_string;
|
||||
} gl_errors[] = {
|
||||
{ GL_NO_ERROR, "No error" },
|
||||
{ GL_INVALID_ENUM, "Invalid enumeration value" },
|
||||
{ GL_INVALID_VALUE, "Invalid value" },
|
||||
{ GL_INVALID_OPERATION, "Invalid operation" },
|
||||
{ GL_STACK_OVERFLOW, "Stack overflow" },
|
||||
{ GL_STACK_UNDERFLOW, "Stack underflow" },
|
||||
{ GL_OUT_OF_MEMORY, "Out of memory" },
|
||||
|
||||
static const struct token_string Errors[] = {
|
||||
{ GL_NO_ERROR, "no error" },
|
||||
{ GL_INVALID_ENUM, "invalid enumerant" },
|
||||
{ GL_INVALID_VALUE, "invalid value" },
|
||||
{ GL_INVALID_OPERATION, "invalid operation" },
|
||||
{ GL_STACK_OVERFLOW, "stack overflow" },
|
||||
{ GL_STACK_UNDERFLOW, "stack underflow" },
|
||||
{ GL_OUT_OF_MEMORY, "out of memory" },
|
||||
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
|
||||
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
|
||||
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "Invalid framebuffer operation" }
|
||||
#endif
|
||||
{ ~0, NULL }
|
||||
};
|
||||
|
||||
const char*
|
||||
_cogl_error_string(GLenum errorCode)
|
||||
static const guint n_gl_errors = G_N_ELEMENTS (gl_errors);
|
||||
|
||||
const gchar *
|
||||
cogl_gl_error_to_string (GLenum error_code)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; Errors[i].String; i++) {
|
||||
if (Errors[i].Token == errorCode)
|
||||
return Errors[i].String;
|
||||
}
|
||||
return "unknown";
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_gl_errors; i++)
|
||||
{
|
||||
if (gl_errors[i].error_code == error_code)
|
||||
return gl_errors[i].error_string;
|
||||
}
|
||||
|
||||
return "Unknown GL error";
|
||||
}
|
||||
#endif
|
||||
#endif /* COGL_GL_DEBUG */
|
||||
|
||||
void
|
||||
cogl_clear (const CoglColor *color)
|
||||
cogl_clear (const CoglColor *color, gulong buffers)
|
||||
{
|
||||
#if COGL_DEBUG
|
||||
fprintf(stderr, "\n ============== Paint Start ================ \n");
|
||||
#endif
|
||||
GLbitfield gl_buffers = 0;
|
||||
|
||||
GE( glClearColor (cogl_color_get_red_float (color),
|
||||
cogl_color_get_green_float (color),
|
||||
cogl_color_get_blue_float (color),
|
||||
0.0) );
|
||||
COGL_NOTE (DRAW, "Clear begin");
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
cogl_clip_ensure ();
|
||||
|
||||
/*
|
||||
* Disable the depth test for now as has some strange side effects,
|
||||
* mainly on x/y axis rotation with multiple layers at same depth
|
||||
* (eg rotating text on a bg has very strange effect). Seems no clean
|
||||
* 100% effective way to fix without other odd issues.. So for now
|
||||
* move to application to handle and add cogl_enable_depth_test()
|
||||
* as for custom actors (i.e groups) to enable if need be.
|
||||
*
|
||||
* glEnable (GL_DEPTH_TEST);
|
||||
* glEnable (GL_ALPHA_TEST)
|
||||
* glDepthFunc (GL_LEQUAL);
|
||||
* glAlphaFunc (GL_GREATER, 0.1);
|
||||
*/
|
||||
if (buffers & COGL_BUFFER_BIT_COLOR)
|
||||
{
|
||||
GE( glClearColor (cogl_color_get_red_float (color),
|
||||
cogl_color_get_green_float (color),
|
||||
cogl_color_get_blue_float (color),
|
||||
0.0) );
|
||||
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
|
||||
if (buffers & COGL_BUFFER_BIT_DEPTH)
|
||||
gl_buffers |= GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
if (buffers & COGL_BUFFER_BIT_STENCIL)
|
||||
gl_buffers |= GL_STENCIL_BUFFER_BIT;
|
||||
|
||||
if (!gl_buffers)
|
||||
{
|
||||
static gboolean shown = FALSE;
|
||||
|
||||
if (!shown)
|
||||
{
|
||||
g_warning ("You should specify at least one auxiliary buffer "
|
||||
"when calling cogl_clear");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
glClear (gl_buffers);
|
||||
|
||||
COGL_NOTE (DRAW, "Clear end");
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
@ -556,24 +571,31 @@ cogl_get_viewport (float v[4])
|
||||
}
|
||||
|
||||
void
|
||||
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
|
||||
cogl_get_bitmasks (gint *red,
|
||||
gint *green,
|
||||
gint *blue,
|
||||
gint *alpha)
|
||||
{
|
||||
GLint value;
|
||||
|
||||
if (red)
|
||||
{
|
||||
GE( glGetIntegerv(GL_RED_BITS, &value) );
|
||||
*red = value;
|
||||
}
|
||||
|
||||
if (green)
|
||||
{
|
||||
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
|
||||
*green = value;
|
||||
}
|
||||
|
||||
if (blue)
|
||||
{
|
||||
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
|
||||
*blue = value;
|
||||
}
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );
|
||||
|
@ -103,6 +103,13 @@ cogl_path_stroke_preserve
|
||||
cogl_color
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>cogl-bitmap</FILE>
|
||||
<TITLE>Bitmaps</TITLE>
|
||||
cogl_bitmap_new_from_file
|
||||
cogl_bitmap_get_size_from_file
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>cogl-texture</FILE>
|
||||
<TITLE>Textures</TITLE>
|
||||
@ -130,12 +137,6 @@ cogl_texture_get_gl_texture
|
||||
cogl_texture_get_data
|
||||
cogl_texture_set_filters
|
||||
cogl_texture_set_region
|
||||
|
||||
<SUBSECTION>
|
||||
CoglBitmap
|
||||
cogl_bitmap_new_from_file
|
||||
cogl_bitmap_free
|
||||
cogl_bitmap_get_size_from_file
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@ -148,7 +149,8 @@ cogl_is_shader
|
||||
cogl_shader_source
|
||||
cogl_shader_compile
|
||||
cogl_shader_get_info_log
|
||||
cogl_shader_get_parameteriv
|
||||
cogl_shader_get_type
|
||||
cogl_shader_is_compiled
|
||||
<SUBSECTION>
|
||||
cogl_create_program
|
||||
cogl_program_ref
|
||||
@ -172,9 +174,7 @@ cogl_offscreen_new_to_texture
|
||||
cogl_offscreen_ref
|
||||
cogl_offscreen_unref
|
||||
cogl_is_offscreen
|
||||
cogl_offscreen_blit
|
||||
cogl_offscreen_blit_region
|
||||
cogl_draw_buffer
|
||||
cogl_set_draw_buffer
|
||||
<SUBSECTION Private>
|
||||
cogl_offscreen_new_multisample
|
||||
</SECTION>
|
||||
|
104
gl/Makefile.am
104
gl/Makefile.am
@ -1,65 +1,65 @@
|
||||
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||
libclutterinclude_HEADERS = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-color.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-deprecated.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-path.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-types.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-material.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-matrix.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-debug.h
|
||||
NULL =
|
||||
|
||||
cogl_headers = \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-color.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-deprecated.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-fixed.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-path.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-bitmap.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-types.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-material.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-matrix.h \
|
||||
$(top_srcdir)/clutter/cogl/cogl-debug.h \
|
||||
$(NULL)
|
||||
|
||||
cogl_priv_headers = \
|
||||
cogl-texture-private.h \
|
||||
cogl-fbo.h \
|
||||
cogl-shader-private.h \
|
||||
cogl-program.h \
|
||||
cogl-context.h \
|
||||
$(NULL)
|
||||
|
||||
cogl_sources = \
|
||||
cogl.c \
|
||||
cogl-primitives.c \
|
||||
cogl-texture.c \
|
||||
cogl-fbo.c \
|
||||
cogl-shader.c \
|
||||
cogl-program.c \
|
||||
cogl-context.c \
|
||||
$(NULL)
|
||||
|
||||
coglincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
|
||||
coglinclude_HEADERS = \
|
||||
$(cogl_headers) \
|
||||
$(top_builddir)/clutter/cogl/cogl.h
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/clutter \
|
||||
-I$(top_srcdir)/clutter/cogl \
|
||||
-I$(top_srcdir)/clutter/cogl/common \
|
||||
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
|
||||
-I$(top_srcdir)/clutter \
|
||||
-I$(top_builddir)/clutter \
|
||||
-I$(top_builddir)/clutter/cogl \
|
||||
-DG_LOG_DOMAIN=\"Cogl-GL\" \
|
||||
-DCLUTTER_COMPILATION \
|
||||
$(CLUTTER_CFLAGS) \
|
||||
$(CLUTTER_DEBUG_CFLAGS) \
|
||||
$(MAINTAINER_CFLAGS) \
|
||||
$(GCC_FLAGS)
|
||||
|
||||
LDADD = $(CLUTTER_LIBS)
|
||||
-DG_LOG_DOMAIN=\"Cogl-GL\" \
|
||||
-DCLUTTER_COMPILATION
|
||||
|
||||
noinst_LTLIBRARIES = libclutter-cogl.la
|
||||
|
||||
libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||
libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
libclutter_cogl_la_SOURCES = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-color.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-deprecated.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-fixed.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-path.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-types.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-debug.h \
|
||||
cogl-internal.h \
|
||||
cogl-texture-private.h \
|
||||
cogl-fbo.h \
|
||||
cogl-shader-private.h \
|
||||
cogl-program.h \
|
||||
cogl-context.h \
|
||||
cogl.c \
|
||||
cogl-primitives.c \
|
||||
cogl-texture.c \
|
||||
cogl-fbo.c \
|
||||
cogl-shader.c \
|
||||
cogl-program.c \
|
||||
cogl-context.c
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(cogl_headers) \
|
||||
$(cogl_priv_headers) \
|
||||
$(cogl_sources) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = cogl-defines.h.in
|
||||
|
||||
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -44,6 +42,7 @@ cogl_create_context ()
|
||||
{
|
||||
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
|
||||
gulong enable_flags = 0;
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
if (_context != NULL)
|
||||
return FALSE;
|
||||
@ -80,7 +79,11 @@ cogl_create_context ()
|
||||
sizeof (CoglLayerInfo));
|
||||
_context->n_texcoord_arrays_enabled = 0;
|
||||
|
||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||
draw_buffer = g_slice_new0 (CoglDrawBufferState);
|
||||
draw_buffer->target = COGL_WINDOW_BUFFER;
|
||||
draw_buffer->offscreen = COGL_INVALID_HANDLE;
|
||||
_context->draw_buffer_stack =
|
||||
g_slist_prepend (NULL, draw_buffer);
|
||||
|
||||
_context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
|
||||
_context->last_path = 0;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -38,6 +36,12 @@ typedef struct
|
||||
GLubyte c[4];
|
||||
} CoglTextureGLVertex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CoglBufferTarget target;
|
||||
CoglHandle offscreen;
|
||||
} CoglDrawBufferState;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Features cache */
|
||||
@ -84,7 +88,7 @@ typedef struct
|
||||
guint n_texcoord_arrays_enabled;
|
||||
|
||||
/* Framebuffer objects */
|
||||
CoglBufferTarget draw_buffer;
|
||||
GSList *draw_buffer_stack;
|
||||
|
||||
/* Clip stack */
|
||||
CoglClipStackState clip;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,14 +24,11 @@
|
||||
#ifndef __COGL_DEFINES_H__
|
||||
#define __COGL_DEFINES_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <@CLUTTER_GL_HEADER@>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef GLenum COGLenum;
|
||||
typedef GLint COGLint;
|
||||
typedef GLuint COGLuint;
|
||||
|
||||
/* FIXME + DOCUMENT */
|
||||
|
||||
#define COPENSTEP OPENSTEP
|
||||
@ -227,7 +222,6 @@ typedef GLuint COGLuint;
|
||||
#define CGL_FOG_INDEX GL_FOG_INDEX
|
||||
#define CGL_FOG_START GL_FOG_START
|
||||
#define CGL_FOG_END GL_FOG_END
|
||||
#define CGL_LINEAR GL_LINEAR
|
||||
#define CGL_EXP GL_EXP
|
||||
#define CGL_LOGIC_OP GL_LOGIC_OP
|
||||
#define CGL_INDEX_LOGIC_OP GL_INDEX_LOGIC_OP
|
||||
@ -420,10 +414,6 @@ typedef GLuint COGLuint;
|
||||
#define CGL_TEXTURE_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE
|
||||
#define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE
|
||||
#define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_SIZE
|
||||
#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST
|
||||
#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR
|
||||
#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST
|
||||
#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR
|
||||
#define CGL_OBJECT_LINEAR GL_OBJECT_LINEAR
|
||||
#define CGL_OBJECT_PLANE GL_OBJECT_PLANE
|
||||
#define CGL_EYE_LINEAR GL_EYE_LINEAR
|
||||
@ -431,7 +421,6 @@ typedef GLuint COGLuint;
|
||||
#define CGL_SPHERE_MAP GL_SPHERE_MAP
|
||||
#define CGL_DECAL GL_DECAL
|
||||
#define CGL_MODULATE GL_MODULATE
|
||||
#define CGL_NEAREST GL_NEAREST
|
||||
#define CGL_REPEAT GL_REPEAT
|
||||
#define CGL_CLAMP GL_CLAMP
|
||||
#define CGL_S GL_S
|
||||
@ -693,9 +682,6 @@ typedef GLuint COGLuint;
|
||||
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
|
||||
#endif
|
||||
|
||||
#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB
|
||||
#define CGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB
|
||||
|
||||
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB
|
||||
|
||||
#define CLUTTER_COGL_HAS_GL 1
|
||||
@ -865,26 +851,26 @@ typedef void
|
||||
|
||||
typedef void
|
||||
(APIENTRYP COGL_PFNGLBINDBUFFERARBPROC)
|
||||
(GLenum target,
|
||||
(GLenum target,
|
||||
GLuint buffer);
|
||||
|
||||
typedef void
|
||||
(APIENTRYP COGL_PFNGLBUFFERDATAARBPROC)
|
||||
(GLenum target,
|
||||
GLsizeiptr size,
|
||||
const GLvoid *data,
|
||||
(GLenum target,
|
||||
GLsizeiptr size,
|
||||
const GLvoid *data,
|
||||
GLenum usage);
|
||||
|
||||
typedef void
|
||||
(APIENTRYP COGL_PFNGLBUFFERSUBDATAARBPROC)
|
||||
(GLenum target,
|
||||
GLintptr offset,
|
||||
(GLenum target,
|
||||
GLintptr offset,
|
||||
GLsizeiptr size,
|
||||
const GLvoid *data);
|
||||
|
||||
typedef void *
|
||||
(APIENTRYP COGL_PFNGLMAPBUFFERARBPROC)
|
||||
(GLenum target,
|
||||
(GLenum target,
|
||||
GLenum access);
|
||||
|
||||
typedef GLboolean
|
||||
|
222
gl/cogl-fbo.c
222
gl/cogl-fbo.c
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -71,25 +69,25 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
GLuint fbo_gl_handle;
|
||||
GLuint gl_stencil_handle;
|
||||
GLenum status;
|
||||
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
|
||||
|
||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
|
||||
/* Make texhandle is a valid texture object */
|
||||
if (!cogl_is_texture (texhandle))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
|
||||
tex = _cogl_texture_pointer_from_handle (texhandle);
|
||||
|
||||
|
||||
/* The texture must not be sliced */
|
||||
if (tex->slice_gl_handles == NULL)
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
|
||||
if (tex->slice_gl_handles->len != 1)
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
|
||||
/* Pick the single texture slice width, height and GL id */
|
||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
|
||||
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
|
||||
@ -111,10 +109,10 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
GE( glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, gl_stencil_handle) );
|
||||
|
||||
|
||||
/* Make sure it's complete */
|
||||
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
|
||||
|
||||
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
{
|
||||
/* Stencil renderbuffers aren't always supported. Try again
|
||||
@ -125,9 +123,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
0) );
|
||||
GE( glDeleteRenderbuffersEXT (1, &gl_stencil_handle) );
|
||||
gl_stencil_handle = 0;
|
||||
|
||||
|
||||
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
|
||||
|
||||
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
{
|
||||
/* Still failing, so give up */
|
||||
@ -136,9 +134,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
|
||||
|
||||
|
||||
/* Allocate and init a CoglFbo object (store non-wasted size
|
||||
for subsequent blits and viewport setup) */
|
||||
fbo = (CoglFbo*) g_malloc (sizeof (CoglFbo));
|
||||
@ -150,15 +148,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
return _cogl_offscreen_handle_new (fbo);
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_offscreen_new_multisample ()
|
||||
{
|
||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_offscreen_free (CoglFbo *fbo)
|
||||
{
|
||||
@ -173,90 +162,26 @@ _cogl_offscreen_free (CoglFbo *fbo)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int src_w,
|
||||
int src_h,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int dst_w,
|
||||
int dst_h)
|
||||
{
|
||||
CoglFbo *src_fbo;
|
||||
CoglFbo *dst_fbo;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
|
||||
return;
|
||||
|
||||
/* Make sure these are valid fbo handles */
|
||||
if (!cogl_is_offscreen (src_buffer))
|
||||
return;
|
||||
|
||||
if (!cogl_is_offscreen (dst_buffer))
|
||||
return;
|
||||
|
||||
src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer);
|
||||
dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer);
|
||||
|
||||
/* Copy (and scale) a region from one to another framebuffer */
|
||||
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
|
||||
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
|
||||
GE( glBlitFramebufferEXT (src_x, src_y, src_x + src_w, src_y + src_h,
|
||||
dst_x, dst_y, dst_x + dst_w, dst_y + dst_h,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer)
|
||||
{
|
||||
CoglFbo *src_fbo;
|
||||
CoglFbo *dst_fbo;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
|
||||
return;
|
||||
|
||||
/* Make sure these are valid fbo handles */
|
||||
if (!cogl_is_offscreen (src_buffer))
|
||||
return;
|
||||
|
||||
if (!cogl_is_offscreen (dst_buffer))
|
||||
return;
|
||||
|
||||
src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer);
|
||||
dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer);
|
||||
|
||||
/* Copy (and scale) whole image from one to another framebuffer */
|
||||
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
|
||||
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
|
||||
GE( glBlitFramebufferEXT (0, 0, src_fbo->width, src_fbo->height,
|
||||
0, 0, dst_fbo->width, dst_fbo->height,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
{
|
||||
CoglFbo *fbo = NULL;
|
||||
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
draw_buffer = ctx->draw_buffer_stack->data;
|
||||
|
||||
if (target == COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
/* Make sure it is a valid fbo handle */
|
||||
if (!cogl_is_offscreen (offscreen))
|
||||
return;
|
||||
|
||||
|
||||
fbo = _cogl_offscreen_pointer_from_handle (offscreen);
|
||||
|
||||
|
||||
/* Check current draw buffer target */
|
||||
if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER)
|
||||
if (draw_buffer->target != COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
/* Push the viewport and matrix setup if redirecting
|
||||
from a non-screen buffer */
|
||||
@ -280,16 +205,16 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
|
||||
_cogl_current_matrix_identity ();
|
||||
}
|
||||
|
||||
|
||||
/* Setup new viewport and matrices */
|
||||
GE( glViewport (0, 0, fbo->width, fbo->height) );
|
||||
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
|
||||
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
|
||||
|
||||
|
||||
/* Bind offscreen framebuffer object */
|
||||
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) );
|
||||
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||
|
||||
|
||||
/* Some implementation require a clear before drawing
|
||||
to an fbo. Luckily it is affected by scissor test. */
|
||||
/* FIXME: test where exactly this is needed end whether
|
||||
@ -299,13 +224,11 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
GE( glEnable (GL_SCISSOR_TEST) );
|
||||
GE( glClear (GL_COLOR_BUFFER_BIT) );
|
||||
GE( glPopAttrib () );
|
||||
|
||||
}
|
||||
else if ((target & COGL_WINDOW_BUFFER) ||
|
||||
(target & COGL_MASK_BUFFER))
|
||||
else if (target & COGL_WINDOW_BUFFER)
|
||||
{
|
||||
/* Check current draw buffer target */
|
||||
if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER)
|
||||
if (draw_buffer->target == COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
/* Pop viewport and matrices if redirecting back
|
||||
from an offscreen buffer */
|
||||
@ -317,22 +240,77 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
|
||||
_cogl_current_matrix_pop ();
|
||||
}
|
||||
|
||||
|
||||
/* Bind window framebuffer object */
|
||||
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
|
||||
|
||||
if (target == COGL_MASK_BUFFER)
|
||||
{
|
||||
/* Draw only to ALPHA channel */
|
||||
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw to all channels */
|
||||
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Store new target */
|
||||
ctx->draw_buffer = target;
|
||||
draw_buffer->target = target;
|
||||
if (draw_buffer->offscreen != offscreen)
|
||||
{
|
||||
if (draw_buffer->offscreen != COGL_INVALID_HANDLE)
|
||||
cogl_handle_unref (draw_buffer->offscreen);
|
||||
if (offscreen != COGL_INVALID_HANDLE)
|
||||
cogl_handle_ref (offscreen);
|
||||
draw_buffer->offscreen = offscreen;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cogl_push_draw_buffer(void)
|
||||
{
|
||||
CoglDrawBufferState *old;
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
old = ctx->draw_buffer_stack->data;
|
||||
|
||||
draw_buffer = g_slice_new0 (CoglDrawBufferState);
|
||||
*draw_buffer = *old;
|
||||
|
||||
ctx->draw_buffer_stack =
|
||||
g_slist_prepend (ctx->draw_buffer_stack, draw_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_pop_draw_buffer(void)
|
||||
{
|
||||
CoglDrawBufferState *to_pop;
|
||||
CoglDrawBufferState *to_restore;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
if (ctx->draw_buffer_stack->next == NULL)
|
||||
{
|
||||
g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()");
|
||||
return;
|
||||
}
|
||||
|
||||
to_pop = ctx->draw_buffer_stack->data;
|
||||
to_restore = ctx->draw_buffer_stack->next->data;
|
||||
|
||||
/* the logic in cogl_set_draw_buffer() only works if
|
||||
* to_pop is still on top of the stack, because
|
||||
* cogl_set_draw_buffer() needs to know the previous
|
||||
* state.
|
||||
*/
|
||||
cogl_set_draw_buffer (to_restore->target, to_restore->offscreen);
|
||||
|
||||
/* cogl_set_draw_buffer() should have set top of stack
|
||||
* to to_restore
|
||||
*/
|
||||
g_assert (to_restore->target == to_pop->target);
|
||||
g_assert (to_restore->offscreen == to_pop->offscreen);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack->data == to_pop);
|
||||
ctx->draw_buffer_stack =
|
||||
g_slist_remove_link (ctx->draw_buffer_stack,
|
||||
ctx->draw_buffer_stack);
|
||||
|
||||
g_slice_free (CoglDrawBufferState, to_pop);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COGL_INTERNAL_H
|
||||
#define __COGL_INTERNAL_H
|
||||
|
||||
#define COGL_DEBUG 0
|
||||
|
||||
#if COGL_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const char *_cogl_error_string(GLenum errorCode);
|
||||
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum err; \
|
||||
(x); \
|
||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||
(char *)_cogl_error_string(err), \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
|
||||
#define GE(x) (x)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
|
||||
#define COGL_ENABLE_BLEND (1<<1)
|
||||
#define COGL_ENABLE_ALPHA_TEST (1<<2)
|
||||
#define COGL_ENABLE_VERTEX_ARRAY (1<<3)
|
||||
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
|
||||
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
|
||||
|
||||
gint
|
||||
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
void
|
||||
cogl_enable (gulong flags);
|
||||
|
||||
gulong
|
||||
cogl_get_enable ();
|
||||
|
||||
#endif /* __COGL_INTERNAL_H */
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -96,7 +94,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
|
||||
CoglShader *shader;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle))
|
||||
return;
|
||||
|
||||
@ -111,7 +109,7 @@ cogl_program_link (CoglHandle handle)
|
||||
{
|
||||
CoglProgram *program;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (!cogl_is_program (handle))
|
||||
return;
|
||||
|
||||
@ -126,7 +124,7 @@ cogl_program_use (CoglHandle handle)
|
||||
CoglProgram *program;
|
||||
GLhandleARB gl_handle;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle))
|
||||
return;
|
||||
|
||||
@ -141,13 +139,13 @@ cogl_program_use (CoglHandle handle)
|
||||
glUseProgramObjectARB (gl_handle);
|
||||
}
|
||||
|
||||
COGLint
|
||||
int
|
||||
cogl_program_get_uniform_location (CoglHandle handle,
|
||||
const gchar *uniform_name)
|
||||
{
|
||||
CoglProgram *program;
|
||||
_COGL_GET_CONTEXT (ctx, 0);
|
||||
|
||||
|
||||
if (!cogl_is_program (handle))
|
||||
return 0;
|
||||
|
||||
@ -157,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_1f (COGLint uniform_no,
|
||||
cogl_program_uniform_1f (int uniform_no,
|
||||
gfloat value)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
@ -165,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_1i (COGLint uniform_no,
|
||||
cogl_program_uniform_1i (int uniform_no,
|
||||
gint value)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
@ -173,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_float (COGLint uniform_no,
|
||||
cogl_program_uniform_float (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const GLfloat *value)
|
||||
@ -200,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_int (COGLint uniform_no,
|
||||
cogl_program_uniform_int (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const COGLint *value)
|
||||
const int *value)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -227,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_matrix (COGLint uniform_no,
|
||||
cogl_program_uniform_matrix (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
gboolean transpose,
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -57,25 +55,37 @@ _cogl_shader_free (CoglShader *shader)
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_create_shader (COGLenum shaderType)
|
||||
cogl_create_shader (CoglShaderType type)
|
||||
{
|
||||
CoglShader *shader;
|
||||
GLenum gl_type;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, 0);
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
|
||||
if (type == COGL_SHADER_TYPE_VERTEX)
|
||||
gl_type = GL_VERTEX_SHADER;
|
||||
else if (type == COGL_SHADER_TYPE_FRAGMENT)
|
||||
gl_type = GL_FRAGMENT_SHADER;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected shader type (0x%08lX) given to "
|
||||
"cogl_create_shader", (unsigned long) type);
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
shader = g_slice_new (CoglShader);
|
||||
shader->gl_handle = glCreateShaderObjectARB (shaderType);
|
||||
shader->gl_handle = glCreateShaderObjectARB (gl_type);
|
||||
|
||||
return _cogl_shader_handle_new (shader);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_source (CoglHandle handle,
|
||||
const gchar *source)
|
||||
const char *source)
|
||||
{
|
||||
CoglShader *shader;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
|
||||
@ -100,11 +110,11 @@ cogl_shader_compile (CoglHandle handle)
|
||||
|
||||
void
|
||||
cogl_shader_get_info_log (CoglHandle handle,
|
||||
guint size,
|
||||
gchar *buffer)
|
||||
size_t size,
|
||||
char *buffer)
|
||||
{
|
||||
CoglShader *shader;
|
||||
COGLint len;
|
||||
int len;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
@ -116,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle,
|
||||
buffer[len]='\0';
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_get_parameteriv (CoglHandle handle,
|
||||
COGLenum pname,
|
||||
COGLint *dest)
|
||||
CoglShaderType
|
||||
cogl_shader_get_type (CoglHandle handle)
|
||||
{
|
||||
GLint type;
|
||||
CoglShader *shader;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
{
|
||||
g_warning ("Non shader handle type passed to cogl_shader_get_type");
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
}
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
glGetObjectParameterivARB (shader->gl_handle, pname, dest);
|
||||
GE (glGetObjectParameterivARB (shader->gl_handle, GL_SHADER_TYPE, &type));
|
||||
if (type == GL_VERTEX_SHADER)
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
else if (type == GL_FRAGMENT_SHADER)
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_shader_is_compiled (CoglHandle handle)
|
||||
{
|
||||
GLint status;
|
||||
CoglShader *shader;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return FALSE;
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
GE (glGetObjectParameterivARB (shader->gl_handle, GL_COMPILE_STATUS, &status));
|
||||
if (status == GL_TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,7 +24,7 @@
|
||||
#ifndef __COGL_TEXTURE_H
|
||||
#define __COGL_TEXTURE_H
|
||||
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
#include "cogl-handle.h"
|
||||
|
||||
typedef struct _CoglTexture CoglTexture;
|
||||
@ -70,8 +68,8 @@ struct _CoglTexture
|
||||
GArray *slice_y_spans;
|
||||
GArray *slice_gl_handles;
|
||||
gint max_waste;
|
||||
COGLenum min_filter;
|
||||
COGLenum mag_filter;
|
||||
CoglTextureFilter min_filter;
|
||||
CoglTextureFilter mag_filter;
|
||||
gboolean is_foreign;
|
||||
GLint wrap_mode;
|
||||
gboolean auto_mipmap;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,6 +19,11 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors:
|
||||
* Matthew Allum <mallum@openedhand.com>
|
||||
* Neil Roberts <neil@linux.intel.com>
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -31,6 +34,7 @@
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
#include "cogl-texture-private.h"
|
||||
#include "cogl-material.h"
|
||||
#include "cogl-context.h"
|
||||
@ -40,17 +44,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
#define COGL_DEBUG 1
|
||||
|
||||
#define GE(x) \
|
||||
{ \
|
||||
glGetError(); x; \
|
||||
GLuint err = glGetError(); \
|
||||
if (err != 0) \
|
||||
printf("err: 0x%x\n", err); \
|
||||
} */
|
||||
|
||||
#ifdef HAVE_COGL_GL
|
||||
|
||||
#define glDrawRangeElements ctx->pf_glDrawRangeElements
|
||||
@ -939,12 +932,11 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
||||
{
|
||||
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
|
||||
|
||||
#if COGL_DEBUG
|
||||
printf ("CREATE SLICE (%d,%d)\n", x,y);
|
||||
printf ("size: (%d x %d)\n",
|
||||
x_span->size - x_span->waste,
|
||||
y_span->size - y_span->waste);
|
||||
#endif
|
||||
COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
|
||||
x, y,
|
||||
x_span->size - x_span->waste,
|
||||
y_span->size - y_span->waste);
|
||||
|
||||
/* Setup texture parameters */
|
||||
GE( glBindTexture (tex->gl_target,
|
||||
gl_handles[y * n_x_slices + x]) );
|
||||
@ -1243,8 +1235,8 @@ cogl_texture_new_with_size (guint width,
|
||||
tex->slice_gl_handles = NULL;
|
||||
|
||||
tex->max_waste = max_waste;
|
||||
tex->min_filter = CGL_NEAREST;
|
||||
tex->mag_filter = CGL_NEAREST;
|
||||
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
|
||||
/* Find closest GL format match */
|
||||
tex->bitmap.format =
|
||||
@ -1304,8 +1296,8 @@ cogl_texture_new_from_data (guint width,
|
||||
tex->slice_gl_handles = NULL;
|
||||
|
||||
tex->max_waste = max_waste;
|
||||
tex->min_filter = CGL_NEAREST;
|
||||
tex->mag_filter = CGL_NEAREST;
|
||||
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
|
||||
/* FIXME: If upload fails we should set some kind of
|
||||
* error flag but still return texture handle (this
|
||||
@ -1336,12 +1328,15 @@ cogl_texture_new_from_data (guint width,
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
|
||||
gint max_waste,
|
||||
CoglTextureFlags flags,
|
||||
CoglPixelFormat internal_format)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
CoglBitmap *bmp = (CoglBitmap *)bmp_handle;
|
||||
|
||||
g_return_val_if_fail (bmp_handle != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE);
|
||||
|
||||
/* Create new texture and fill with loaded data */
|
||||
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
|
||||
@ -1358,8 +1353,8 @@ cogl_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||
tex->slice_gl_handles = NULL;
|
||||
|
||||
tex->max_waste = max_waste;
|
||||
tex->min_filter = CGL_NEAREST;
|
||||
tex->mag_filter = CGL_NEAREST;
|
||||
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
|
||||
|
||||
/* FIXME: If upload fails we should set some kind of
|
||||
* error flag but still return texture handle if the
|
||||
@ -1399,19 +1394,20 @@ cogl_texture_new_from_file (const gchar *filename,
|
||||
CoglPixelFormat internal_format,
|
||||
GError **error)
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
CoglHandle bmp;
|
||||
CoglHandle handle;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
||||
|
||||
if (!(bmp = cogl_bitmap_new_from_file (filename, error)))
|
||||
bmp = cogl_bitmap_new_from_file (filename, error);
|
||||
if (bmp == COGL_INVALID_HANDLE)
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
handle = cogl_texture_new_from_bitmap (bmp,
|
||||
max_waste,
|
||||
flags,
|
||||
internal_format);
|
||||
cogl_bitmap_free (bmp);
|
||||
cogl_handle_unref (bmp);
|
||||
|
||||
return handle;
|
||||
}
|
||||
@ -1685,7 +1681,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
COGLenum
|
||||
CoglTextureFilter
|
||||
cogl_texture_get_min_filter (CoglHandle handle)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
@ -1698,7 +1694,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
|
||||
return tex->min_filter;
|
||||
}
|
||||
|
||||
COGLenum
|
||||
CoglTextureFilter
|
||||
cogl_texture_get_mag_filter (CoglHandle handle)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
@ -1713,8 +1709,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
|
||||
|
||||
void
|
||||
cogl_texture_set_filters (CoglHandle handle,
|
||||
COGLenum min_filter,
|
||||
COGLenum mag_filter)
|
||||
CoglTextureFilter min_filter,
|
||||
CoglTextureFilter mag_filter)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
GLuint gl_handle;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -8,6 +8,7 @@ libclutterinclude_HEADERS = \
|
||||
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-path.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-bitmap.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-types.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
|
||||
@ -24,16 +25,13 @@ INCLUDES = \
|
||||
-I$(top_builddir)/clutter \
|
||||
-I$(top_builddir)/clutter/cogl \
|
||||
-DG_LOG_DOMAIN=\"Cogl-GLES\" \
|
||||
-DCLUTTER_COMPILATION \
|
||||
$(CLUTTER_CFLAGS) \
|
||||
$(CLUTTER_DEBUG_CFLAGS) \
|
||||
$(MAINTAINER_CFLAGS) \
|
||||
$(GCC_FLAGS)
|
||||
|
||||
LDADD = $(CLUTTER_LIBS)
|
||||
-DCLUTTER_COMPILATION
|
||||
|
||||
noinst_LTLIBRARIES = libclutter-cogl.la
|
||||
|
||||
libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||
libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
libclutter_cogl_la_SOURCES = \
|
||||
$(top_builddir)/clutter/cogl/cogl.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-defines-gles.h \
|
||||
@ -43,10 +41,10 @@ libclutter_cogl_la_SOURCES = \
|
||||
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-path.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-shader.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-bitmap.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-texture.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-types.h \
|
||||
$(top_builddir)/clutter/cogl/cogl-debug.h \
|
||||
cogl-internal.h \
|
||||
cogl-texture-private.h \
|
||||
cogl-fbo.h \
|
||||
cogl-context.h \
|
||||
@ -75,8 +73,6 @@ EXTRA_DIST = cogl-defines.h.in \
|
||||
cogl-fixed-vertex-shader.glsl \
|
||||
cogl-fixed-fragment-shader.glsl
|
||||
|
||||
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
|
||||
|
||||
.glsl.h :
|
||||
/bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh -h $<
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -46,6 +44,7 @@ cogl_create_context ()
|
||||
{
|
||||
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
|
||||
gulong enable_flags = 0;
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
if (_context != NULL)
|
||||
return FALSE;
|
||||
@ -83,7 +82,11 @@ cogl_create_context ()
|
||||
sizeof (CoglLayerInfo));
|
||||
_context->n_texcoord_arrays_enabled = 0;
|
||||
|
||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||
draw_buffer = g_slice_new0 (CoglDrawBufferState);
|
||||
draw_buffer->target = COGL_WINDOW_BUFFER;
|
||||
draw_buffer->offscreen = COGL_INVALID_HANDLE;
|
||||
_context->draw_buffer_stack =
|
||||
g_slist_prepend (NULL, draw_buffer);
|
||||
|
||||
_context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
|
||||
_context->last_path = 0;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -40,6 +38,12 @@ typedef struct
|
||||
GLubyte c[4];
|
||||
} CoglTextureGLVertex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CoglBufferTarget target;
|
||||
CoglHandle offscreen;
|
||||
} CoglDrawBufferState;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Features cache */
|
||||
@ -86,7 +90,7 @@ typedef struct
|
||||
guint n_texcoord_arrays_enabled;
|
||||
|
||||
/* Framebuffer objects */
|
||||
CoglBufferTarget draw_buffer;
|
||||
GSList *draw_buffer_stack;
|
||||
|
||||
/* Clip stack */
|
||||
CoglClipStackState clip;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#ifndef __COGL_DEFINES_H__
|
||||
#define __COGL_DEFINES_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <@CLUTTER_GL_HEADER@>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -429,10 +430,6 @@ G_BEGIN_DECLS
|
||||
#define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES
|
||||
#define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES
|
||||
|
||||
typedef GLenum COGLenum;
|
||||
typedef GLint COGLint;
|
||||
typedef GLuint COGLuint;
|
||||
|
||||
/* extras */
|
||||
|
||||
/* YUV textures also unsupported */
|
||||
@ -440,18 +437,6 @@ typedef GLuint COGLuint;
|
||||
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
|
||||
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
|
||||
|
||||
#ifdef GL_FRAGMENT_SHADER
|
||||
#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER
|
||||
#else
|
||||
#define CGL_FRAGMENT_SHADER 0
|
||||
#endif
|
||||
|
||||
#ifdef GL_VERTEX_SHADER
|
||||
#define CGL_VERTEX_SHADER GL_VERTEX_SHADER
|
||||
#else
|
||||
#define CGL_VERTEX_SHADER 0
|
||||
#endif
|
||||
|
||||
#if defined(GL_OBJECT_COMPILE_STATUS)
|
||||
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS
|
||||
#elif defined(GL_COMPILE_STATUS)
|
||||
|
166
gles/cogl-fbo.c
166
gles/cogl-fbo.c
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -132,15 +130,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
return _cogl_offscreen_handle_new (fbo);
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_offscreen_new_multisample ()
|
||||
{
|
||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_offscreen_free (CoglFbo *fbo)
|
||||
{
|
||||
@ -155,36 +144,16 @@ _cogl_offscreen_free (CoglFbo *fbo)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int src_w,
|
||||
int src_h,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int dst_w,
|
||||
int dst_h)
|
||||
{
|
||||
/* Not supported on GLES */
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer)
|
||||
{
|
||||
/* Not supported on GLES */
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
{
|
||||
CoglFbo *fbo = NULL;
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
draw_buffer = ctx->draw_buffer_stack->data;
|
||||
|
||||
if (target == COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
GLboolean scissor_enabled;
|
||||
@ -197,7 +166,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
fbo = _cogl_offscreen_pointer_from_handle (offscreen);
|
||||
|
||||
/* Check current draw buffer target */
|
||||
if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER)
|
||||
if (draw_buffer->target != COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
/* Push the viewport and matrix setup if redirecting
|
||||
from a non-screen buffer */
|
||||
@ -247,11 +216,10 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
scissor_box[2], scissor_box[3]);
|
||||
|
||||
}
|
||||
else if ((target & COGL_WINDOW_BUFFER) ||
|
||||
(target & COGL_MASK_BUFFER))
|
||||
else if (target & COGL_WINDOW_BUFFER)
|
||||
{
|
||||
/* Check current draw buffer target */
|
||||
if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER)
|
||||
if (draw_buffer->target == COGL_OFFSCREEN_BUFFER)
|
||||
{
|
||||
/* Pop viewport and matrices if redirecting back
|
||||
from an offscreen buffer */
|
||||
@ -267,27 +235,75 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
|
||||
/* Bind window framebuffer object */
|
||||
GE( glBindFramebuffer (GL_FRAMEBUFFER, 0) );
|
||||
|
||||
|
||||
if (target == COGL_WINDOW_BUFFER)
|
||||
{
|
||||
/* Draw to RGB channels */
|
||||
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||
}
|
||||
else if (target == COGL_MASK_BUFFER)
|
||||
{
|
||||
/* Draw only to ALPHA channel */
|
||||
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw to all channels */
|
||||
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Store new target */
|
||||
ctx->draw_buffer = target;
|
||||
draw_buffer->target = target;
|
||||
if (draw_buffer->offscreen != offscreen)
|
||||
{
|
||||
if (draw_buffer->offscreen != COGL_INVALID_HANDLE)
|
||||
cogl_handle_unref (draw_buffer->offscreen);
|
||||
if (offscreen != COGL_INVALID_HANDLE)
|
||||
cogl_handle_ref (offscreen);
|
||||
draw_buffer->offscreen = offscreen;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cogl_push_draw_buffer(void)
|
||||
{
|
||||
CoglDrawBufferState *old;
|
||||
CoglDrawBufferState *draw_buffer;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
old = ctx->draw_buffer_stack->data;
|
||||
|
||||
draw_buffer = g_slice_new0 (CoglDrawBufferState);
|
||||
*draw_buffer = *old;
|
||||
|
||||
ctx->draw_buffer_stack =
|
||||
g_slist_prepend (ctx->draw_buffer_stack, draw_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_pop_draw_buffer(void)
|
||||
{
|
||||
CoglDrawBufferState *to_pop;
|
||||
CoglDrawBufferState *to_restore;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack != NULL);
|
||||
if (ctx->draw_buffer_stack->next == NULL)
|
||||
{
|
||||
g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()");
|
||||
return;
|
||||
}
|
||||
|
||||
to_pop = ctx->draw_buffer_stack->data;
|
||||
to_restore = ctx->draw_buffer_stack->next->data;
|
||||
|
||||
/* the logic in cogl_set_draw_buffer() only works if
|
||||
* to_pop is still on top of the stack, because
|
||||
* cogl_set_draw_buffer() needs to know the previous
|
||||
* state.
|
||||
*/
|
||||
cogl_set_draw_buffer (to_restore->target, to_restore->offscreen);
|
||||
|
||||
/* cogl_set_draw_buffer() should have set top of stack
|
||||
* to to_restore
|
||||
*/
|
||||
g_assert (to_restore->target == to_pop->target);
|
||||
g_assert (to_restore->offscreen == to_pop->offscreen);
|
||||
|
||||
g_assert (ctx->draw_buffer_stack->data == to_pop);
|
||||
ctx->draw_buffer_stack =
|
||||
g_slist_remove_link (ctx->draw_buffer_stack,
|
||||
ctx->draw_buffer_stack);
|
||||
|
||||
g_slice_free (CoglDrawBufferState, to_pop);
|
||||
}
|
||||
|
||||
#else /* HAVE_COGL_GLES2 */
|
||||
@ -306,12 +322,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_offscreen_new_multisample ()
|
||||
{
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_offscreen_ref (CoglHandle handle)
|
||||
{
|
||||
@ -324,27 +334,7 @@ cogl_offscreen_unref (CoglHandle handle)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit_region (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int src_w,
|
||||
int src_h,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int dst_w,
|
||||
int dst_h)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cogl_offscreen_blit (CoglHandle src_buffer,
|
||||
CoglHandle dst_buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -356,7 +354,7 @@ cogl_gles2_get_fragment_shader (const CoglGles2WrapperSettings *settings)
|
||||
g_string_append (shader_source, cogl_fixed_fragment_shader_main_declare);
|
||||
|
||||
g_string_append (shader_source, cogl_fixed_fragment_shader_main_start);
|
||||
|
||||
|
||||
/* This pointless extra variable is needed to work around an
|
||||
apparent bug in the PowerVR drivers. Without it the alpha
|
||||
blending seems to stop working */
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COGL_INTERNAL_H
|
||||
#define __COGL_INTERNAL_H
|
||||
|
||||
typedef enum {
|
||||
COGL_BOXED_NONE,
|
||||
COGL_BOXED_INT,
|
||||
COGL_BOXED_FLOAT,
|
||||
COGL_BOXED_MATRIX
|
||||
} CoglBoxedType;
|
||||
|
||||
typedef struct _CoglBoxedValue
|
||||
{
|
||||
CoglBoxedType type;
|
||||
int size, count;
|
||||
gboolean transpose;
|
||||
|
||||
union {
|
||||
gfloat float_value[4];
|
||||
gint int_value[4];
|
||||
gfloat matrix[16];
|
||||
gfloat *float_array;
|
||||
gint *int_array;
|
||||
gpointer array;
|
||||
} v;
|
||||
} CoglBoxedValue;
|
||||
|
||||
|
||||
#define COGL_DEBUG 0
|
||||
|
||||
#if COGL_DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const char *_cogl_error_string(GLenum errorCode);
|
||||
|
||||
#define GE(x...) G_STMT_START { \
|
||||
GLenum err; \
|
||||
(x); \
|
||||
while ((err = glGetError()) != GL_NO_ERROR) { \
|
||||
fprintf(stderr, "glError: %s caught at %s:%u\n", \
|
||||
(char *)_cogl_error_string(err), \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#else /* COGL_DEBUG */
|
||||
|
||||
#define GE(x) (x)
|
||||
|
||||
#endif /* COGL_DEBUG */
|
||||
|
||||
#define COGL_ENABLE_BLEND (1<<1)
|
||||
#define COGL_ENABLE_ALPHA_TEST (1<<2)
|
||||
#define COGL_ENABLE_VERTEX_ARRAY (1<<3)
|
||||
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
|
||||
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
|
||||
|
||||
void
|
||||
_cogl_features_init (void);
|
||||
|
||||
gint
|
||||
_cogl_get_format_bpp (CoglPixelFormat format);
|
||||
|
||||
void
|
||||
cogl_enable (gulong flags);
|
||||
|
||||
gulong
|
||||
cogl_get_enable ();
|
||||
|
||||
#endif /* __COGL_INTERNAL_H */
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -89,7 +87,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
|
||||
CoglProgram *program;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle))
|
||||
return;
|
||||
|
||||
@ -116,7 +114,7 @@ void
|
||||
cogl_program_use (CoglHandle handle)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle))
|
||||
return;
|
||||
|
||||
@ -124,7 +122,7 @@ cogl_program_use (CoglHandle handle)
|
||||
ctx->gles2.settings_dirty = TRUE;
|
||||
}
|
||||
|
||||
COGLint
|
||||
int
|
||||
cogl_program_get_uniform_location (CoglHandle handle,
|
||||
const gchar *uniform_name)
|
||||
{
|
||||
@ -157,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_1f (COGLint uniform_no,
|
||||
cogl_program_uniform_1f (int uniform_no,
|
||||
gfloat value)
|
||||
{
|
||||
cogl_program_uniform_float (uniform_no, 1, 1, &value);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_1i (COGLint uniform_no,
|
||||
cogl_program_uniform_1i (int uniform_no,
|
||||
gint value)
|
||||
{
|
||||
cogl_program_uniform_int (uniform_no, 1, 1, &value);
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_program_uniform_x (COGLint uniform_no,
|
||||
cogl_program_uniform_x (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
CoglBoxedType type,
|
||||
@ -217,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_float (COGLint uniform_no,
|
||||
cogl_program_uniform_float (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const GLfloat *value)
|
||||
@ -227,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_int (COGLint uniform_no,
|
||||
cogl_program_uniform_int (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const GLint *value)
|
||||
@ -237,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_matrix (COGLint uniform_no,
|
||||
cogl_program_uniform_matrix (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
gboolean transpose,
|
||||
@ -298,7 +296,7 @@ cogl_program_use (CoglHandle program_handle)
|
||||
{
|
||||
}
|
||||
|
||||
COGLint
|
||||
int
|
||||
cogl_program_get_uniform_location (CoglHandle program_handle,
|
||||
const gchar *uniform_name)
|
||||
{
|
||||
@ -306,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_1f (COGLint uniform_no,
|
||||
cogl_program_uniform_1f (int uniform_no,
|
||||
gfloat value)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_float (COGLint uniform_no,
|
||||
cogl_program_uniform_float (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const GLfloat *value)
|
||||
@ -320,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_int (COGLint uniform_no,
|
||||
cogl_program_uniform_int (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
const COGLint *value)
|
||||
const int *value)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cogl_program_uniform_matrix (COGLint uniform_no,
|
||||
cogl_program_uniform_matrix (int uniform_no,
|
||||
gint size,
|
||||
gint count,
|
||||
gboolean transpose,
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -50,26 +48,35 @@ _cogl_shader_free (CoglShader *shader)
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_create_shader (COGLenum shaderType)
|
||||
cogl_create_shader (CoglShaderType type)
|
||||
{
|
||||
CoglShader *shader;
|
||||
GLenum gl_type;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, 0);
|
||||
if (type == COGL_SHADER_TYPE_VERTEX)
|
||||
gl_type = GL_VERTEX_SHADER;
|
||||
else if (type == COGL_SHADER_TYPE_FRAGMENT)
|
||||
gl_type = GL_FRAGMENT_SHADER;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected shader type (0x%08lX) given to "
|
||||
"cogl_create_shader", (unsigned long) type);
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
shader = g_slice_new (CoglShader);
|
||||
shader->gl_handle = glCreateShader (shaderType);
|
||||
shader->type = shaderType;
|
||||
shader->gl_handle = glCreateShader (gl_type);
|
||||
|
||||
return _cogl_shader_handle_new (shader);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_source (CoglHandle handle,
|
||||
const gchar *source)
|
||||
const char *source)
|
||||
{
|
||||
CoglShader *shader;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
|
||||
@ -94,11 +101,11 @@ cogl_shader_compile (CoglHandle handle)
|
||||
|
||||
void
|
||||
cogl_shader_get_info_log (CoglHandle handle,
|
||||
guint size,
|
||||
gchar *buffer)
|
||||
size_t size,
|
||||
char *buffer)
|
||||
{
|
||||
CoglShader *shader;
|
||||
COGLint len = 0;
|
||||
int len = 0;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
@ -110,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle,
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_get_parameteriv (CoglHandle handle,
|
||||
COGLenum pname,
|
||||
COGLint *dest)
|
||||
CoglShaderType
|
||||
cogl_shader_get_type (CoglHandle handle)
|
||||
{
|
||||
GLint type;
|
||||
CoglShader *shader;
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return;
|
||||
{
|
||||
g_warning ("Non shader handle type passed to cogl_shader_get_type");
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
}
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
glGetShaderiv (shader->gl_handle, pname, dest);
|
||||
GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type));
|
||||
if (type == GL_VERTEX_SHADER)
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
else if (type == GL_FRAGMENT_SHADER)
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
else
|
||||
{
|
||||
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_shader_is_compiled (CoglHandle handle)
|
||||
{
|
||||
GLint status;
|
||||
CoglShader *shader;
|
||||
|
||||
if (!cogl_is_shader (handle))
|
||||
return FALSE;
|
||||
|
||||
shader = _cogl_shader_pointer_from_handle (handle);
|
||||
|
||||
GE (glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
|
||||
if (status == GL_TRUE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#else /* HAVE_COGL_GLES2 */
|
||||
@ -131,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle,
|
||||
/* No support on regular OpenGL 1.1 */
|
||||
|
||||
CoglHandle
|
||||
cogl_create_shader (COGLenum shaderType)
|
||||
cogl_create_shader (CoglShaderType type)
|
||||
{
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
@ -155,7 +190,7 @@ cogl_shader_unref (CoglHandle handle)
|
||||
|
||||
void
|
||||
cogl_shader_source (CoglHandle shader,
|
||||
const gchar *source)
|
||||
const char *source)
|
||||
{
|
||||
}
|
||||
|
||||
@ -166,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle)
|
||||
|
||||
void
|
||||
cogl_shader_get_info_log (CoglHandle handle,
|
||||
guint size,
|
||||
gchar *buffer)
|
||||
size_t size,
|
||||
char *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
cogl_shader_get_parameteriv (CoglHandle handle,
|
||||
COGLenum pname,
|
||||
COGLint *dest)
|
||||
CoglShaderType
|
||||
cogl_shader_get_type (CoglHandle handle)
|
||||
{
|
||||
return COGL_SHADER_TYPE_VERTEX;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_shader_is_compiled (CoglHandle handle)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* HAVE_COGL_GLES2 */
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,7 +24,7 @@
|
||||
#ifndef __COGL_TEXTURE_H
|
||||
#define __COGL_TEXTURE_H
|
||||
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
#include "cogl-handle.h"
|
||||
|
||||
typedef struct _CoglTexture CoglTexture;
|
||||
@ -70,8 +68,8 @@ struct _CoglTexture
|
||||
GArray *slice_y_spans;
|
||||
GArray *slice_gl_handles;
|
||||
gint max_waste;
|
||||
COGLenum min_filter;
|
||||
COGLenum mag_filter;
|
||||
CoglTextureFilter min_filter;
|
||||
CoglTextureFilter mag_filter;
|
||||
gboolean is_foreign;
|
||||
GLint wrap_mode;
|
||||
gboolean auto_mipmap;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -30,7 +28,7 @@
|
||||
#include "cogl.h"
|
||||
#include "cogl-internal.h"
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
#include "cogl-texture-private.h"
|
||||
#include "cogl-material.h"
|
||||
#include "cogl-context.h"
|
||||
@ -42,17 +40,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
#define COGL_DEBUG 1
|
||||
|
||||
#define GE(x) \
|
||||
{ \
|
||||
glGetError(); x; \
|
||||
GLuint err = glGetError(); \
|
||||
if (err != 0) \
|
||||
printf("err: 0x%x\n", err); \
|
||||
} */
|
||||
|
||||
extern void _cogl_journal_flush (void);
|
||||
|
||||
static void _cogl_texture_free (CoglTexture *tex);
|
||||
@ -485,9 +472,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
|
||||
_cogl_current_matrix_push ();
|
||||
_cogl_current_matrix_identity ();
|
||||
|
||||
/* Draw to all channels */
|
||||
cogl_draw_buffer (COGL_WINDOW_BUFFER | COGL_MASK_BUFFER, 0);
|
||||
|
||||
/* Direct copy operation */
|
||||
|
||||
if (ctx->texture_download_material == COGL_INVALID_HANDLE)
|
||||
@ -584,8 +568,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
|
||||
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
|
||||
_cogl_current_matrix_pop ();
|
||||
|
||||
cogl_draw_buffer (COGL_WINDOW_BUFFER, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1435,12 +1417,13 @@ cogl_texture_new_from_data (guint width,
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
|
||||
gint max_waste,
|
||||
CoglTextureFlags flags,
|
||||
CoglPixelFormat internal_format)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
CoglBitmap *bmp = (CoglBitmap *)bmp_handle;
|
||||
|
||||
/* Create new texture and fill with loaded data */
|
||||
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
|
||||
@ -1498,19 +1481,20 @@ cogl_texture_new_from_file (const gchar *filename,
|
||||
CoglPixelFormat internal_format,
|
||||
GError **error)
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
CoglHandle bmp;
|
||||
CoglHandle handle;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
||||
|
||||
if (!(bmp = cogl_bitmap_new_from_file (filename, error)))
|
||||
bmp = cogl_bitmap_new_from_file (filename, error);
|
||||
if (bmp == COGL_INVALID_HANDLE)
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
handle = cogl_texture_new_from_bitmap (bmp,
|
||||
max_waste,
|
||||
flags,
|
||||
internal_format);
|
||||
cogl_bitmap_free (bmp);
|
||||
cogl_handle_unref (bmp);
|
||||
|
||||
return handle;
|
||||
}
|
||||
@ -1783,7 +1767,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
COGLenum
|
||||
CoglTextureFilter
|
||||
cogl_texture_get_min_filter (CoglHandle handle)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
@ -1796,7 +1780,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
|
||||
return tex->min_filter;
|
||||
}
|
||||
|
||||
COGLenum
|
||||
CoglTextureFilter
|
||||
cogl_texture_get_mag_filter (CoglHandle handle)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
@ -1811,8 +1795,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
|
||||
|
||||
void
|
||||
cogl_texture_set_filters (CoglHandle handle,
|
||||
COGLenum min_filter,
|
||||
COGLenum mag_filter)
|
||||
CoglTextureFilter min_filter,
|
||||
CoglTextureFilter mag_filter)
|
||||
{
|
||||
CoglTexture *tex;
|
||||
GLuint gl_handle;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -44,7 +42,7 @@ cogl_util_next_p2 (int a)
|
||||
{
|
||||
int rval=1;
|
||||
|
||||
while(rval < a)
|
||||
while(rval < a)
|
||||
rval <<= 1;
|
||||
|
||||
return rval;
|
||||
|
@ -1,11 +1,9 @@
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2007 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,7 +24,7 @@
|
||||
#ifndef __COGL_UTIL_H
|
||||
#define __COGL_UTIL_H
|
||||
|
||||
int
|
||||
int
|
||||
cogl_util_next_p2 (int a);
|
||||
|
||||
#endif /* __COGL_UTIL_H */
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2007,2008,2009 OpenedHand
|
||||
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1,16 +1,36 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Cogl
|
||||
#
|
||||
# An object oriented GL/GLES Abstraction/Utility Layer
|
||||
#
|
||||
# Copyright (C) 2008,2009 Intel Corporation.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
output_copyright ()
|
||||
{
|
||||
cat <<EOF > "$1";
|
||||
/*
|
||||
* Clutter COGL
|
||||
* Cogl
|
||||
*
|
||||
* A basic GL/GLES Abstraction/Utility Layer
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||
*
|
||||
* Copyright (C) 2008 OpenedHand
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
Loading…
Reference in New Issue
Block a user