Re: [AD] GLSL #version

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


And to make that more clear, I have a function that I pass the shader source
into and it simply adds a line at the top, '#version XYZ".

Thanks,
Trent

-----Original Message-----
From: Trent Gamblin [mailto:nooskewl@xxxxxxxxxx] 
Sent: January 8, 2014 11:57 AM
To: 'Allegro Development'
Subject: Re: [AD] GLSL #version

This then does prevent the user from using their shaders verbatim outside of
Allegro or using outside shaders with Allegro. Personally I prefer the
approach I've been using which is to do it myself.

Thanks,
Trent

-----Original Message-----
From: SiegeLord [mailto:slabode@xxxxxxxxxx] 
Sent: January 8, 2014 11:42 AM
To: Coordination of admins/developers of the game programming library
Allegro
Subject: [AD] GLSL #version

Right now we have a slight issue with our shader API. The root problem 
comes from the fact that GLSL and GLES SL are different languages... it 
is generally not the case that you can send use the same code for 
desktop OpenGL and for OpenGL ES. Many differences can be abstracted 
away via #ifdef GL_ES/#endif, but not all of them. In particular, the 
#version statement cannot be placed inside a pre-processor block, which 
means that it is impossible to use the same source file for both 
versions of OpenGL (they have different sets of valid #version numbers).

OpenGL API solves this by allowing you to specify multiple sources of 
code to send to the GPU. I.e. they solve the problem by requiring you to 
write something like this:

const char **gl_code = {"#version 110\n", shader_source};
const char **gles_code = {"#version 100\n", shader_source};
glShaderSource(handle, 2, use_gles ? gles_code : gl_code, NULL);

Our API does not allow that (the main culprit is 
al_attach_shader_source_file). I don't necessarily think we should take 
the same route (especially since these hacks are not needed for HLSL). I 
propose letting Allegro pre-process the shader source and expand a 
special macro:

#define ALLEGRO_GLSL_VERSION(gl_version, gles_version) \
#ifdef GL_ES \
	#version gles_version \
#else \
	#version gl_version \
#endif

The user would then place that macro at the top of their shader source 
file and it'd do the right thing.

-SL

----------------------------------------------------------------------------
--
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
-- 
https://lists.sourceforge.net/lists/listinfo/alleg-developers


----------------------------------------------------------------------------
--
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
-- 
https://lists.sourceforge.net/lists/listinfo/alleg-developers





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/