Beispiel #1
0
static void
_v_hi_set_gl_state(WaveformActor* actor)
{
	AGl* agl = agl_get_instance();
	const WaveformContext* wfc = actor->canvas;

#if defined (MULTILINE_SHADER)
							glEnable(GL_BLEND);
							glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
							if(wfc->use_1d_textures){
								glDisable(GL_TEXTURE_1D);
								_c->shaders.lines->uniform.colour = actor->fg_colour;
								_c->shaders.lines->uniform.n_channels = w->n_channels;
							}
#elif defined(ANTIALIASED_LINES)
	if(wfc->use_1d_textures){
		agl->shaders.text->uniform.fg_colour = actor->fg_colour;
		agl_use_material(agl->aaline);
		agl_enable(AGL_ENABLE_BLEND | AGL_ENABLE_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, aaline_class.texture);
	}else{
		agl_enable(AGL_ENABLE_BLEND | AGL_ENABLE_TEXTURE_2D);
	}
#else
							glEnable(GL_BLEND);
							glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
							if(wfc->use_1d_textures){
								glDisable(GL_TEXTURE_1D);
								agl->shaders.plain->uniform.colour = actor->fg_colour;
								agl_use_program((AGlShader*)agl->shaders.plain);
							}
							glDisable(GL_TEXTURE_2D);
#endif
}
Beispiel #2
0
	void create_background(AGlActor* a)
	{
		//create an alpha-map gradient texture

		AGlTextureActor* ta = (AGlTextureActor*)a;

		if(ta->texture[0]) return;

		int width = 256;
		int height = 256;
		char* pbuf = g_new0(char, width * height);
#if 1
		int y; for(y=0;y<height;y++){
			int x; for(x=0;x<width;x++){
				*(pbuf + y * width + x) = ((x+y) * 0xff) / (width * 2);
			}
		}
#else
		// this gradient is brighter in the middle. It only works for stereo.
		int nc = 2;
		int c; for(c=0;c<nc;c++){
			int top = (height / nc) * c;
			int bot = height / nc;
			int mid = height / (2 * nc);
			int y; for(y=0;y<mid;y++){
				int x; for(x=0;x<width;x++){
					int y_ = top + y;
					int val = 0xff * (1.0 + sinf(((float)(-mid + 2 * y)) / mid));
					*(pbuf + y_ * width + x) = ((val) / 8 + ((x+y_) * 0xff) / (width * 2)) / 2;
					y_ = top + bot - y - 1;
					*(pbuf + (y_) * width + x) = ((val) / 8 + ((x+y_) * 0xff) / (width * 2)) / 2;
				}
			}
		} 
#endif

		agl_enable(AGL_ENABLE_TEXTURE_2D | AGL_ENABLE_BLEND);

		glGenTextures(1, ta->texture);
		if(glGetError() != GL_NO_ERROR){ gerr ("couldnt create bg_texture."); goto out; }

		agl_load_alphamap(pbuf, ta->texture[0], width, height);

	  out:
		g_free(pbuf);
	}