Пример #1
0
static void
SDLGL_PushBlendingMode(void *drv, AG_BlendFn fnSrc, AG_BlendFn fnDst)
{
	AG_DriverSDLGL *sgl = drv;

	/* XXX TODO: stack */
	glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
	    &sgl->bs[0].texEnvMode);
	glGetBooleanv(GL_BLEND, &sgl->bs[0].enabled);
	glGetIntegerv(GL_BLEND_SRC, &sgl->bs[0].srcFactor);
	glGetIntegerv(GL_BLEND_DST, &sgl->bs[0].dstFactor);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glEnable(GL_BLEND);
	glBlendFunc(AG_GL_GetBlendingFunc(fnSrc), AG_GL_GetBlendingFunc(fnDst));
}
Пример #2
0
int __glXDisp_GetTexEnvfv(__GLXclientState *cl, GLbyte *pc)
{
	GLenum pname;
	GLint compsize;
	__GLXcontext *cx;
	ClientPtr client = cl->client;
	int error;
	GLfloat answerBuffer[200];
	char *answer;

	cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error);
	if (!cx) {
		return error;
	}
	pc += __GLX_SINGLE_HDR_SIZE;
	pname = *(GLenum *)(pc + 4);
	compsize = __glGetTexEnvfv_size(pname);
	if (compsize < 0) compsize = 0;

	__GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
	__glXClearErrorOccured();
	glGetTexEnvfv( 
		*(GLenum   *)(pc + 0),
		*(GLenum   *)(pc + 4),
		(GLfloat  *) answer
	);
	if (__glXErrorOccured()) {
	    __GLX_BEGIN_REPLY(0);
	    __GLX_PUT_SIZE(0);
	    __GLX_SEND_HEADER();
	} else if (compsize == 1) {
	    __GLX_BEGIN_REPLY(0);
	    __GLX_PUT_SIZE(1);
	    __GLX_PUT_FLOAT();
	    __GLX_SEND_HEADER();
	} else {
	    __GLX_BEGIN_REPLY(compsize*4);
	    __GLX_PUT_SIZE(compsize);
	    __GLX_SEND_HEADER();
	    __GLX_SEND_FLOAT_ARRAY(compsize);
	}
	return Success;
}
Пример #3
0
void LogoutEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
    {
    effects->paintScreen( mask, region, data );

#ifdef KWIN_HAVE_OPENGL_COMPOSITING
    if( blurSupported && progress > 0.0 )
        {
        assert( effects->popRenderTarget() == blurTarget );

        // Render the blurred scene
        blurTexture->bind();
        GLfloat bias[1];
        glGetTexEnvfv( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias );
        glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, progress * 2.75 );
        glBegin( GL_QUADS );
            glTexCoord2f( 0.0, 0.0 );
            glVertex2f( 0.0, displayHeight() );
            glTexCoord2f( 1.0, 0.0 );
            glVertex2f( displayWidth(), displayHeight() );
            glTexCoord2f( 1.0, 1.0 );
            glVertex2f( displayWidth(), 0.0 );
            glTexCoord2f( 0.0, 1.0 );
            glVertex2f( 0.0, 0.0 );
        glEnd();
        glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias[0] );
        blurTexture->unbind();

        // Render the logout window
        if( logoutWindow )
            {
            int winMask = logoutWindow->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE;
            WindowPaintData winData( logoutWindow );
            winData.opacity = windowOpacity;
            effects->drawWindow( logoutWindow, winMask, region, winData );
            }
        }
#endif
    }
Пример #4
0
static GLboolean
test_texture_env(void)
{
   /* Texture Environment state is fixed-function; not used by shaders */
   int i;

   clear_errors();

   /* set per-unit state */
   for (i = 0; i < MaxTextureCombinedUnits; i++) {
      glActiveTexture(GL_TEXTURE0 + i);
      glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, Random[i]);
      if (!piglit_check_gl_error(GL_NO_ERROR)) {
         return GL_FALSE;
      }
   }

   /* check per-unit state */
   for (i = 0; i < MaxTextureCombinedUnits; i++) {
      GLfloat v[4];
      glActiveTexture(GL_TEXTURE0 + i);
      glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, v);
      if (!equal4v(v, Random[i])) {
         printf("Setting per-unit env state failed for unit %d\n", i);
         report4v(Random[i], v);
         return GL_FALSE;
      }
   }

   /* there should be no errors at this point */
   if (!piglit_check_gl_error(GL_NO_ERROR)) {
      return GL_FALSE;
   }

   return GL_TRUE;
}
Пример #5
0
void GlStateSnapshot::log(std::string id, unsigned key, int type) {
	GLint ival[4];
	GLboolean bval[4];
	GLdouble dval[4];
	GLfloat fval[16];
	ival[0] = ival[1] = ival[2] = ival[3] = 0;
	fval[0] = fval[1] = fval[2] = fval[3] = 0;
	dval[0] = dval[1] = dval[2] = dval[3] = 0;
	bval[0] = bval[1] = bval[2] = bval[3] = false;
	std::ostringstream os;
	switch (type) {
		case INTv:
			glGetIntegerv(key, ival);
			os << "GL state: " << id << " " << ival[0];
			break;
		case BOOLv:
			glGetBooleanv(key, bval);
			os << "GL state: " << id << " " << (bval[0] ? "yes" : "no");
			break;
		case FLOATv:
			glGetFloatv(key, fval);
			os << "GL state: " << id << " " << fval[0];
			break;
		case DOUBLEv:
			glGetDoublev(key, dval);
			os << "GL state: " << id << " " << dval[0];
			break;
		case INTv2:
			glGetIntegerv(key, ival);
			os << "GL state: " << id << " " << ival[0] << " " << ival[1];
			break;
		case INTv4:
			glGetIntegerv(key, ival);
			os << "GL state: " << id << " " << ival[0] << " " << ival[1] << " " << ival[2] << " " << ival[3];
			break;
		case BOOLv4:
			glGetBooleanv(key, bval);
			os << "GL state: " << id << " " << (bval[0] ? 'y':'n') << " " << (bval[1] ? 'y':'n') << " " << (bval[2] ? 'y':'n') << " " << (bval[3] ? 'y':'n');
			break;
		case FLOATv4:
			glGetFloatv(key, fval);
			os << "GL state: " << id << " " << fval[0] << " " << fval[1] << " " << fval[2] << " " << fval[3];
			break;
		case FLOATv16:
			glGetFloatv(key, fval);
			os << "GL state: " << id << "0 " << fval[0] << " " << fval[1] << " " << fval[2] << " " << fval[3] << "\n";
			os << "GL state: " << id << "1 " << fval[4] << " " << fval[5] << " " << fval[6] << " " << fval[7] << "\n";
			os << "GL state: " << id << "2 " << fval[8] << " " << fval[9] << " " << fval[10] << " " << fval[11] << "\n";
			os << "GL state: " << id << "3 " << fval[12] << " " << fval[13] << " " << fval[14] << " " << fval[15];
			break;
		case TEXENViv:
			glGetTexEnviv(GL_TEXTURE_ENV, key, ival);
			os << "GL state: " << id << " " << ival[0];
			break;
		case TEXENVfv4:
			glGetTexEnvfv(GL_TEXTURE_ENV, key, fval);
			os << "GL state: " << id << " " << fval[0] << " " << fval[1] << " " << fval[2] << " " << fval[3];
			break;
		case TEXGENiv:
			glGetTexGeniv(GL_Q, key, ival); ival[3] = ival[0];
			glGetTexGeniv(GL_R, key, ival); ival[2] = ival[0];
			glGetTexGeniv(GL_T, key, ival); ival[1] = ival[0];
			glGetTexGeniv(GL_S, key, ival);
			os << "GL state: " << id << " " << ival[0] << " " << ival[1] << " " << ival[2] << " " << ival[3];
			break;
	}
	m_StateLog.push_back(os.str());
}
Пример #6
0
// Debug utility: validate the current texture environment against MBX errata.
// Assert if we use a state combination not supported by the MBX hardware.
void validateTexEnv(void)
{
	#if DEBUG
	typedef struct {
		GLint combine;
		GLint src[3];
		GLint op[3];
		GLint scale;
	} Channel;

	typedef struct {
		GLint enabled;
		GLint binding;
		GLint mode;
		Channel rgb;
		Channel a;
		GLfloat color[4];
	} TexEnv;

	// MBX supports two texture units
	TexEnv unit[2];
	GLint active;
	int i, prev = -1;

	glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
	for (i = 0; i < 2; i++)
	{
		glActiveTexture(GL_TEXTURE0+i);
		unit[i].enabled = glIsEnabled(GL_TEXTURE_2D);
		glGetIntegerv(GL_TEXTURE_BINDING_2D, &unit[i].binding);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,  &unit[i].mode);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_COMBINE_RGB,       &unit[i].rgb.combine);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC0_RGB,          &unit[i].rgb.src[0]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC1_RGB,          &unit[i].rgb.src[1]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC2_RGB,          &unit[i].rgb.src[2]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND0_RGB,      &unit[i].rgb.op[0]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND1_RGB,      &unit[i].rgb.op[1]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND2_RGB,      &unit[i].rgb.op[2]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_RGB_SCALE,         &unit[i].rgb.scale);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,     &unit[i].a.combine);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC0_ALPHA,        &unit[i].a.src[0]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC1_ALPHA,        &unit[i].a.src[1]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC2_ALPHA,        &unit[i].a.src[2]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,    &unit[i].a.op[0]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,    &unit[i].a.op[1]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,    &unit[i].a.op[2]);
		glGetTexEnviv(GL_TEXTURE_ENV, GL_ALPHA_SCALE,       &unit[i].a.scale);
		glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &unit[i].color[0]);

		if (unit[i].enabled == 0) continue;
		if (unit[i].mode != GL_COMBINE) continue;

		// PREVIOUS on unit 0 means PRIMARY_COLOR.
		if (i == 0)
		{
			int j;

			for (j = 0; j < 3; j++)
			{
				if (unit[i].rgb.src[j] == GL_PREVIOUS)
					unit[i].rgb.src[j] = GL_PRIMARY_COLOR;
				if (unit[i].a.src[j] == GL_PREVIOUS)
					unit[i].a.src[j] = GL_PRIMARY_COLOR;
			}
		}

		// If the value of COMBINE_RGB is MODULATE, only one of the two multiplicands can use an ALPHA operand.
		rt_assert(!(unit[i].rgb.combine == GL_MODULATE &&
		           (unit[i].rgb.op[0] == GL_SRC_ALPHA || unit[i].rgb.op[0] == GL_ONE_MINUS_SRC_ALPHA) &&
		           (unit[i].rgb.op[1] == GL_SRC_ALPHA || unit[i].rgb.op[1] == GL_ONE_MINUS_SRC_ALPHA)));

		// If the value of COMBINE_RGB is INTERPOLATE and either SRC0 or SRC1 uses an ALPHA operand, SRC2 can not be CONSTANT or PRIMARY_COLOR or use an ALPHA operand.
		rt_assert(!(unit[i].rgb.combine == GL_INTERPOLATE &&
		           (unit[i].rgb.op[0] == GL_SRC_ALPHA || unit[i].rgb.op[0] == GL_ONE_MINUS_SRC_ALPHA ||
		            unit[i].rgb.op[1] == GL_SRC_ALPHA || unit[i].rgb.op[1] == GL_ONE_MINUS_SRC_ALPHA) &&
		           (unit[i].rgb.op[2] == GL_SRC_ALPHA || unit[i].rgb.op[2] == GL_ONE_MINUS_SRC_ALPHA ||
		            unit[i].rgb.src[2] == GL_CONSTANT || unit[i].rgb.src[2] == GL_PRIMARY_COLOR)));

		// If the value of COMBINE_RGB is INTERPOLATE and SRC0 and SRC1 are CONSTANT or PRIMARY COLOR, SRC2 can not be CONSTANT or PRIMARY_COLOR or use an ALPHA operand.
		rt_assert(!(unit[i].rgb.combine == GL_INTERPOLATE &&
		          ((unit[i].rgb.src[0] == GL_CONSTANT      && unit[i].rgb.src[1] == GL_CONSTANT) ||
		           (unit[i].rgb.src[0] == GL_PRIMARY_COLOR && unit[i].rgb.src[1] == GL_PRIMARY_COLOR)) &&
		           (unit[i].rgb.op[2] == GL_SRC_ALPHA || unit[i].rgb.op[2] == GL_ONE_MINUS_SRC_ALPHA ||
		            unit[i].rgb.src[2] == GL_CONSTANT || unit[i].rgb.src[2] == GL_PRIMARY_COLOR)));

		// If the value of COMBINE_RGB is DOT3_RGB or DOT3_RGBA, only one of the sources can be PRIMARY_COLOR or use an ALPHA operand.
		rt_assert(!((unit[i].rgb.combine == GL_DOT3_RGB || unit[i].rgb.combine == GL_DOT3_RGBA) &&
		            (unit[i].rgb.src[0] == GL_PRIMARY_COLOR || unit[i].rgb.op[0] == GL_SRC_ALPHA || unit[i].rgb.op[0] == GL_ONE_MINUS_SRC_ALPHA) &&
		            (unit[i].rgb.src[1] == GL_PRIMARY_COLOR || unit[i].rgb.op[1] == GL_SRC_ALPHA || unit[i].rgb.op[1] == GL_ONE_MINUS_SRC_ALPHA)));

		// If the value of COMBINE_RGB is SUBTRACT, SCALE_RGB must be 1.0.
		rt_assert(!(unit[i].rgb.combine == GL_SUBTRACT && unit[i].rgb.scale != 1));

		if (unit[i].rgb.combine != GL_DOT3_RGBA)
		{
			// If the value of COMBINE_ALPHA is MODULATE or INTERPOLATE, only one of the two multiplicands can be CONSTANT.
			rt_assert(!(unit[i].a.combine == GL_MODULATE    &&  unit[i].a.src[0] == GL_CONSTANT && unit[i].a.src[1] == GL_CONSTANT));
			rt_assert(!(unit[i].a.combine == GL_INTERPOLATE && (unit[i].a.src[0] == GL_CONSTANT || unit[i].a.src[1] == GL_CONSTANT) && unit[i].a.src[2] == GL_CONSTANT));
	
			// If the value of COMBINE_ALPHA is SUBTRACT, SCALE_ALPHA must be 1.0.
			rt_assert(!(unit[i].a.combine == GL_SUBTRACT && unit[i].a.scale != 1));
		}
		
		// The value of TEXTURE_ENV_COLOR must be the same for all texture units that CONSTANT is used on.
		if (unit[i].rgb.src[0] == GL_CONSTANT ||
		   (unit[i].rgb.src[1] == GL_CONSTANT && unit[i].rgb.combine != GL_REPLACE) ||
		   (unit[i].rgb.src[2] == GL_CONSTANT && unit[i].rgb.combine == GL_INTERPOLATE) ||
		   (unit[i].rgb.combine != GL_DOT3_RGBA &&
		   (unit[i].a.src[0] == GL_CONSTANT ||
		   (unit[i].a.src[1] == GL_CONSTANT && unit[i].a.combine != GL_REPLACE) ||
		   (unit[i].a.src[2] == GL_CONSTANT && unit[i].a.combine == GL_INTERPOLATE))))
		{
			if (prev >= 0)
				rt_assert(!(unit[prev].color[0] != unit[i].color[0] ||
							unit[prev].color[1] != unit[i].color[1] ||
							unit[prev].color[2] != unit[i].color[2] ||
							unit[prev].color[3] != unit[i].color[3]));
			prev = i;
		}
	}

	glActiveTexture(active);
	glCheckError();
	#endif /* DEBUG */
}
Пример #7
0
/**
 * @brief Dumps OpenGL state for debugging - typically every capability set with glEnable().
 */
void R_DumpOpenGlState (void)
{
#define CAPABILITY( X ) {GL_ ## X, # X}
	/* List taken from here: http://www.khronos.org/opengles/sdk/1.1/docs/man/glIsEnabled.xml */
	const struct { GLenum idx; const char * text; } openGLCaps[] = {
		CAPABILITY(ALPHA_TEST),
		CAPABILITY(BLEND),
		CAPABILITY(COLOR_ARRAY),
		CAPABILITY(COLOR_LOGIC_OP),
		CAPABILITY(COLOR_MATERIAL),
		CAPABILITY(CULL_FACE),
		CAPABILITY(DEPTH_TEST),
		CAPABILITY(DITHER),
		CAPABILITY(FOG),
		CAPABILITY(LIGHTING),
		CAPABILITY(LINE_SMOOTH),
		CAPABILITY(MULTISAMPLE),
		CAPABILITY(NORMAL_ARRAY),
		CAPABILITY(NORMALIZE),
		CAPABILITY(POINT_SMOOTH),
		CAPABILITY(POLYGON_OFFSET_FILL),
		CAPABILITY(RESCALE_NORMAL),
		CAPABILITY(SAMPLE_ALPHA_TO_COVERAGE),
		CAPABILITY(SAMPLE_ALPHA_TO_ONE),
		CAPABILITY(SAMPLE_COVERAGE),
		CAPABILITY(SCISSOR_TEST),
		CAPABILITY(STENCIL_TEST),
		CAPABILITY(VERTEX_ARRAY)
	};
#undef CAPABILITY

	char s[1024] = "";
	GLint i;
	GLint maxTexUnits = 0;
	GLint activeTexUnit = 0;
	GLint activeClientTexUnit = 0;
	GLint activeTexId = 0;
	GLfloat texEnvMode = 0;
	const char * texEnvModeStr = "UNKNOWN";
	GLfloat color[4];

	for (i = 0; i < sizeof(openGLCaps)/sizeof(openGLCaps[0]); i++) {
		if (glIsEnabled(openGLCaps[i].idx)) {
			Q_strcat(s, sizeof(s), openGLCaps[i].text);
			Q_strcat(s, sizeof(s), " ");
		}
	}
	glGetFloatv(GL_CURRENT_COLOR, color);

	Com_Printf("OpenGL enabled caps: %s color %f %f %f %f \n", s, color[0], color[1], color[2], color[3]);

	glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexUnit);
	glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &activeClientTexUnit);

	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTexUnits);
	for (i = GL_TEXTURE0; i < GL_TEXTURE0 + maxTexUnits; i++) {
		glActiveTexture(i);
		glClientActiveTexture(i);

		strcpy(s, "");
		if (glIsEnabled (GL_TEXTURE_2D))
			strcat(s, "enabled, ");
		if (glIsEnabled (GL_TEXTURE_COORD_ARRAY))
			strcat(s, "with texcoord array, ");
		if (i == activeTexUnit)
			strcat(s, "active, ");
		if (i == activeClientTexUnit)
			strcat(s, "client active, ");

		glGetIntegerv(GL_TEXTURE_BINDING_2D, &activeTexId);
		glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvMode);
		if (fabs(texEnvMode - GL_ADD) < 0.1f)
			texEnvModeStr = "ADD";
		if (fabs(texEnvMode - GL_MODULATE) < 0.1f)
			texEnvModeStr = "MODULATE";
		if (fabs(texEnvMode - GL_DECAL) < 0.1f)
			texEnvModeStr = "DECAL";
		if (fabs(texEnvMode - GL_BLEND) < 0.1f)
			texEnvModeStr = "BLEND";
		if (fabs(texEnvMode - GL_REPLACE) < 0.1f)
			texEnvModeStr = "REPLACE";
		if (fabs(texEnvMode - GL_COMBINE) < 0.1f)
			texEnvModeStr = "COMBINE";

		Com_Printf("Texunit: %d texID %d %s texEnv mode %s\n", i - GL_TEXTURE0, activeTexId, s, texEnvModeStr);
	}

	glActiveTexture(activeTexUnit);
	glClientActiveTexture(activeClientTexUnit);
}
void glGetTexEnvfvLogged(GLenum env, GLenum pname, GLfloat *params) {
	printf("glGetTexEnvfv(%s, %s, %p)\n", GLEnumName(env), GLEnumName(pname), params);
	glGetTexEnvfv(env, pname, params);
}
Пример #9
0
M(void, glGetTexEnvfv, jint target, jint pname, jobject params) {
	glGetTexEnvfv(target, pname, BUFF(GLfloat, params));
}
Пример #10
0
void _glGetTexEnvfv( int target,int pname,Array<Float> params,int offset ) {
    glGetTexEnvfv( target,pname,&params[offset] );
}
Пример #11
0
void gl4es_glGetMultiTexEnvfv(GLenum texunit, GLenum target, GLenum pname, GLfloat *params) {
    text(glGetTexEnvfv(target, pname, params));
}