return GL_FALSE;
}
+ switch (ctx->API) {
#if FEATURE_es2_glsl
- /* For ES2, we can draw if any vertex array is enabled (and we should
- * always have a vertex program/shader).
- */
- if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current)
- return GL_FALSE;
-#else
- /* For regular OpenGL, only draw if we have vertex positions (regardless
- * of whether or not we have a vertex program/shader).
- */
- if (!ctx->Array.ArrayObj->Vertex.Enabled &&
- !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
- return GL_FALSE;
+ case API_OPENGLES2:
+ /* For ES2, we can draw if any vertex array is enabled (and we
+ * should always have a vertex program/shader). */
+ if (ctx->Array.ArrayObj->_Enabled == 0x0 || !ctx->VertexProgram._Current)
+ return GL_FALSE;
+ break;
#endif
+#if FEATURE_ES1 || FEATURE_GL
+ case API_OPENGLES:
+ case API_OPENGL:
+ /* For regular OpenGL, only draw if we have vertex positions
+ * (regardless of whether or not we have a vertex program/shader). */
+ if (!ctx->Array.ArrayObj->Vertex.Enabled &&
+ !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
+ return GL_FALSE;
+ break;
+#endif
+
+ default:
+ ASSERT_NO_FEATURE();
+ }
+
return GL_TRUE;
}
#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
ctx->VertexProgram.Enabled = GL_FALSE;
#if FEATURE_es2_glsl
- ctx->VertexProgram.PointSizeEnabled = GL_TRUE;
+ ctx->VertexProgram.PointSizeEnabled =
+ (ctx->API == API_OPENGLES2) ? GL_TRUE : GL_FALSE;
#else
ctx->VertexProgram.PointSizeEnabled = GL_FALSE;
#endif
_slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
slang_unit_type type)
{
+ GET_CURRENT_CONTEXT(ctx);
struct gl_program *prog = A->program;
const char *varName = (char *) var->a_name;
GLboolean success = GL_TRUE;
}
#if FEATURE_es2_glsl /* XXX should use FEATURE_texture_rect */
/* disallow rect samplers */
- if (is_rect_sampler_spec(&var->type.specifier)) {
+ if (ctx->API == API_OPENGLES2 &&
+ is_rect_sampler_spec(&var->type.specifier)) {
slang_info_log_error(A->log, "invalid sampler type for '%s'", varName);
return GL_FALSE;
}
static void
init_default_precision(slang_output_ctx *O, slang_unit_type type)
{
+ GET_CURRENT_CONTEXT(ctx);
GLuint i;
for (i = 0; i < TYPE_SPECIFIER_COUNT; i++) {
#if FEATURE_es2_glsl
- O->default_precision[i] = PRECISION_LOW;
+ if (ctx->API == API_OPENGLES2)
+ O->default_precision[i] = PRECISION_LOW;
+ else
+ O->default_precision[i] = PRECISION_HIGH;
#else
O->default_precision[i] = PRECISION_HIGH;
#endif
/* allow 'invariant' keyword? */
#if FEATURE_es2_glsl
- o.allow_invariant = GL_TRUE;
+ o.allow_invariant =
+ (ctx->API == API_OPENGLES2 || C->version >= 120) ? GL_TRUE : GL_FALSE;
#else
o.allow_invariant = (C->version >= 120) ? GL_TRUE : GL_FALSE;
#endif
/* allow 'lowp/mediump/highp' keywords? */
#if FEATURE_es2_glsl
- o.allow_precision = GL_TRUE;
+ o.allow_precision =
+ (ctx->API == API_OPENGLES2 || C->version >= 120) ? GL_TRUE : GL_FALSE;
#else
o.allow_precision = (C->version >= 120) ? GL_TRUE : GL_FALSE;
#endif
unsigned int shader_type,
unsigned int parsing_builtin)
{
+ GET_CURRENT_CONTEXT(ctx);
struct sl_pp_purify_options options;
struct sl_pp_context *context;
unsigned char *prod;
#if FEATURE_es2_glsl
- if (sl_pp_context_add_predefined(context, "GL_ES", "1") ||
- sl_pp_context_add_predefined(context, "GL_FRAGMENT_PRECISION_HIGH", "1")) {
- slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context));
- sl_pp_context_destroy(context);
- return GL_FALSE;
+ if (ctx->API == API_OPENGLES2) {
+ if (sl_pp_context_add_predefined(context, "GL_ES", "1") ||
+ sl_pp_context_add_predefined(context, "GL_FRAGMENT_PRECISION_HIGH", "1")) {
+ slang_info_log_error(infolog, "%s", sl_pp_context_error_message(context));
+ sl_pp_context_destroy(context);
+ return GL_FALSE;
+ }
}
#endif
#if FEATURE_es2_glsl
/* must have both a vertex and fragment program for ES2 */
- if (!vertProg) {
- link_error(shProg, "missing vertex shader\n");
- return;
- }
- if (!fragProg) {
- link_error(shProg, "missing fragment shader\n");
- return;
+ if (ctx->API == API_OPENGLES2) {
+ if (!vertProg) {
+ link_error(shProg, "missing vertex shader\n");
+ return;
+ }
+ if (!fragProg) {
+ link_error(shProg, "missing fragment shader\n");
+ return;
+ }
}
#endif