• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GL_Bind函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GL_Bind函数的典型用法代码示例。如果您正苦于以下问题:C++ GL_Bind函数的具体用法?C++ GL_Bind怎么用?C++ GL_Bind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GL_Bind函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: R_DrawAliasModel


//.........这里部分代码省略.........
				shadelight += add;
			}
		}
	}

	// clamp lighting so it doesn't overbright as much
	if (ambientlight > 128)
		ambientlight = 128;
	if (ambientlight + shadelight > 192)
		shadelight = 192 - ambientlight;

	// ZOID: never allow players to go totally black
	i = currententity - cl_entities;
	if (i >= 1 && i<=cl.maxclients /* && !strcmp (currententity->model->name, "progs/player.mdl") */)
		if (ambientlight < 8)
			ambientlight = shadelight = 8;

	// HACK HACK HACK -- no fullbright colors, so make torches full light
	if (!strcmp (clmodel->name, "progs/flame2.mdl")
		|| !strcmp (clmodel->name, "progs/flame.mdl") )
		ambientlight = shadelight = 256;

	shadedots = r_avertexnormal_dots[((int)(e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
	shadelight = shadelight / 200.0;

	an = e->angles[1]/180*M_PI;
	shadevector[0] = cos(-an);
	shadevector[1] = sin(-an);
	shadevector[2] = 1;
	VectorNormalize (shadevector);

	//
	// locate the proper data
	//
	paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);

	c_alias_polys += paliashdr->numtris;

	//
	// draw all the triangles
	//

	GL_DisableMultitexture();

    glPushMatrix ();
	R_RotateForEntity (e);

	if (!strcmp (clmodel->name, "progs/eyes.mdl") && gl_doubleeyes.value) {
		glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2] - (22 + 8));
// double size of eyes, since they are really hard to see in gl
		glScalef (paliashdr->scale[0]*2, paliashdr->scale[1]*2, paliashdr->scale[2]*2);
	} else {
		glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]);
		glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]);
	}

	anim = (int)(cl.time*10) & 3;
    GL_Bind(paliashdr->gl_texturenum[currententity->skinnum][anim]);

	// we can't dynamically colormap textures, so they are cached
	// seperately for the players.  Heads are just uncolored.
	if (currententity->colormap != vid.colormap && !gl_nocolors.value)
	{
		i = currententity - cl_entities;
		if (i >= 1 && i<=cl.maxclients /* && !strcmp (currententity->model->name, "progs/player.mdl") */)
		    GL_Bind(playertextures - 1 + i);
	}

	if (gl_smoothmodels.value)
		glShadeModel (GL_SMOOTH);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	if (gl_affinemodels.value)
		glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);

	R_SetupAliasFrame (currententity->frame, paliashdr);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glShadeModel (GL_FLAT);
	if (gl_affinemodels.value)
		glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glPopMatrix ();

	if (r_shadows.value)
	{
		glPushMatrix ();
		R_RotateForEntity (e);
		glDisable (GL_TEXTURE_2D);
		glEnable (GL_BLEND);
		glColor4f (0,0,0,0.5);
		GL_DrawAliasShadow (paliashdr, lastposenum);
		glEnable (GL_TEXTURE_2D);
		glDisable (GL_BLEND);
		glColor4f (1,1,1,1);
		glPopMatrix ();
	}

}
开发者ID:ACSOP,项目名称:android_external_quake,代码行数:101,代码来源:gl_rmain.cpp


示例2: R_DrawSpriteModel

/*
=================
R_DrawSpriteModel -- johnfitz -- rewritten: now supports all orientations
=================
*/
void R_DrawSpriteModel (entity_t *e)
{
	vec3_t			point, v_forward, v_right, v_up;
	msprite_t		*psprite;
	mspriteframe_t	*frame;
	float			*s_up, *s_right;
	float			angle, sr, cr;

	//TODO: frustum cull it?

	frame = R_GetSpriteFrame (e);
	psprite = (msprite_t *) currententity->model->cache.data;

	switch(psprite->type)
	{
	case SPR_VP_PARALLEL_UPRIGHT: //faces view plane, up is towards the heavens
		v_up[0] = 0;
		v_up[1] = 0;
		v_up[2] = 1;
		s_up = v_up;
		s_right = vright;
		break;
	case SPR_FACING_UPRIGHT: //faces camera origin, up is towards the heavens
		VectorSubtract(currententity->origin, r_origin, v_forward);
		v_forward[2] = 0;
		VectorNormalizeFast(v_forward);
		v_right[0] = v_forward[1];
		v_right[1] = -v_forward[0];
		v_right[2] = 0;
		v_up[0] = 0;
		v_up[1] = 0;
		v_up[2] = 1;
		s_up = v_up;
		s_right = v_right;
		break;
	case SPR_VP_PARALLEL: //faces view plane, up is towards the top of the screen
		s_up = vup;
		s_right = vright;
		break;
	case SPR_ORIENTED: //pitch yaw roll are independent of camera
		AngleVectors (currententity->angles, v_forward, v_right, v_up);
		s_up = v_up;
		s_right = v_right;
		break;
	case SPR_VP_PARALLEL_ORIENTED: //faces view plane, but obeys roll value
		angle = currententity->angles[ROLL] * M_PI_DIV_180;
		sr = sin(angle);
		cr = cos(angle);
		v_right[0] = vright[0] * cr + vup[0] * sr;
		v_right[1] = vright[1] * cr + vup[1] * sr;
		v_right[2] = vright[2] * cr + vup[2] * sr;
		v_up[0] = vright[0] * -sr + vup[0] * cr;
		v_up[1] = vright[1] * -sr + vup[1] * cr;
		v_up[2] = vright[2] * -sr + vup[2] * cr;
		s_up = v_up;
		s_right = v_right;
		break;
	default:
		return;
	}

	//johnfitz: offset decals
	if (psprite->type == SPR_ORIENTED)
		GL_PolygonOffset (OFFSET_DECAL);

	glColor3f (1,1,1);

	GL_DisableMultitexture();

	GL_Bind(frame->gltexture);

	glEnable (GL_ALPHA_TEST);
	glBegin (GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris

	glTexCoord2f (0, frame->tmax);
	VectorMA (e->origin, frame->down, s_up, point);
	VectorMA (point, frame->left, s_right, point);
	glVertex3fv (point);

	glTexCoord2f (0, 0);
	VectorMA (e->origin, frame->up, s_up, point);
	VectorMA (point, frame->left, s_right, point);
	glVertex3fv (point);

	glTexCoord2f (frame->smax, 0);
	VectorMA (e->origin, frame->up, s_up, point);
	VectorMA (point, frame->right, s_right, point);
	glVertex3fv (point);

	glTexCoord2f (frame->smax, frame->tmax);
	VectorMA (e->origin, frame->down, s_up, point);
	VectorMA (point, frame->right, s_right, point);
	glVertex3fv (point);

	glEnd ();
//.........这里部分代码省略.........
开发者ID:sakridge,项目名称:quakespasm-ml,代码行数:101,代码来源:r_sprite.c


示例3: GL_DrawQ3AliasFrame

//void GL_DrawQ3AliasFrame (md3header_mem_t *header, int lastpose, int pose, float blend, qboolean mtex)
void GL_DrawQ3AliasFrame (const md3header_t *header, const entity_t *e, int pose, float blend, qboolean mtex)
/*******JDH*******/
{
   int               i, j, k, index;
   int               frame;
   int               lastframe;
   int               vertframeoffset;
   int               lastvertframeoffset;
   float            /*alpha, */iblend;
   md3surface_t   *surf;
   md3st_t         *tc, *xycoord;
   md3tri_t      *tris;
   md3vert_t      *verts, *vertslast, *currvert, *lastvert;
   md3shader_t		*shaders;
//  vec3_t			currnorm, lastnorm;

	r_modelalpha = GL_GetAliasAlpha (e);

	if (r_modelalpha < 1.0)
		glEnable (GL_BLEND);

	blend = bound(0, blend, 1);
	iblend = 1.0 - blend;

	surf = (md3surface_t *)((byte *)header + header->surface_offs);

	for (i = 0; i < header->num_surfaces; i++)
	{
		if (surf->num_surf_frames == 0)
		{
			surf = (md3surface_t *)((byte *)surf + surf->end_offs);
			continue;   //shouldn't ever do this, each surface should have at least one frame
		}

		//get pointer to shaders (ie. textures)
		shaders = (md3shader_t *)((byte *)surf + surf->shader_offs);
		index = shaders[e->skinnum % surf->num_surf_shaders].index;

		GL_Bind (index);

		frame = pose % surf->num_surf_frames;   //cap the frame inside the list of frames in the model
		vertframeoffset = frame * surf->num_surf_verts * sizeof(md3vert_t);
		/*******JDH*******/
		//lastframe = lastpose%surf->num_surf_frames;
		lastframe = e->lastpose % surf->num_surf_frames;
		/*******JDH*******/
		lastvertframeoffset = lastframe*surf->num_surf_verts * sizeof(md3vert_t);

		tc = (md3st_t *)((byte *)surf + surf->tc_offs);
		tris = (md3tri_t *)((byte *)surf + surf->tris_offs);
		verts = (md3vert_t *)((byte *)surf + surf->vert_offs + vertframeoffset);
		vertslast = (md3vert_t *)((byte *)surf + surf->vert_offs + lastvertframeoffset);

		/*if (blend >=1)
		{
		//glNormalPointer(GL_FLOAT, 6 * sizeof(float), (float *)verts->normal);
		//glEnableClientState(GL_NORMAL_ARRAY);

		glVertexPointer(3, GL_SHORT, sizeof( md3vert_t ), verts->vec);
		glEnableClientState(GL_VERTEX_ARRAY);

		glTexCoordPointer(2, GL_FLOAT, 0, (float *)tc);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);

		glDrawElements(GL_TRIANGLES, surf->num_surf_tris*3, GL_UNSIGNED_INT, tris);

		//glDisableClientState(GL_NORMAL_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		}
		else*/
		{
		//interpolated

			glBegin(GL_TRIANGLES);
			//for each triangle
			for (j = 0; j < surf->num_surf_tris; j++)
			{
				//draw the poly
				for (k=0; k < 3; k++)
				{
					index = tris[j].tri[k];
					xycoord = &tc[index];

					if (mtex)
					{
						qglMultiTexCoord2f (GL_TEXTURE0_ARB, xycoord->s, xycoord->t);
						qglMultiTexCoord2f (GL_TEXTURE1_ARB, xycoord->s, xycoord->t);
					}
					else
					{
						glTexCoord2f (xycoord->s, xycoord->t);
					}

					currvert = &verts[index];
					lastvert = &vertslast[index];

					GL_SetupMD3Light (currvert, lastvert, r_modelalpha);

//.........这里部分代码省略.........
开发者ID:SpiritQuaddicted,项目名称:reQuiem,代码行数:101,代码来源:gl_md3.c


示例4: GL_State

void StencilShadow::RenderShadow()
{
#ifndef DISABLE_STENCILSHADOW
	DWORD lighting, fog, srcblend, destblend, alphablend, zwrite, zfunc, cullmode;

	GL_State(GLS_DEFAULT);

	glw_state->device->GetRenderState( D3DRS_LIGHTING, &lighting );
	glw_state->device->GetRenderState( D3DRS_FOGENABLE, &fog );
	glw_state->device->GetRenderState( D3DRS_SRCBLEND, &srcblend );
	glw_state->device->GetRenderState( D3DRS_DESTBLEND, &destblend );
	glw_state->device->GetRenderState( D3DRS_ALPHABLENDENABLE, &alphablend );
	glw_state->device->GetRenderState( D3DRS_ZWRITEENABLE, &zwrite );
	glw_state->device->GetRenderState( D3DRS_ZFUNC, &zfunc );
	glw_state->device->GetRenderState( D3DRS_CULLMODE, &cullmode );

	pVerts = NULL;
	pExtrusions = NULL;

	GL_Bind( tr.whiteImage );

	glw_state->device->SetRenderState( D3DRS_LIGHTING, FALSE );
	glw_state->device->SetRenderState( D3DRS_FOGENABLE, FALSE );

	glw_state->device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
	glw_state->device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );

    // Disable z-buffer writes (note: z-testing still occurs), and enable the
    // stencil-buffer
    glw_state->device->SetRenderState( D3DRS_ZWRITEENABLE,  FALSE );
    glw_state->device->SetRenderState( D3DRS_STENCILENABLE, TRUE );

    // Don't bother with interpolating color
    glw_state->device->SetRenderState( D3DRS_SHADEMODE,     D3DSHADE_FLAT );

	glw_state->device->SetRenderState( D3DRS_ZFUNC,			D3DCMP_LESS );

    // Set up stencil compare function, reference value, and masks.
    // Stencil test passes if ((ref & mask) cmpfn (stencil & mask)) is true.
    // Note: since we set up the stencil-test to always pass, the STENCILFAIL
    // renderstate is really not needed.
    glw_state->device->SetRenderState( D3DRS_STENCILFUNC,   D3DCMP_ALWAYS );
#ifdef _STENCIL_REVERSE
	glw_state->device->SetRenderState( D3DRS_STENCILZFAIL,  D3DSTENCILOP_INCR );
    glw_state->device->SetRenderState( D3DRS_STENCILFAIL,   D3DSTENCILOP_KEEP );
	glw_state->device->SetRenderState( D3DRS_STENCILPASS,   D3DSTENCILOP_KEEP );
#else
	glw_state->device->SetRenderState( D3DRS_STENCILZFAIL,  D3DSTENCILOP_KEEP );
    glw_state->device->SetRenderState( D3DRS_STENCILFAIL,   D3DSTENCILOP_KEEP );
	glw_state->device->SetRenderState( D3DRS_STENCILPASS,   D3DSTENCILOP_INCR );	
#endif

    // If ztest passes, inc/decrement stencil buffer value
    glw_state->device->SetRenderState( D3DRS_STENCILREF,       0x1 );
    glw_state->device->SetRenderState( D3DRS_STENCILMASK,      0x7f ); //0xffffffff );
    glw_state->device->SetRenderState( D3DRS_STENCILWRITEMASK, 0x7f ); //0xffffffff );

    // Make sure that no pixels get drawn to the frame buffer
    glw_state->device->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    glw_state->device->SetRenderState( D3DRS_COLORWRITEENABLE, 0 );

	glw_state->device->SetTexture(0, NULL);
	glw_state->device->SetTexture(1, NULL);

	// Compute the matrix set
    XGMATRIX matComposite, matProjectionViewport, matWorld;
	glw_state->device->GetProjectionViewportMatrix( &matProjectionViewport );

	XGMatrixMultiply( &matComposite, (XGMATRIX*)glw_state->matrixStack[glwstate_t::MatrixMode_Model]->GetTop(), &matProjectionViewport );

	// Transpose and set the composite matrix.
	XGMatrixTranspose( &matComposite, &matComposite );
	glw_state->device->SetVertexShaderConstant( CV_WORLDVIEWPROJ_0, &matComposite, 4 );

	// Set viewport offsets.
	float fViewportOffsets[4] = { 0.53125f, 0.53125f, 0.0f, 0.0f };
	glw_state->device->SetVertexShaderConstant( CV_VIEWPORT_OFFSETS, &fViewportOffsets, 1 );

	glw_state->device->SetVertexShader(m_dwVertexShaderShadow);

#ifdef _STENCIL_REVERSE
	qglCullFace( GL_FRONT );
#else
	qglCullFace( GL_BACK );
#endif

	BuildEdges();

	// Draw front-side of shadow volume in stencil/z only
	if(m_nIndexes)
        renderObject_Shadow( D3DPT_QUADLIST, m_nIndexes, m_shadowIndexes );
#ifdef _STENCIL_REVERSE
	if(m_nIndexesCap)
        renderObject_Shadow( D3DPT_TRIANGLELIST, m_nIndexesCap, m_shadowIndexesCap );
#endif

	// Now reverse cull order so back sides of shadow volume are written.
#ifdef _STENCIL_REVERSE
	qglCullFace( GL_BACK );
#else
//.........这里部分代码省略.........
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:101,代码来源:win_stencilshadow.cpp


示例5: R_Bloom_GeneratexCross

/*
=================
R_Bloom_GeneratexCross - alternative bluring method
=================
*/
void R_Bloom_GeneratexCross( void )
{
    int			i;
    static int		BLOOM_BLUR_RADIUS = 8;
    //static float	BLOOM_BLUR_INTENSITY = 2.5f;
    float	BLOOM_BLUR_INTENSITY;
    static float intensity;
    static float range;

    //set up sample size workspace
    qglViewport( 0, 0, sample_width, sample_height );
    qglMatrixMode( GL_PROJECTION );
    qglLoadIdentity ();
    qglOrtho(0, sample_width, sample_height, 0, -10, 100);
    qglMatrixMode( GL_MODELVIEW );
    qglLoadIdentity ();

    //copy small scene into r_bloomeffecttexture
    GL_Bind(0, r_bloomeffecttexture);
    qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

    //start modifying the small scene corner
    qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
    GL_Enable(GL_BLEND);

    //darkening passes
    if( r_bloom_darken->value )
    {
        GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
        GL_TexEnv(GL_MODULATE);

        for(i=0; i<r_bloom_darken->value ; i++) {
            R_Bloom_SamplePass( 0, 0 );
        }
        qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
    }

    //bluring passes
    if( BLOOM_BLUR_RADIUS ) {

        GL_BlendFunc(GL_ONE, GL_ONE);

        range = (float)BLOOM_BLUR_RADIUS;

        BLOOM_BLUR_INTENSITY = r_bloom_intensity->value;
        //diagonal-cross draw 4 passes to add initial smooth
        qglColor4f( 0.5f, 0.5f, 0.5f, 1.0);
        R_Bloom_SamplePass( 1, 1 );
        R_Bloom_SamplePass( -1, 1 );
        R_Bloom_SamplePass( -1, -1 );
        R_Bloom_SamplePass( 1, -1 );
        qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

        for(i=-(BLOOM_BLUR_RADIUS+1); i<BLOOM_BLUR_RADIUS; i++) {
            intensity = BLOOM_BLUR_INTENSITY/(range*2+1)*(1 - fabs(i*i)/(float)(range*range));
            if( intensity < 0.05f ) continue;
            qglColor4f( intensity, intensity, intensity, 1.0f);
            R_Bloom_SamplePass( i, 0 );
            //R_Bloom_SamplePass( -i, 0 );
        }

        qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

        //for(i=0;i<BLOOM_BLUR_RADIUS;i++) {
        for(i=-(BLOOM_BLUR_RADIUS+1); i<BLOOM_BLUR_RADIUS; i++) {
            intensity = BLOOM_BLUR_INTENSITY/(range*2+1)*(1 - fabs(i*i)/(float)(range*range));
            if( intensity < 0.05f ) continue;
            qglColor4f( intensity, intensity, intensity, 1.0f);
            R_Bloom_SamplePass( 0, i );
            //R_Bloom_SamplePass( 0, -i );
        }

        qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
    }

    //restore full screen workspace
    qglViewport( 0, 0, glState.width, glState.height );
    qglMatrixMode( GL_PROJECTION );
    qglLoadIdentity ();
    qglOrtho(0, glState.width, glState.height, 0, -10, 100);
    qglMatrixMode( GL_MODELVIEW );
    qglLoadIdentity ();
}
开发者ID:AimHere,项目名称:thirty-flights-of-linux,代码行数:88,代码来源:r_bloom.c


示例6: R_BloomBlend

void R_BloomBlend ( refdef_t *fd )
{
    if( !(fd->rdflags & RDF_BLOOM) || !r_bloom->value || r_showtris->value )
        return;

    if( !BLOOM_SIZE )
        R_Bloom_InitTextures();

    if( screen_texture_width < BLOOM_SIZE ||
            screen_texture_height < BLOOM_SIZE )
        return;

    //set up full screen workspace
    qglViewport ( 0, 0, vid.width, vid.height );
    GL_TexEnv (GL_REPLACE); // Knightmare added
    GL_Disable (GL_DEPTH_TEST);
    qglMatrixMode (GL_PROJECTION);
    qglLoadIdentity ();
    qglOrtho(0, vid.width, vid.height, 0, -10, 100);
    qglMatrixMode (GL_MODELVIEW);
    qglLoadIdentity ();
    GL_Disable (GL_CULL_FACE);

    GL_Disable (GL_BLEND);
    qglEnable (GL_TEXTURE_2D);

    qglColor4f (1, 1, 1, 1);

    //set up current sizes
    curView_x = fd->x;
    curView_y = fd->y;
    curView_width = fd->width;
    curView_height = fd->height;
    screenText_tcw = ((float)fd->width / (float)screen_texture_width);
    screenText_tch = ((float)fd->height / (float)screen_texture_height);
    if( fd->height > fd->width ) {
        sampleText_tcw = ((float)fd->width / (float)fd->height);
        sampleText_tch = 1.0f;
    } else {
        sampleText_tcw = 1.0f;
        sampleText_tch = ((float)fd->height / (float)fd->width);
    }
    sample_width = BLOOM_SIZE * sampleText_tcw;
    sample_height = BLOOM_SIZE * sampleText_tch;

    //copy the screen space we'll use to work into the backup texture
    GL_Bind(r_bloombackuptexture->texnum);
    qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_size * sampleText_tcw, r_screenbackuptexture_size * sampleText_tch);

    //create the bloom image
    R_Bloom_DownsampleView();
    R_Bloom_GeneratexDiamonds( fd );
    //R_Bloom_GeneratexCross();

    //restore the screen-backup to the screen
    GL_Disable(GL_BLEND);
    GL_Bind(r_bloombackuptexture->texnum);
    qglColor4f( 1, 1, 1, 1 );
    R_Bloom_Quad( 0,
                  vid.height - (r_screenbackuptexture_size * sampleText_tch),
                  r_screenbackuptexture_size * sampleText_tcw,
                  r_screenbackuptexture_size * sampleText_tch,
                  sampleText_tcw,
                  sampleText_tch );

    R_Bloom_DrawEffect( fd );

    // Knightmare added
    R_SetupGL ();
    GL_BlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    qglEnable (GL_TEXTURE_2D);
    qglColor4f(1,1,1,1);
}
开发者ID:AimHere,项目名称:thirty-flights-of-linux,代码行数:73,代码来源:r_bloom.c


示例7: ProjectDlightTexture_altivec


//.........这里部分代码省略.........
			vec_t dist0, dist1, dist2;
			
			dist0 = origin0 - tess.xyz[i][0];
			dist1 = origin1 - tess.xyz[i][1];
			dist2 = origin2 - tess.xyz[i][2];

			backEnd.pc.c_dlightVertexes++;

			texCoords0 = 0.5f + dist0 * scale;
			texCoords1 = 0.5f + dist1 * scale;

			if( !r_dlightBacks->integer &&
					// dist . tess.normal[i]
					( dist0 * tess.normal[i][0] +
					dist1 * tess.normal[i][1] +
					dist2 * tess.normal[i][2] ) < 0.0f ) {
				clip = 63;
			} else {
				if ( texCoords0 < 0.0f ) {
					clip |= 1;
				} else if ( texCoords0 > 1.0f ) {
					clip |= 2;
				}
				if ( texCoords1 < 0.0f ) {
					clip |= 4;
				} else if ( texCoords1 > 1.0f ) {
					clip |= 8;
				}
				texCoords[0] = texCoords0;
				texCoords[1] = texCoords1;

				// modulate the strength based on the height and color
				if ( dist2 > radius ) {
					clip |= 16;
					modulate = 0.0f;
				} else if ( dist2 < -radius ) {
					clip |= 32;
					modulate = 0.0f;
				} else {
					dist2 = Q_fabs(dist2);
					if ( dist2 < radius * 0.5f ) {
						modulate = 1.0f;
					} else {
						modulate = 2.0f * (radius - dist2) * scale;
					}
				}
			}
			clipBits[i] = clip;

			modulateVec = vec_ld(0,(float *)&modulate);
			modulateVec = vec_perm(modulateVec,modulateVec,modulatePerm);
			colorVec = vec_madd(floatColorVec0,modulateVec,zero);
			colorInt = vec_cts(colorVec,0);	// RGBx
			colorShort = vec_pack(colorInt,colorInt);		// RGBxRGBx
			colorChar = vec_packsu(colorShort,colorShort);	// RGBxRGBxRGBxRGBx
			colorChar = vec_sel(colorChar,vSel,vSel);		// RGBARGBARGBARGBA replace alpha with 255
			vec_ste((vector unsigned int)colorChar,0,(unsigned int *)colors);	// store color
		}

		// build a list of triangles that need light
		numIndexes = 0;
		for ( i = 0 ; i < tess.numIndexes ; i += 3 ) {
			int		a, b, c;

			a = tess.indexes[i];
			b = tess.indexes[i+1];
			c = tess.indexes[i+2];
			if ( clipBits[a] & clipBits[b] & clipBits[c] ) {
				continue;	// not lighted
			}
			hitIndexes[numIndexes] = a;
			hitIndexes[numIndexes+1] = b;
			hitIndexes[numIndexes+2] = c;
			numIndexes += 3;
		}

		if ( !numIndexes ) {
			continue;
		}

		qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
		qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );

		qglEnableClientState( GL_COLOR_ARRAY );
		qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );

		GL_Bind( tr.dlightImage );
		// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
		// where they aren't rendered
		if ( dl->additive ) {
			GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
		}
		else {
			GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
		}
		R_DrawElements( numIndexes, hitIndexes );
		backEnd.pc.c_totalIndexes += numIndexes;
		backEnd.pc.c_dlightIndexes += numIndexes;
	}
}
开发者ID:burzumishi,项目名称:dragonballworld,代码行数:101,代码来源:tr_shade.c


示例8: ProjectDlightTexture_scalar


//.........这里部分代码省略.........
			floatColor[0] = dl->color[0] * 255.0f;
			floatColor[1] = dl->color[1] * 255.0f;
			floatColor[2] = dl->color[2] * 255.0f;
		}

		for ( i = 0 ; i < tess.numVertexes ; i++, texCoords += 2, colors += 4 ) {
			int		clip = 0;
			vec3_t	dist;
			
			VectorSubtract( origin, tess.xyz[i], dist );

			backEnd.pc.c_dlightVertexes++;

			texCoords[0] = 0.5f + dist[0] * scale;
			texCoords[1] = 0.5f + dist[1] * scale;

			if( !r_dlightBacks->integer &&
					// dist . tess.normal[i]
					( dist[0] * tess.normal[i][0] +
					dist[1] * tess.normal[i][1] +
					dist[2] * tess.normal[i][2] ) < 0.0f ) {
				clip = 63;
			} else {
				if ( texCoords[0] < 0.0f ) {
					clip |= 1;
				} else if ( texCoords[0] > 1.0f ) {
					clip |= 2;
				}
				if ( texCoords[1] < 0.0f ) {
					clip |= 4;
				} else if ( texCoords[1] > 1.0f ) {
					clip |= 8;
				}
				texCoords[0] = texCoords[0];
				texCoords[1] = texCoords[1];

				// modulate the strength based on the height and color
				if ( dist[2] > radius ) {
					clip |= 16;
					modulate = 0.0f;
				} else if ( dist[2] < -radius ) {
					clip |= 32;
					modulate = 0.0f;
				} else {
					dist[2] = Q_fabs(dist[2]);
					if ( dist[2] < radius * 0.5f ) {
						modulate = 1.0f;
					} else {
						modulate = 2.0f * (radius - dist[2]) * scale;
					}
				}
			}
			clipBits[i] = clip;
			colors[0] = myftol(floatColor[0] * modulate);
			colors[1] = myftol(floatColor[1] * modulate);
			colors[2] = myftol(floatColor[2] * modulate);
			colors[3] = 255;
		}

		// build a list of triangles that need light
		numIndexes = 0;
		for ( i = 0 ; i < tess.numIndexes ; i += 3 ) {
			int		a, b, c;

			a = tess.indexes[i];
			b = tess.indexes[i+1];
			c = tess.indexes[i+2];
			if ( clipBits[a] & clipBits[b] & clipBits[c] ) {
				continue;	// not lighted
			}
			hitIndexes[numIndexes] = a;
			hitIndexes[numIndexes+1] = b;
			hitIndexes[numIndexes+2] = c;
			numIndexes += 3;
		}

		if ( !numIndexes ) {
			continue;
		}

		qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
		qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );

		qglEnableClientState( GL_COLOR_ARRAY );
		qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );

		GL_Bind( tr.dlightImage );
		// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
		// where they aren't rendered
		if ( dl->additive ) {
			GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
		}
		else {
			GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
		}
		R_DrawElements( numIndexes, hitIndexes );
		backEnd.pc.c_totalIndexes += numIndexes;
		backEnd.pc.c_dlightIndexes += numIndexes;
	}
}
开发者ID:burzumishi,项目名称:dragonballworld,代码行数:101,代码来源:tr_shade.c


示例9: ForwardDlight


//.........这里部分代码省略.........

			ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE);

			GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor);
			GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor);
		}

		if (pStage->alphaGen == AGEN_PORTAL)
		{
			GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange);
		}

		GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen);
		GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen);

		GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, dl->color);

		VectorSet(vector, 0, 0, 0);
		GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vector);

		VectorCopy(dl->origin, vector);
		vector[3] = 1.0f;
		GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector);

		GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius);

		GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale);
		GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale);
		
		// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
		// where they aren't rendered
		GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );

		GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);

		if (pStage->bundle[TB_DIFFUSEMAP].image[0])
			R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP);

		// bind textures that are sampled and used in the glsl shader, and
		// bind whiteImage to textures that are sampled but zeroed in the glsl shader
		//
		// alternatives:
		//  - use the last bound texture
		//     -> costs more to sample a higher res texture then throw out the result
		//  - disable texture sampling in glsl shader with #ifdefs, as before
		//     -> increases the number of shaders that must be compiled
		//

		if (pStage->bundle[TB_NORMALMAP].image[0])
		{
			R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP);
		}
		else if (r_normalMapping->integer)
			GL_BindToTMU( tr.whiteImage, TB_NORMALMAP );

		if (pStage->bundle[TB_SPECULARMAP].image[0])
		{
			R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP);
		}
		else if (r_specularMapping->integer)
			GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP );

		{
			vec4_t enableTextures;

			VectorSet4(enableTextures, 0.0f, 0.0f, 0.0f, 0.0f);
			GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures);
		}

		if (r_dlightMode->integer >= 2)
		{
			GL_SelectTexture(TB_SHADOWMAP);
			GL_Bind(tr.shadowCubemaps[l]);
			GL_SelectTexture(0);
		}

		ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb );
		GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix);
		GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb);

		GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen);

		//
		// draw
		//

		if (input->multiDrawPrimitives)
		{
			R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex);
		}
		else
		{
			R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex);
		}

		backEnd.pc.c_totalIndexes += tess.numIndexes;
		backEnd.pc.c_dlightIndexes += tess.numIndexes;
		backEnd.pc.c_dlightVertexes += tess.numVertexes;
	}
}
开发者ID:ensiform,项目名称:q3pp,代码行数:101,代码来源:tr_shade.cpp


示例10: RB_GLSL_IterateStagesGeneric


//.........这里部分代码省略.........
		/* model view matrix */
		if (program->u_ModelViewMatrix > -1)
			R_GLSL_SetUniform_ModelViewMatrix(program, glState.currentModelViewMatrix);

		/* model view projection matrix */
		if (program->u_ModelViewProjectionMatrix > -1)
			R_GLSL_SetUniform_ModelViewProjectionMatrix(program, glState.currentModelViewProjectionMatrix);

		/* projection matrix */
		if (program->u_ProjectionMatrix > -1)
			R_GLSL_SetUniform_ProjectionMatrix(program, glState.currentProjectionMatrix);

		/* texture coordinates 0 */
		if (program->u_TCGen0 > -1)
			R_GLSL_SetUniform_TCGen0(program, pStage->bundle[0].tcGen);

		/* texture coordinates 1 */
		if (program->u_TCGen1 > -1)
			R_GLSL_SetUniform_TCGen1(program, pStage->bundle[1].tcGen);

		/* tex env */
		if (program->u_TexEnv > -1) {
			if (r_lightmap->integer)
				R_GLSL_SetUniform_TexEnv(program, GL_REPLACE);
			else
				R_GLSL_SetUniform_TexEnv(program, input->shader->multitextureEnv);
		}

		/* texture unit 0 */
		if (program->u_Texture0 > -1 && pStage->bundle[0].image[0]) {
			GL_SelectTexture(0);

			if (pStage->bundle[0].vertexLightmap && ((r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2) && r_lightmap->integer)
				GL_Bind(tr.whiteImage);
			else
				R_BindAnimatedImage(&pStage->bundle[0]);
		}

		/* texture unit 1 */
		if (program->u_Texture1 > -1 && pStage->bundle[1].image[0]) {
			GL_SelectTexture(1);
			qglEnable(GL_TEXTURE_2D);
			R_BindAnimatedImage(&pStage->bundle[1]);
		}

		/* texture unit 2 */
		if (program->u_Texture2 > -1 && pStage->bundle[2].image[0]) {
			GL_SelectTexture(2);
			qglEnable(GL_TEXTURE_2D);
			R_BindAnimatedImage(&pStage->bundle[2]);
		}

		/* texture unit 3 */
		if (program->u_Texture3 > -1 && pStage->bundle[3].image[0]) {
			GL_SelectTexture(3);
			qglEnable(GL_TEXTURE_2D);
			R_BindAnimatedImage(&pStage->bundle[3]);
		}

		/* texture unit 4 */
		if (program->u_Texture4 > -1 && pStage->bundle[4].image[0]) {
			GL_SelectTexture(4);
			qglEnable(GL_TEXTURE_2D);
			R_BindAnimatedImage(&pStage->bundle[4]);
		}
开发者ID:burzumishi,项目名称:dragonballworld,代码行数:66,代码来源:tr_shade.c


示例11: R_DrawParticles


//.........这里部分代码省略.........
	for (p=active_particles ; p ; p=p->next)
	{
		for ( ;; )
		{
			kill = p->next;
			//XYZ
			if (kill && ((kill->die < cl.time) || (kill->numbounces <= 0)))
			{
				p->next = kill->next;
				kill->next = free_particles;
				free_particles = kill;
				continue;
			}
			break;
		}

		scale = p->size;
		p->size += p->growspeed*frametime;

		//calculate color based on life ...
		blend = (p->die-cl.time)/p->lifetime;
		blend1 = 1-blend;
		for (i=0; i<3; i++) {
			p->color[i] = p->startcolor[i] * blend + p->endcolor[i] * blend1;
		}

		if ((p->die - cl.time) < 0.5) {
			float fade = 2*(p->die - cl.time);
			glColor4f(p->color[0]*fade, p->color[1]*fade, p->color[2]*fade, fade);
		} else {
			glColor3fv(&p->color[0]);
		}

		GL_Bind(p->texture);
		glBlendFunc (p->srcblend, p->dstblend);

		//Align with velocity
		if (p->velaligned){
			float lscale;
			VectorCopy (p->vel, up);
			VectorNormalize(up);
			CrossProduct(vpn,up,right);
			VectorNormalize(right);
			lscale = (Length(p->vel)*p->velscale);
			VectorScale(up,lscale,up);
		} else {
			VectorCopy (vup, up);
			VectorCopy (vright, right);
		}

		glLoadIdentity();
		glTranslatef(0.5,0.5,0);
		glRotatef(p->rot,0,0,1);
		glTranslatef(-0.5,-0.5,0);

		sscale = -scale/4;
		VectorMA(p->org,sscale,up,neworg);
		VectorMA(neworg,sscale,right,neworg);

                // draw the particle as two triangles
                scale /= 2;
		glBegin(GL_TRIANGLE_FAN);
		glTexCoord2f (0,0);
		glVertex3fv (neworg);
		glTexCoord2f (0,1);
		glVertex3f (neworg[0] + up[0]*scale, neworg[1] + up[1]*scale,
开发者ID:MaddTheSane,项目名称:TenebraeQuake,代码行数:67,代码来源:r_part.c


示例12: VectorScale

void CRainSystem::Render(void)
{
	int			i;
	SParticle	*item;
	vec4_t		forward, down, left;
	vec3_t		pos;
//	float		percent;
	float		radius;

	CWorldEffectsSystem::Render();

	if (mFadeAlpha <= 0.0)
	{
		return;
	}

	VectorScale(backEnd.viewParms.or.axis[0], 1, forward);		// forward
	VectorScale(backEnd.viewParms.or.axis[1], 0.2f, left);		// left
	down[0] = 0 - mWindDirection[0] * mRainHeight * mWindAngle;
	down[1] = 0 - mWindDirection[1] * mRainHeight * mWindAngle;
	down[2] = -mRainHeight;

	GL_Bind(mImage);

	GL_State(GLS_ALPHA);
	qglEnable(GL_TEXTURE_2D);
	qglDisable(GL_CULL_FACE);

	qglMatrixMode(GL_MODELVIEW);
	qglPushMatrix();
    qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1],  backEnd.viewParms.or.origin[2]);

	item = mRainList;
	qglBegin(GL_TRIANGLES );
	for(i=mMaxRain;i;i--)
	{
/*		percent = (item->pos[1] -(-20.0)) / (20.0 - (-20.0));
		percent *= forward[2];
		if (percent < 0.0)
		{
			radius = 10 * (percent + 1.0);
		}
		else
		{
			radius = 10 * (1.0 - percent);
		}*/
		radius = item->pos[1];
		if (item->pos[2] < 0.0)
		{
//			radius *= 1.0 - (item->pos[2] / 40.0);
			float alpha = mAlpha * (item->pos[1] / -item->pos[2]);

			if (alpha > mAlpha)
			{
				alpha = mAlpha;
			}
			qglColor4f(1.0, 1.0, 1.0, alpha * mFadeAlpha);
		}
		else
		{
			qglColor4f(1.0, 1.0, 1.0, mAlpha * mFadeAlpha);
//			radius *= 1.0 + (item->pos[2] / 20.0);
		}

		pos[0] = sin(item->pos[0]) * radius + (item->pos[2] * mWindDirection[0] * mWindAngle);
		pos[1] = cos(item->pos[0]) * radius + (item->pos[2] * mWindDirection[1] * mWindAngle);
		pos[2] = item->pos[2];

		qglTexCoord2f(1.0, 0.0);
		qglVertex3f(pos[0],
					pos[1],
					pos[2]);

		qglTexCoord2f(0.0, 0.0);
		qglVertex3f(pos[0] + left[0],
					pos[1] + left[1],
					pos[2] + left[2]);
		
		qglTexCoord2f(0.0, 1.0);
		qglVertex3f(pos[0] + down[0] + left[0],
					pos[1] + down[1] + left[1],
					pos[2] + down[2] + left[2]);
		item++;
	}
	qglEnd();

	qglEnable(GL_CULL_FACE);

	qglPopMatrix();
}
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:90,代码来源:tr_worldeffects.cpp


示例13: mMaxRain

CRainSystem::CRainSystem(int maxRain) :
	mMaxRain(maxRain),
	mNextWindGust(0),
	mRainHeight(5),
	mAlpha(0.15f),
	mWindAngle(1.0f),

	mFadeAlpha(0.0f),
	mIsRaining(false)

{
	char			name[256];
	unsigned char	*data, *pos;
	int				width, height;
	int				x, y;

	mSpread[0] = (float)(M_PI*2.0);		// angle spread
	mSpread[1] = 20.0f;			// radius spread
	mSpread[2] = 20.0f;			// z spread

	mMinVelocity[0] = 0.1f;
	mMaxVelocity[0] = -0.1f;
	mMinVelocity[1] = 0.1f;
	mMaxVelocity[1] = -0.1f;
	mMinVelocity[2] = -60.0;
	mMaxVelocity[2] = -50.0;

	mWindDuration = 15;
	mWindLow = 50;
	mWindMin = 0.01f;
	mWindMax = 0.05f;

	mWindChange = 0;
	mWindDirection[0] = mWindDirection[1] = mWindDirection[2] = 0.0;

	mRainList = new SParticle[mMaxRain];

	sprintf(name, "gfx/world/rain.tga");
	R_LoadImage( name, &data, &width, &height );
	if (!data)
	{
		ri.Error (ERR_DROP, "Could not load %s", name);
	}

	pos = data;
	for(y=0;y<height;y++)
	{
		for(x=0;x<width;x++)
		{
			pos[3] = pos[0];
			pos += 4;
		}
	}

	mImage = R_CreateImage(name, data, width, height, false, false, false, GL_CLAMP);
	GL_Bind(mImage);
	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
	qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

	Init();
}
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:61,代码来源:tr_worldeffects.cpp


示例14: Tess_StageIteratorSky

/*
================
Tess_StageIteratorSky

All of the visible sky triangles are in tess

Other things could be stuck in here, like birds in the sky, etc
================
*/
void Tess_StageIteratorSky( void )
{
	// log this call
	if ( r_logFile->integer )
	{
		// don't just call LogComment, or we will get
		// a call to va() every frame!
		GLimp_LogComment( va
		                  ( "--- Tess_StageIteratorSky( %s, %i vertices, %i triangles ) ---\n", tess.surfaceShader->name,
		                    tess.numVertexes, tess.numIndexes / 3 ) );
	}

	if ( r_fastsky->integer )
	{
		return;
	}

	// trebor: HACK why does this happen with cg_draw2D 0 ?
	if ( tess.stageIteratorFunc2 == NULL )
	{
		//tess.stageIteratorFunc2 = Tess_StageIteratorGeneric;
		ri.Error( ERR_FATAL, "tess.stageIteratorFunc == NULL" );
	}

	GL_Cull(CT_TWO_SIDED);

	if ( tess.stageIteratorFunc2 == &Tess_StageIteratorDepthFill )
	{
		// go through all the polygons and project them onto
		// the sky box to see which blocks on each side need
		// to be drawn
		Tess_ClipSkyPolygons();

		// generate the vertexes for all the clouds, which will be drawn
		// by the generic shader routine
		BuildCloudData();

		if ( tess.numVertexes || tess.multiDrawPrimitives )
		{
			tess.stageIteratorFunc2();
		}
	}
	else
	{
		if ( tess.stageIteratorFunc2 == &Tess_StageIteratorGBuffer )
		{
			R_BindFBO( tr.geometricRenderFBO );
		}

		// go through all the polygons and project them onto
		// the sky box to see which blocks on each side need
		// to be drawn
		Tess_ClipSkyPolygons();

		// r_showSky will let all the sky blocks be drawn in
		// front of everything to allow developers to see how
		// much sky is getting sucked in

		if ( r_showSky->integer )
		{
			glDepthRange( 0.0, 0.0 );
		}
		else
		{
			glDepthRange( 1.0, 1.0 );
		}

		// draw the outer skybox
		if ( tess.surfaceShader->sky.outerbox && tess.surfaceShader->sky.outerbox != tr.blackCubeImage )
		{
#if 1
			R_BindVBO( tess.vbo );
			R_BindIBO( tess.ibo );

			gl_skyboxShader->BindProgram();

			gl_skyboxShader->SetUniform_ViewOrigin( backEnd.viewParms.orientation.origin );  // in world space

			gl_skyboxShader->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
			gl_skyboxShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] );

			gl_skyboxShader->SetRequiredVertexPointers();

			// bind u_ColorMap
			GL_SelectTexture( 0 );
			GL_Bind( tess.surfaceShader->sky.outerbox );

			DrawSkyBox( tess.surfaceShader );
#endif
		}

//.........这里部分代码省略.........
开发者ID:elbeardmorez,项目名称:Unvanquished,代码行数:101,代码来源:tr_sky.cpp


示例15: R_DrawSkyBox

void R_DrawSkyBox (void)
{
#ifdef ENABLE_HYG_STARS
	R_DrawStars(); // jitstarviewer
#else
	int		i;

	if (fogenabled) // jitfog
		qgl.Disable(GL_FOG);

	if (skyrotate)
	{
		// check for no sky at all
		for (i = 0; i < 6; ++i)
		{
			if (skymins[0][i] < skymaxs[0][i] && skymins[1][i] < skymaxs[1][i])
				break;
		}

		if (i == 6)
			return;		// nothing visible
	}

	qgl.PushMatrix();
	qgl.Translatef(r_origin[0], r_origin[1], r_origin[2]);
	qgl.Rotatef(r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]);

	if (fogenabled && sky_images[0] == r_whitetexture) // jitfog
	{
		qgl.Color3fv(fogcolor);
		GLSTATE_ENABLE_BLEND
		GL_TexEnv(GL_MODULATE);
	}

	for (i = 0; i < 6; ++i)
	{
		if (skyrotate)
		{
			// hack, forces full sky to draw when rotating
			skymins[0][i] = -1;
			skymins[1][i] = -1;
			skymaxs[0][i] = 1;
			skymaxs[1][i] = 1;
		}

		if (skymins[0][i] >= skymaxs[0][i] || skymins[1][i] >= skymaxs[1][i])
			continue;

		GL_Bind(sky_images[skytexorder[i]]->texnum);

		qgl.Begin(GL_QUADS);
		MakeSkyVec(skymins[0][i], skymins[1][i], i);
		MakeSkyVec(skymins[0][i], skymaxs[1][i], i);
		MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i);
		MakeSkyVec(skymaxs[0][i], skymins[1][i], i);
		qgl.End();
	}

	qgl.PopMatrix();

	if (fogenabled) // jitfog
	{
		qgl.Color3f(1, 1, 1);
		GLSTATE_DISABLE_BLEND
		qgl.Enable(GL_FOG);
	}
#endif
}
开发者ID:jitspoe,项目名称:starviewer,代码行数:68,代码来源:gl_warp.c


示例16: edge

/*
=================
RB_ShadowTessEnd

triangleFromEdge[ v1 ][ v2 ]


  set triangle from edge( v1, v2, tri )
  if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) {
  }
=================
*/
void RB_ShadowTessEnd( void ) {
	int		i;
	int		numTris;
	vec3_t	lightDir;
	GLboolean rgba[4];

	// we can only do this if we have enough space in the vertex buffers
	if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {
		return;
	}

	if ( glConfig.stencilBits < 4 ) {
		return;
	}

	VectorCopy( backEnd.currentEntity->lightDir, lightDir );

	// project vertexes away from light direction
	for ( i = 0 ; i < tess.numVertexes ; i++ ) {
		VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );
	}

	// decide which triangles face the light
	Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes );

	numTris = tess.numIndexes / 3;
	for ( i = 0 ; i < numTris ; i++ ) {
		int		i1, i2, i3;
		vec3_t	d1, d2, normal;
		float	*v1, *v2, *v3;
		float	d;

		i1 = tess.indexes[ i*3 + 0 ];
		i2 = tess.indexes[ i*3 + 1 ];
		i3 = tess.indexes[ i*3 + 2 ];

		v1 = tess.xyz[ i1 ];
		v2 = tess.xyz[ i2 ];
		v3 = tess.xyz[ i3 ];

		VectorSubtract( v2, v1, d1 );
		VectorSubtract( v3, v1, d2 );
		CrossProduct( d1, d2, normal );

		d = DotProduct( normal, lightDir );
		if ( d > 0 ) {
			facing[ i ] = 1;
		} else {
			facing[ i ] = 0;
		}

		// create the edges
		R_AddEdgeDef( i1, i2, facing[ i ] );
		R_AddEdgeDef( i2, i3, facing[ i ] );
		R_AddEdgeDef( i3, i1, facing[ i ] );
	}

	// draw the silhouette edges

	GL_Bind( tr.whiteImage );
	qglEnable( GL_CULL_FACE );
	GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
	qglColor3f( 0.2f, 0.2f, 0.2f );

	// don't write to the color buffer
	qglGetBooleanv(GL_COLOR_WRITEMASK, rgba);
	qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );

	qglEnable( GL_STENCIL_TEST );
	qglStencilFunc( GL_ALWAYS, 1, 255 );

	// mirrors have the culling order reversed
	if ( backEnd.viewParms.isMirror ) {
		qglCullFace( GL_FRONT );
		qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );

		R_RenderShadowEdges();

		qglCullFace( GL_BACK );
		qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );

		R_RenderShadowEdges();
	} else {
		qglCullFace( GL_BACK );
		qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );

		R_RenderShadowEdges();

//.........这里部分代码省略.........
开发者ID:OnlyTheGhosts,项目名称:Mirai_Ran,代码行数:101,代码来源:tr_shadows.c



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GL_CALL函数代码示例发布时间:2022-05-30
下一篇:
C++ GL_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap