void rect(const unsigned texture,
		  const vec2& v0,
		  const vec2& v1,
		  const vec2& vt0,
		  const vec2& vt1)
{
	if(!glIsTexture(texture))
		return;

	const BindTexture2D bind(texture);
	GLint old_state(0);
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &old_state);

	if(old_state != GL_MODULATE)
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	vec2 vp[4] = {v0, vec2(v1.x, v0.y), vec2(v0.x, v1.y), v1};
	vec2 vtp[4] = {vt0, vec2(vt1.x, vt0.y), vec2(vt0.x, vt1.y), vt1};

	glTexCoordPointer(2, GL_FLOAT, 0, vtp);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glVertexPointer(2, GL_FLOAT, 0, vp);
	glEnableClientState(GL_VERTEX_ARRAY);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	if(old_state != GL_MODULATE)
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, old_state);
}
Exemple #2
0
void StartTextureEffect(uint8 effect)
{
    glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &envMode);
    glGetTexEnviv(GL_TEXTURE_ENV, GL_COMBINE_RGB, &combineRGB);
    glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC0_RGB, &src0RGB);
    glGetTexEnviv(GL_TEXTURE_ENV, GL_SRC1_RGB, &src1RGB);

    if (effect == HDGL_EFFECT_DOUBLE_INTENSITY)
    {
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
        glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
        glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
        glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
        glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
    }
}
Exemple #3
0
void arglDispImage(ARUint8 *image, const ARParam *cparam, const double zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings)
{
	GLint texEnvModeSave;	
	GLboolean lightingSave;
	GLboolean depthTestSave;
#ifdef ARGL_DEBUG
	GLenum			err;
	const GLubyte	*errs;
#endif // ARGL_DEBUG

	if (!image) return;

	// Prepare an orthographic projection, set camera position for 2D drawing, and save GL state.
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvModeSave); // Save GL texture environment mode.
	if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	lightingSave = glIsEnabled(GL_LIGHTING);			// Save enabled state of lighting.
	if (lightingSave == GL_TRUE) glDisable(GL_LIGHTING);
	depthTestSave = glIsEnabled(GL_DEPTH_TEST);		// Save enabled state of depth test.
	if (depthTestSave == GL_TRUE) glDisable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, cparam->xsize, 0, cparam->ysize);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();		
	
	if (arDebug) { // Globals from ar.h: arDebug, arImage, arImageProcMode.
		if (arImage) {
			if (arImageProcMode == AR_IMAGE_PROC_IN_HALF) {
				ARParam cparamScaled = *cparam;
				cparamScaled.xsize /= 2;
				cparamScaled.ysize /= 2;
				arglDispImageStateful(arImage, &cparamScaled, zoom * 2.0, contextSettings);
			} else {
				arglDispImageStateful(arImage, cparam, zoom, contextSettings);
			}
		}
	} else {
		arglDispImageStateful(image, cparam, zoom, contextSettings);
	}

	// Restore previous projection, camera position, and GL state.
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	if (depthTestSave == GL_TRUE) glEnable(GL_DEPTH_TEST);			// Restore enabled state of depth test.
	if (lightingSave == GL_TRUE) glEnable(GL_LIGHTING);			// Restore enabled state of lighting.
	if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnvModeSave); // Restore GL texture environment mode.
	
#ifdef ARGL_DEBUG
	// Report any errors we generated.
	while ((err = glGetError()) != GL_NO_ERROR) {
		errs = gluErrorString(err);	// fetch error code
		fprintf(stderr, "GL error: %s (%i)\n", errs, (int)err);	// write err code and number to stderr
	}
#endif // ARGL_DEBUG
	
}
			void	saveOpenGLState(int screenWidth, int screenHeight)
			{
				glPushAttrib(GL_ALL_ATTRIB_BITS);
				glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);

				glMatrixMode(GL_TEXTURE);
				glPushMatrix();
				glLoadIdentity();
				glMatrixMode(GL_MODELVIEW);
				glPushMatrix();
				glLoadIdentity();
				glMatrixMode(GL_PROJECTION);
				glPushMatrix();
				GLint Vp[4];
				glGetIntegerv(GL_VIEWPORT, Vp);
				if (screenWidth>0 && screenHeight>0)
				{
					Vp[0] = 0;
					Vp[1] = 0;
					Vp[2] = screenWidth-1;
					Vp[3] = screenHeight-1;
					glViewport(Vp[0], Vp[1], Vp[2], Vp[3]);
				}
				glLoadIdentity();
				glOrtho(Vp[0], Vp[0]+Vp[2], Vp[1]+Vp[3], Vp[1], -1, 1);
				glGetIntegerv(GL_VIEWPORT, m_ViewportInit);
				glGetFloatv(GL_PROJECTION_MATRIX, m_ProjMatrixInit);

				glGetFloatv(GL_LINE_WIDTH, &m_PrevLineWidth);
			 //   glDisable(GL_POLYGON_STIPPLE);
				glLineWidth(1);

				glGetBooleanv(GL_TEXTURE_GEN_S,&m_texGenS);
				glGetBooleanv(GL_TEXTURE_GEN_T,&m_texGenT);
				glGetBooleanv(GL_TEXTURE_GEN_R,&m_texGenR);

				glDisable(GL_TEXTURE_GEN_S);
				glDisable(GL_TEXTURE_GEN_T);
				glDisable(GL_TEXTURE_GEN_R);

				glDisable(GL_LINE_SMOOTH);
			//    glDisable(GL_LINE_STIPPLE);
				glDisable(GL_CULL_FACE);
				glDisable(GL_DEPTH_TEST);
				glDisable(GL_LIGHTING);
				glEnable(GL_BLEND);

				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &m_PrevTexEnv);
				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
				glDisable(GL_TEXTURE_2D);

			}
	// overriding draw method
	void CCQuadParticleSystem::draw()
	{	
		// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
		// Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
		// Unneeded states: -
		glBindTexture(GL_TEXTURE_2D, m_pTexture->getName());

		glBindBuffer(GL_ARRAY_BUFFER, m_uQuadsID);

#define kPointSize sizeof(m_pQuads[0].bl)
		glVertexPointer(2,GL_FLOAT, kPointSize, 0);

		glColorPointer(4, GL_FLOAT, kPointSize, (GLvoid*) offsetof(ccV2F_C4F_T2F,colors) );

		glTexCoordPointer(2, GL_FLOAT, kPointSize, (GLvoid*) offsetof(ccV2F_C4F_T2F,texCoords) );


		bool newBlend = false;
		if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST ) 
		{
			newBlend = true;
			glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
		}

		// save color mode
#if 0
		glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &colorMode);
		if( colorModulate )
			glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
		else
			glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
#endif

		if( m_nParticleIdx != m_nParticleCount ) 
		{
			CCLOG("pd:%d, pc:%d", m_nParticleIdx, m_nParticleCount);
		}
		glDrawElements(GL_TRIANGLES, m_nParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices);	

		// restore blend state
		if( newBlend )
			glBlendFunc( CC_BLEND_SRC, CC_BLEND_DST );

#if 0
		// restore color mode
		glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, colorMode);
#endif

		glBindBuffer(GL_ARRAY_BUFFER, 0);

		// restore GL default state
		// -
	}
	/**
	 * GLNyARRaster_RGBをバックグラウンドに書き出す。
	 * @param image
	 * @param zoom
	 */
	void NyARGLUtil::drawBackGround(const NyARToolkitCPP::INyARRgbRaster& i_raster, double i_zoom)
	{
		GLboolean lightingSave;
		GLboolean depthTestSave;
		GLint texEnvModeSave;
		const NyARToolkitCPP::TNyARIntSize& rsize=i_raster.getSize();

		// Prepare an orthographic projection, set camera position for 2D drawing, and save GL state.
		glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,&texEnvModeSave); // Save GL texture environment mode.
		if (texEnvModeSave != GL_REPLACE) {
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
		}
		lightingSave = glIsEnabled(GL_LIGHTING); // Save enabled state of lighting.
		if (lightingSave == GL_TRUE) {
			glDisable(GL_LIGHTING);
		}
		depthTestSave = glIsEnabled(GL_DEPTH_TEST); // Save enabled state of depth test.
		if (depthTestSave == GL_TRUE) {
			glDisable(GL_DEPTH_TEST);
		}
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();
		gluOrtho2D(0.0,rsize.w, 0.0,rsize.h);
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glLoadIdentity();
		arglDispImageStateful(i_raster, i_zoom);

		// Restore previous projection, camera position, and GL state.
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();
		if (depthTestSave) {
			glEnable(GL_DEPTH_TEST); // Restore enabled state of depth test.
		}
		if (lightingSave) {
			glEnable(GL_LIGHTING); // Restore enabled state of lighting.
		}
		if (texEnvModeSave != GL_REPLACE) {
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,texEnvModeSave); // Restore GL texture environment mode.
		}
		glEnd();
	}
Exemple #7
0
int __glXDisp_GetTexEnviv(__GLXclientState *cl, GLbyte *pc)
{
	GLenum pname;
	GLint compsize;
	__GLXcontext *cx;
	ClientPtr client = cl->client;
	int error;
	GLint 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 = __glGetTexEnviv_size(pname);
	if (compsize < 0) compsize = 0;

	__GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4);
	__glXClearErrorOccured();
	glGetTexEnviv( 
		*(GLenum   *)(pc + 0),
		*(GLenum   *)(pc + 4),
		(GLint    *) 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_INT();
	    __GLX_SEND_HEADER();
	} else {
	    __GLX_BEGIN_REPLY(compsize*4);
	    __GLX_PUT_SIZE(compsize);
	    __GLX_SEND_HEADER();
	    __GLX_SEND_INT_ARRAY(compsize);
	}
	return Success;
}
Exemple #8
0
static void
clutter_md2_data_save_state (ClutterMD2DataState *state)
{
  state->depth_test      = glIsEnabled (GL_DEPTH_TEST) ? TRUE : FALSE;
  state->blend           = glIsEnabled (GL_BLEND) ? TRUE : FALSE;
  state->texture_2d      = glIsEnabled (GL_TEXTURE_2D) ? TRUE : FALSE;
#ifdef GL_TEXTURE_RECTANGLE_ARB
  state->rectangle       = glIsEnabled (GL_TEXTURE_RECTANGLE_ARB)
    ? TRUE : FALSE;
#endif
  state->tex_coord_array = glIsEnabled (GL_TEXTURE_COORD_ARRAY) ? TRUE : FALSE;
  state->normal_array    = glIsEnabled (GL_NORMAL_ARRAY) ? TRUE : FALSE;
  state->vertex_array    = glIsEnabled (GL_VERTEX_ARRAY) ? TRUE : FALSE;
  state->color_array     = glIsEnabled (GL_COLOR_ARRAY) ? TRUE : FALSE;

  glGetIntegerv (GL_DEPTH_FUNC, &state->depth_func);
  glGetIntegerv (GL_TEXTURE_BINDING_2D, &state->texture_num);
  glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &state->tex_env_mode);
}
Exemple #9
0
static void blf_draw_gl__start(FontBLF *font, GLint *mode, GLint *param)
{
	/*
	 * The pixmap alignment hack is handle
	 * in BLF_position (old ui_rasterpos_safe).
	 */

	glEnable(GL_BLEND);
	glEnable(GL_TEXTURE_2D);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	/* Save the current matrix mode. */
	glGetIntegerv(GL_MATRIX_MODE, mode);

	glMatrixMode(GL_TEXTURE);
	glPushMatrix();
	glLoadIdentity();

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	if (font->flags & BLF_MATRIX)
		glMultMatrixd((GLdouble *)&font->m);

	glTranslate3fv(font->pos);

	if (font->flags & BLF_ASPECT)
		glScalef(font->aspect[0], font->aspect[1], font->aspect[2]);

	if (font->flags & BLF_ROTATION)  /* radians -> degrees */
		glRotatef(font->angle * (float)(180.0 / M_PI), 0.0f, 0.0f, 1.0f);

	if (font->shadow || font->blur)
		glGetFloatv(GL_CURRENT_COLOR, font->orig_col);

	/* always bind the texture for the first glyph */
	font->tex_bind_state = -1;

	/* Save the current parameter to restore it later. */
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
	if (*param != GL_MODULATE)
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
Exemple #10
0
static JSBool
AfxGlobal_modReplaceOnGlBegin(JSContext *cx, unsigned argc, JS::Value *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
	if(1 > args.length())
		return JS_FALSE;

	GLint newTextureBinding2d;

	if(!JS::ToInt32(cx, args[0], &newTextureBinding2d))
		return JS_FALSE;

	GLint oldActiveTextureArb;
	GLboolean oldTexture2d;
	GLint oldTextureBinding2d;
	GLint oldTextureEnvMode;
	
	glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &oldActiveTextureArb);

	glActiveTextureARB(GL_TEXTURE2_ARB);

	oldTexture2d = glIsEnabled(GL_TEXTURE_2D);
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTextureBinding2d);
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldTextureEnvMode);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, newTextureBinding2d);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	
	jsval jsOldVals[4] = { JS_NumberValue(oldActiveTextureArb), BOOLEAN_TO_JSVAL(oldTexture2d), JS_NumberValue(oldTextureBinding2d), JS_NumberValue(oldTextureEnvMode) };

	JSObject * retObj = JS_NewArrayObject(cx, 4, jsOldVals);

	if(!retObj)
		return JS_FALSE;

	args.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Exemple #11
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());
}
void
display(void)
{
    float t = glutGet( GLUT_ELAPSED_TIME );

    win->frameInit();

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    Matrix m;
    Quaternion q;
    q.setValueAsAxisDeg( 0,1,0, -t/20 );
    m.setRotate( q );
    tchunk1->setMatrix( m );

    tchunk1->activate( dact );
    mchunk1->activate( dact );
    pchunk1->activate( dact );
    lichunk1->activate( dact );

    glCallList( dlid );

    m.setIdentity();
    m.setTranslate( cos(t/1000), 0, sin(t/1000) );
    tchunk2->setMatrix( m );


    pchunk2->changeFrom( dact, get_pointer(pchunk1) );
    tchunk2->changeFrom( dact, get_pointer(tchunk1) );
    mchunk2->changeFrom( dact, get_pointer(mchunk1) );
    lichunk2->changeFrom( dact, get_pointer(lichunk1) );
    blchunk->activate( dact );

    glCallList( dlid );

    tchunk2->deactivate( dact );
    mchunk2->deactivate( dact );
    pchunk2->deactivate( dact );
    lichunk2->deactivate( dact );
    blchunk->deactivate( dact );


    xchunk1->activate( dact );
    txchunk->activate( dact );

#if 0
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_PASS_THROUGH_NV);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV,34102
);
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_SCALE_NV, 0.0000 );
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_BIAS_NV, 0.0000 );

glEnable(GL_TEXTURE_SHADER_NV);
GLint consistent;
glGetTexEnviv(GL_TEXTURE_SHADER_NV, GL_SHADER_CONSISTENT_NV,
      &consistent);
if(!consistent)
{
    FWARNING(("Texture shaders not consistent!\n"));
}
#endif
   
    glCallList( dlid2 );

// glDisable(GL_TEXTURE_SHADER_NV);
    xchunk1->deactivate( dact );
    txchunk->deactivate( dact );

    win->frameExit();

    glutSwapBuffers();
}
Exemple #13
0
void gl4es_glGetMultiTexEnviv(GLenum texunit, GLenum target, GLenum pname, GLint *params) {
    text(glGetTexEnviv(target, pname, params));
}
Exemple #14
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 */
}
void glGetTexEnvivLogged(GLenum env, GLenum pname, GLint *params) {
	printf("glGetTexEnviv(%s, %s, %p)\n", GLEnumName(env), GLEnumName(pname), params);
	glGetTexEnviv(env, pname, params);
}
Exemple #16
0
void arglDispImage(ARUint8 *image, const ARParam *cparam, const double zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings)
{
	GLint texEnvModeSave;	
	GLboolean lightingSave;
	GLboolean depthTestSave;
#if ARGL_SUPPORT_DEBUG_MODE
    int arDebugMode = AR_DEBUG_DISABLE, arImageProcMode;
#endif // ARGL_SUPPORT_DEBUG_MODE
#ifdef ARGL_DEBUG
	GLenum			err;
	const GLubyte	*errs;
#endif // ARGL_DEBUG

	if (!image || !cparam) return;

	// Prepare an orthographic projection, set camera position for 2D drawing, and save GL state.
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvModeSave); // Save GL texture environment mode.
	if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	lightingSave = glIsEnabled(GL_LIGHTING);			// Save enabled state of lighting.
	if (lightingSave == GL_TRUE) glDisable(GL_LIGHTING);
	depthTestSave = glIsEnabled(GL_DEPTH_TEST);		// Save enabled state of depth test.
	if (depthTestSave == GL_TRUE) glDisable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, cparam->xsize, 0, cparam->ysize, -1.0, 1.0);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();		
	
#if ARGL_SUPPORT_DEBUG_MODE
	if (contextSettings->arhandle) arGetDebugMode(contextSettings->arhandle, &arDebugMode);
	if (arDebugMode == AR_DEBUG_ENABLE) {
		if (contextSettings->arhandle->labelInfo.bwImage) {
			arGetImageProcMode(contextSettings->arhandle, &arImageProcMode);
			if (arImageProcMode == AR_IMAGE_PROC_FIELD_IMAGE) {
				ARParam cparamScaled = *cparam;
				cparamScaled.xsize /= 2;
				cparamScaled.ysize /= 2;
				arglDispImageStateful(contextSettings->arhandle->labelInfo.bwImage, &cparamScaled, zoom * 2.0, contextSettings);
			} else {
				arglDispImageStateful(contextSettings->arhandle->labelInfo.bwImage, cparam, zoom, contextSettings);
			}
		}
	} else {
#endif // ARGL_SUPPORT_DEBUG_MODE
		arglDispImageStateful(image, cparam, zoom, contextSettings);
#if ARGL_SUPPORT_DEBUG_MODE
	}
#endif // ARGL_SUPPORT_DEBUG_MODE

	// Restore previous projection, camera position, and GL state.
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	if (depthTestSave == GL_TRUE) glEnable(GL_DEPTH_TEST);			// Restore enabled state of depth test.
	if (lightingSave == GL_TRUE) glEnable(GL_LIGHTING);			// Restore enabled state of lighting.
	if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnvModeSave); // Restore GL texture environment mode.
	
#ifdef ARGL_DEBUG
	// Report any errors we generated.
	while ((err = glGetError()) != GL_NO_ERROR) {
		errs = gluErrorString(err);	// fetch error code
		ARLOGe("GL error: %s (0x%04X)\n", errs, (int)err);	// write err code and number to stderr
	}
#endif // ARGL_DEBUG
	
}
Exemple #17
0
void _glGetTexEnviv( int target,int pname,Array<int> params,int offset ) {
    glGetTexEnviv( target,pname,&params[offset] );
}
Exemple #18
0
M(void, glGetTexEnviv, jint target, jint pname, jobject params) {
	glGetTexEnviv(target, pname, BUFF(GLint, params));
}