2010-06-15 11:44:52 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008,2009,2010 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, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-07-01 20:07:36 -04:00
|
|
|
#include "cogl-material-private.h"
|
2010-08-12 05:37:55 -04:00
|
|
|
#include "cogl-shader-private.h"
|
2010-07-01 20:07:36 -04:00
|
|
|
|
|
|
|
#ifdef COGL_MATERIAL_BACKEND_GLSL
|
|
|
|
|
2010-06-15 11:44:52 -04:00
|
|
|
#include "cogl.h"
|
|
|
|
#include "cogl-internal.h"
|
|
|
|
#include "cogl-context.h"
|
|
|
|
#include "cogl-handle.h"
|
|
|
|
|
|
|
|
#ifndef HAVE_COGL_GLES
|
|
|
|
#include "cogl-program.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GL/GLES compatability defines for material thingies:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GLES2
|
|
|
|
#include "../gles/cogl-gles2-wrapper.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cogl_material_backend_glsl_get_max_texture_units (void)
|
|
|
|
{
|
|
|
|
return _cogl_get_max_texture_image_units ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_cogl_material_backend_glsl_start (CoglMaterial *material,
|
|
|
|
int n_layers,
|
|
|
|
unsigned long materials_difference)
|
|
|
|
{
|
2010-08-04 12:53:51 -04:00
|
|
|
CoglHandle program;
|
|
|
|
|
2010-06-15 11:44:52 -04:00
|
|
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
|
|
|
|
|
|
if (!cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-08-04 12:53:51 -04:00
|
|
|
program = cogl_material_get_user_program (material);
|
|
|
|
if (program == COGL_INVALID_HANDLE ||
|
|
|
|
_cogl_program_get_language (program) != COGL_SHADER_LANGUAGE_GLSL)
|
|
|
|
return FALSE; /* XXX: change me when we support code generation here */
|
2010-06-15 11:44:52 -04:00
|
|
|
|
2010-08-04 12:53:51 -04:00
|
|
|
_cogl_use_program (program, COGL_MATERIAL_PROGRAM_TYPE_GLSL);
|
|
|
|
return TRUE;
|
2010-06-15 11:44:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_cogl_material_backend_glsl_add_layer (CoglMaterial *material,
|
|
|
|
CoglMaterialLayer *layer,
|
|
|
|
unsigned long layers_difference)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_cogl_material_backend_glsl_passthrough (CoglMaterial *material)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_cogl_material_backend_glsl_end (CoglMaterial *material,
|
|
|
|
unsigned long materials_difference)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CoglMaterialBackend _cogl_material_glsl_backend =
|
|
|
|
{
|
|
|
|
_cogl_material_backend_glsl_get_max_texture_units,
|
|
|
|
_cogl_material_backend_glsl_start,
|
|
|
|
_cogl_material_backend_glsl_add_layer,
|
|
|
|
_cogl_material_backend_glsl_passthrough,
|
|
|
|
_cogl_material_backend_glsl_end,
|
|
|
|
NULL, /* material_state_change_notify */
|
|
|
|
NULL, /* material_set_parent_notify */
|
|
|
|
NULL, /* layer_state_change_notify */
|
|
|
|
NULL, /* free_priv */
|
|
|
|
};
|
|
|
|
|
2010-07-01 20:07:36 -04:00
|
|
|
#endif /* COGL_MATERIAL_BACKEND_GLSL */
|
|
|
|
|