mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 16:40:41 -05:00
5985eef44c
This glues CoglMaterial in as the fundamental way that Cogl describes how to fill in geometry. It adds cogl_set_source (), which is used to set the material which will be used by all subsequent drawing functions It adds cogl_set_source_texture as a convenience for setting up a default material with a single texture layer, and cogl_set_source_color is now also a convenience for setting up a material with a solid fill. "drawing functions" include, cogl_rectangle, cogl_texture_rectangle, cogl_texture_multiple_rectangles, cogl_texture_polygon (though the cogl_texture_* funcs have been renamed; see below for details), cogl_path_fill/stroke and cogl_vertex_buffer_draw*. cogl_texture_rectangle, cogl_texture_multiple_rectangles and cogl_texture_polygon no longer take a texture handle; instead the current source material is referenced. The functions have also been renamed to: cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords and cogl_polygon respectivly. Most code that previously did: cogl_texture_rectangle (tex_handle, x, y,...); needs to be changed to now do: cogl_set_source_texture (tex_handle); cogl_rectangle_with_texture_coords (x, y,....); In the less likely case where you were blending your source texture with a color like: cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */ cogl_texture_rectangle (tex_handle, x, y,...); you will need your own material to do that: mat = cogl_material_new (); cogl_material_set_color4ub (r,g,b,a); cogl_material_set_layer (mat, 0, tex_handle)); cogl_set_source_material (mat); Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use cog_rectangle_with_texure_coords since these are the coordinates that cogl_rectangle will use. For cogl_texture_polygon; as well as dropping the texture handle, the n_vertices and vertices arguments were transposed for consistency. So code previously written as: cogl_texture_polygon (tex_handle, 3, verts, TRUE); need to be written as: cogl_set_source_texture (tex_handle); cogl_polygon (verts, 3, TRUE); All of the unit tests have been updated to now use the material API and test-cogl-material has been renamed to test-cogl-multitexture since any textured quad is now technically a test of CoglMaterial but this test specifically creates a material with multiple texture layers. Note: The GLES backend has not been updated yet; that will be done in a following commit.
82 lines
2.4 KiB
C
82 lines
2.4 KiB
C
/*
|
|
* 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_TEXTURE_H
|
|
#define __COGL_TEXTURE_H
|
|
|
|
#include "cogl-bitmap.h"
|
|
|
|
typedef struct _CoglTexture CoglTexture;
|
|
typedef struct _CoglTexSliceSpan CoglTexSliceSpan;
|
|
typedef struct _CoglSpanIter CoglSpanIter;
|
|
|
|
struct _CoglTexSliceSpan
|
|
{
|
|
gint start;
|
|
gint size;
|
|
gint waste;
|
|
};
|
|
|
|
struct _CoglTexture
|
|
{
|
|
guint ref_count;
|
|
CoglBitmap bitmap;
|
|
gboolean bitmap_owner;
|
|
GLenum gl_target;
|
|
GLenum gl_intformat;
|
|
GLenum gl_format;
|
|
GLenum gl_type;
|
|
GArray *slice_x_spans;
|
|
GArray *slice_y_spans;
|
|
GArray *slice_gl_handles;
|
|
gint max_waste;
|
|
COGLenum min_filter;
|
|
COGLenum mag_filter;
|
|
gboolean is_foreign;
|
|
GLint wrap_mode;
|
|
gboolean auto_mipmap;
|
|
};
|
|
|
|
/* To improve batching of geometry when submitting vertices to OpenGL we
|
|
* log the texture rectangles we want to draw to a journal, so when we
|
|
* later flush the journal we aim to batch data, and gl draw calls. */
|
|
typedef struct _CoglJournalEntry
|
|
{
|
|
CoglHandle material;
|
|
gint n_layers;
|
|
guint32 fallback_mask;
|
|
GLuint layer0_override_texture;
|
|
} CoglJournalEntry;
|
|
|
|
CoglTexture*
|
|
_cogl_texture_pointer_from_handle (CoglHandle handle);
|
|
|
|
gboolean
|
|
_cogl_texture_span_has_waste (CoglTexture *tex,
|
|
gint x_span_index,
|
|
gint y_span_index);
|
|
|
|
#endif /* __COGL_TEXTURE_H */
|