inline void VL_glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
 {
   if(glBlendColor)
     glBlendColor(red,green,blue,alpha);
   else
   if (glBlendColorEXT)
     glBlendColorEXT(red,green,blue,alpha);
   else
     VL_UNSUPPORTED_FUNC();
 }
Пример #2
0
void Renderer_gl2::equCrossSection()
{
	if (! tryVolShader)
	{
		Renderer_gl1::equCrossSection();
		return;
	}
	glBlendEquationEXT(GL_FUNC_ADD_EXT);/////////////////////
	glBlendColorEXT(1, 1, 1, 1-CSbeta);
	glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); // constant Alpha
}
Пример #3
0
/* allegro_gl_set_blender_mode (GFX_DRIVER vtable entry):
 * Sets the blending mode. Same implementation to all GFX vtables.
 */
void allegro_gl_set_blender_mode(int mode, int r, int g, int b, int a) {
	__allegro_gl_blit_operation = AGL_OP_BLEND;
	/* These blenders do not need any special extensions. 
	 * We specify only pixel arithmetic here. Blend equation and blend
	 * color (if available) are reset to defualt later.*/
	switch (mode) {
		case blender_mode_none:
			glBlendFunc(GL_ONE, GL_ZERO);
		break;
		case blender_mode_alpha:
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		break;
		case blender_mode_invert:
			glLogicOp(GL_COPY_INVERTED);
			__allegro_gl_blit_operation = AGL_OP_LOGIC_OP;
		break;
		case blender_mode_multiply:
			glBlendFunc(GL_DST_COLOR, GL_ZERO);
		break;
	}
	
	if (allegro_gl_opengl_version() >= 1.4 ||
	   (allegro_gl_opengl_version() >= 1.2 &&
		allegro_gl_is_extension_supported("GL_ARB_imaging"))) {
		/* We're running a recent version of OpenGL and everything needed is here. */
		
		glBlendColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f);

		switch (mode) {
			case blender_mode_none:
				glBlendEquation(GL_FUNC_ADD);
			break;
			case blender_mode_alpha:
				glBlendEquation(GL_FUNC_ADD);
			break;
			case blender_mode_trans:
				glBlendEquation(GL_FUNC_ADD);
				glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
			break;
			case blender_mode_add:
				glBlendEquation(GL_FUNC_ADD);
				glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE);
			break;
			case blender_mode_burn:
				glBlendEquation(GL_FUNC_SUBTRACT);
				glBlendFunc(GL_ONE, GL_CONSTANT_ALPHA);
			break;
			case blender_mode_dodge:
				glBlendEquation(GL_FUNC_ADD);
				glBlendFunc(GL_ONE, GL_CONSTANT_ALPHA);
			break;
			case blender_mode_multiply:
				glBlendEquation(GL_FUNC_ADD);
			break;
		}

		return;
	}
	
	/* Check for presence of glBlendColor() and special parameters to
	 * glBlendFunc(). */
	if (allegro_gl_is_extension_supported("GL_EXT_blend_color")) {
		glBlendColorEXT(r / 255.f, g / 255.f, b / 255.f, a / 255.f);

		switch (mode) {
			case blender_mode_trans:
				glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE_MINUS_CONSTANT_ALPHA_EXT);
			break;
			case blender_mode_add:
				glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE);
			break;
			case blender_mode_burn:
				glBlendFunc(GL_ONE, GL_CONSTANT_ALPHA_EXT);
			break;
			case blender_mode_dodge:
				glBlendFunc(GL_ONE, GL_CONSTANT_ALPHA_EXT);
			break;
		}
	}
	else if (mode == blender_mode_trans ||
			 mode == blender_mode_add ||
			 mode == blender_mode_burn ||
			 mode == blender_mode_dodge) {
		/* glBlendColor() is not available and it is needed by the selected
		 * bledner. Bail out.*/
		return;
	}

	/* Check for presence of glBlendEquation(). */
	if (allegro_gl_is_extension_supported("GL_EXT_blend_minmax")) {
		switch (mode) {
			case blender_mode_none:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_alpha:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_trans:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_add:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_dodge:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_multiply:
				glBlendEquationEXT(GL_FUNC_ADD_EXT);
			break;
			case blender_mode_burn:
				if (allegro_gl_is_extension_supported("GL_EXT_blend_subtract")) {
					glBlendEquationEXT(GL_FUNC_SUBTRACT_EXT);
				}
				else {
					/* GL_FUNC_SUBTRACT is not supported and it is needed by the
					 * selected blender. Bail out. */
					return;
				}
			break;
		}
	}
}
Пример #4
0
/* draw the object unlit without surface texture */
void redraw(void)
{
    int i;
    GLfloat offS, offT, offR; /* mapping texture to planes */

    offS = 200.f/texwid;
    offT = 200.f/texht;
    offR = 200.f/texdepth;
    
    clipplane0[W] = 100.f - offS;
    clipplane1[W] = 100.f - offS;
    clipplane2[W] = 100.f - offT;
    clipplane3[W] = 100.f - offT;
    clipplane4[W] = 100.f - offR;
    clipplane5[W] = 100.f - offR;

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    /* GL_MODELVIEW */
    if(cut) {
	cutplane[W] = cutbias;
	glClipPlane(GL_CLIP_PLANE5, cutplane);
    }

    glPushMatrix(); /* identity */
    glRotatef(objangle[X], 0.f, 1.f, 0.f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glClipPlane(GL_CLIP_PLANE0, clipplane0);
    glClipPlane(GL_CLIP_PLANE1, clipplane1);
    glClipPlane(GL_CLIP_PLANE2, clipplane2);
    glClipPlane(GL_CLIP_PLANE3, clipplane3);
    glClipPlane(GL_CLIP_PLANE4, clipplane4);
    if(!cut)
	glClipPlane(GL_CLIP_PLANE5, clipplane5);
    glPopMatrix(); /* back to identity */

    glMatrixMode(GL_TEXTURE);
    glPushMatrix(); /* identity */
    glTranslatef( .5f,  .5f, .5f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glRotatef(objangle[X], 0.f, 0.f, 1.f);
    glTranslatef( -.5f,  -.5f, -.5f);

    switch(operator) {
    case OVER:
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	break;
    case ATTENUATE:
#ifdef GL_EXT_blend_color
	if (ext_blend_color) {
	    glEnable(GL_BLEND);
	    glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE);
	    glBlendColorEXT(1.f, 1.f, 1.f, 1.f/slices);
	    break;
	}
#endif
	printf("EXT_blend_color not supported\n");
	break;
    case NONE:
	/* don't blend */
	break;
    }

    if(texture)
#ifdef GL_TEXTURE_3D_EXT
       glEnable(GL_TEXTURE_3D_EXT);
#else
       ;
#endif
    else {
Пример #5
0
/* draw the object unlit without surface texture */
void redraw(void)
{
    int i;
    GLfloat offS, offT, offR; /* mapping texture to planes */

    offS = 200.f/texwid;
    offT = 200.f/texht;
    offR = 200.f/texdepth;
    
    clipplane0[W] = 100.f - offS;
    clipplane1[W] = 100.f - offS;
    clipplane2[W] = 100.f - offT;
    clipplane3[W] = 100.f - offT;
    clipplane4[W] = 100.f - offR;
    clipplane5[W] = 100.f - offR;

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    if(map)
	remaptex();

    /* GL_MODELVIEW */
    if(cut)
    {
	cutplane[W] = cutbias;
	glClipPlane(GL_CLIP_PLANE5, cutplane);
    }

    glPushMatrix(); /* identity */
    glRotatef(objangle[X], 0.f, 1.f, 0.f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glClipPlane(GL_CLIP_PLANE0, clipplane0);
    glClipPlane(GL_CLIP_PLANE1, clipplane1);
    glClipPlane(GL_CLIP_PLANE2, clipplane2);
    glClipPlane(GL_CLIP_PLANE3, clipplane3);
    glClipPlane(GL_CLIP_PLANE4, clipplane4);
    if(!cut)
	glClipPlane(GL_CLIP_PLANE5, clipplane5);
    glPopMatrix(); /* back to identity */

    /* draw opaque geometry here */
    glDisable(GL_CLIP_PLANE0);
    glDisable(GL_CLIP_PLANE1);
    glDisable(GL_CLIP_PLANE2);
    glDisable(GL_CLIP_PLANE3);
    glDisable(GL_CLIP_PLANE4);
    if(geom)
    {
	if(!cut)
	    glDisable(GL_CLIP_PLANE5);
	glPushMatrix();
	glTranslatef(objpos[X], objpos[Y], objpos[Z]);
	glCallList(SPHERE);
	glPopMatrix();
    }
    glMatrixMode(GL_TEXTURE);
    glEnable(GL_CLIP_PLANE0);
    glEnable(GL_CLIP_PLANE1);
    glEnable(GL_CLIP_PLANE2);
    glEnable(GL_CLIP_PLANE3);
    glEnable(GL_CLIP_PLANE4);
    glEnable(GL_CLIP_PLANE5);

    glMatrixMode(GL_TEXTURE);
    glPushMatrix(); /* identity */
    glTranslatef( .5f,  .5f, .5f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glRotatef(objangle[X], 0.f, 0.f, 1.f);
    glTranslatef( -.5f,  -.5f, -.5f);

    switch(operator)
    {
    case OVER:
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	break;
    case ATTENUATE:
#ifdef GL_EXT_blend_color
        if (hasBlendColor){
	    glEnable(GL_BLEND);
	    glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE);
	    glBlendColorEXT(1.f, 1.f, 1.f, 1.f/slices);
        } else
#endif
        {
            fprintf(stderr, "volume: attenuate not supported!\n");
        }
        break;
    case NONE:
	/* don't blend */
	break;
    }

    if(texture) {
#ifdef GL_EXT_texture3D
       glEnable(GL_TEXTURE_3D_EXT);
#endif
    } else {
#ifdef GL_EXT_texture3D
       glDisable(GL_TEXTURE_3D_EXT);
#endif
       glEnable(GL_LIGHTING);
       glEnable(GL_LIGHT0);
    }

    

    for(i = 0; i < slices; i++)
    {
	glBegin(GL_QUADS);
	glVertex3f(-100.f, -100.f, 
		   -100.f + offR + i * (200.f - 2 * offR)/(slices - 1));
	glVertex3f( 100.f, -100.f,
		   -100.f + offR + i * (200.f - 2 * offR)/(slices - 1));
	glVertex3f( 100.f,  100.f,
		   -100.f + offR + i * (200.f - 2 * offR)/(slices - 1));
	glVertex3f(-100.f,  100.f,
		   -100.f + offR + i * (200.f - 2 * offR)/(slices - 1));
	glEnd();
    }
#ifdef GL_EXT_texture3D
    glDisable(GL_TEXTURE_3D_EXT);
#endif
    if(!texture)
    {
       glDisable(GL_LIGHTING);
    }
    glDisable(GL_BLEND);

    glPopMatrix(); /* back to identity */
    glMatrixMode(GL_MODELVIEW);

    if(operator == ATTENUATE)
    {
	glPixelTransferf(GL_RED_SCALE, 3.f); /* brighten image */
	glPixelTransferf(GL_GREEN_SCALE, 3.f);
	glPixelTransferf(GL_BLUE_SCALE, 3.f);
	glCopyPixels(0, 0, winWidth, winHeight, GL_COLOR);
    }
    if(dblbuf)
	glutSwapBuffers(); 
    else
	glFlush(); 

    CHECK_ERROR("OpenGL Error in redraw()");
}