本文整理汇总了C++中qglEnable函数的典型用法代码示例。如果您正苦于以下问题:C++ qglEnable函数的具体用法?C++ qglEnable怎么用?C++ qglEnable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglEnable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RB_StageIteratorLightmappedMultitexture
/*
===================
RB_StageIteratorLightmappedMultitexture
===================
*/
void RB_StageIteratorLightmappedMultitexture(void)
{
shaderCommands_t *input = &tess;
shader_t *shader = input->shader;
// 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("--- RB_StageIteratorLightmappedMultitexture( %s ) ---\n", tess.shader->name));
}
// set GL fog
SetIteratorFog();
// set face culling appropriately
GL_Cull(shader->cullType);
// set color, pointers, and lock
GL_State(GLS_DEFAULT);
qglVertexPointer(3, GL_FLOAT, 16, input->xyz);
#ifdef REPLACE_MODE
qglDisableClientState(GL_COLOR_ARRAY);
qglColor3f(1, 1, 1);
qglShadeModel(GL_FLAT);
#else
qglEnableClientState(GL_COLOR_ARRAY);
qglColorPointer(4, GL_UNSIGNED_BYTE, 0, tess.constantColor255);
#endif
// select base stage
GL_SelectTexture(0);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
R_BindAnimatedImage(&tess.xstages[0]->bundle[0]);
qglTexCoordPointer(2, GL_FLOAT, 8, tess.texCoords0);
// configure second stage
GL_SelectTexture(1);
qglEnable(GL_TEXTURE_2D);
if (r_lightmap->integer)
{
GL_TexEnv(GL_REPLACE);
}
else
{
GL_TexEnv(GL_MODULATE);
}
// modified for snooper
if (tess.xstages[0]->bundle[1].isLightmap && (backEnd.refdef.rdflags & RDF_SNOOPERVIEW))
{
GL_Bind(tr.whiteImage);
}
else
{
R_BindAnimatedImage(&tess.xstages[0]->bundle[1]);
}
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer(2, GL_FLOAT, 8, tess.texCoords1);
// lock arrays
if (qglLockArraysEXT)
{
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment("glLockArraysEXT\n");
}
R_DrawElements(input->numIndexes, input->indexes);
// disable texturing on TEXTURE1, then select TEXTURE0
qglDisable(GL_TEXTURE_2D);
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
GL_SelectTexture(0);
#ifdef REPLACE_MODE
GL_TexEnv(GL_MODULATE);
qglShadeModel(GL_SMOOTH);
#endif
// now do any dynamic lighting needed
//if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE )
if (tess.dlightBits && tess.shader->fogPass &&
!(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY)))
{
if (r_dynamiclight->integer == 2)
{
DynamicLightPass();
}
else
{
DynamicLightSinglePass();
//.........这里部分代码省略.........
示例2: RB_StageIteratorGeneric
/*
** RB_StageIteratorGeneric
*/
void RB_StageIteratorGeneric( void )
{
shaderCommands_t *input;
shader_t *shader;
input = &tess;
shader = input->shader;
RB_DeformTessGeometry();
//
// 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("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) );
}
//
// set face culling appropriately
//
GL_Cull( shader->cullType );
// set polygon offset if necessary
if ( shader->polygonOffset )
{
qglEnable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
//
// if there is only a single pass then we can enable color
// and texture arrays before we compile, otherwise we need
// to avoid compiling those arrays since they will change
// during multipass rendering
//
if ( tess.numPasses > 1 || shader->multitextureEnv )
{
setArraysOnce = false;
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
}
else
{
setArraysOnce = true;
qglEnableClientState( GL_COLOR_ARRAY);
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
}
//
// lock XYZ
//
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT)
{
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
//
// enable color and texcoord arrays after the lock if necessary
//
if ( !setArraysOnce )
{
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglEnableClientState( GL_COLOR_ARRAY );
}
//
// call shader function
//
RB_IterateStagesGeneric( input );
//
// now do any dynamic lighting needed
//
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE
&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//
// unlock arrays
//
//.........这里部分代码省略.........
示例3: RB_StageIteratorGeneric
/*
** RB_StageIteratorGeneric
*/
void RB_StageIteratorGeneric( void )
{
shaderCommands_t *input;
unsigned int vertexAttribs = 0;
input = &tess;
if (!input->numVertexes || !input->numIndexes)
{
return;
}
if (tess.useInternalVBO)
{
RB_DeformTessGeometry();
}
vertexAttribs = RB_CalcShaderVertexAttribs( input );
if (tess.useInternalVBO)
{
RB_UpdateVBOs(vertexAttribs);
}
else
{
backEnd.pc.c_staticVboDraws++;
}
//
// 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("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) );
}
//
// set face culling appropriately
//
if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW))
{
//GL_Cull( CT_TWO_SIDED );
if (input->shader->cullType == CT_TWO_SIDED)
GL_Cull( CT_TWO_SIDED );
else if (input->shader->cullType == CT_FRONT_SIDED)
GL_Cull( CT_BACK_SIDED );
else
GL_Cull( CT_FRONT_SIDED );
}
else
GL_Cull( input->shader->cullType );
// set polygon offset if necessary
if ( input->shader->polygonOffset )
{
qglEnable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
//
// Set vertex attribs and pointers
//
GLSL_VertexAttribsState(vertexAttribs);
//
// render depth if in depthfill mode
//
if (backEnd.depthFill)
{
RB_IterateStagesGeneric( input );
//
// reset polygon offset
//
if ( input->shader->polygonOffset )
{
qglDisable( GL_POLYGON_OFFSET_FILL );
}
return;
}
//
// render shadowmap if in shadowmap mode
//
if (backEnd.viewParms.flags & VPF_SHADOWMAP)
{
if ( input->shader->sort == SS_OPAQUE )
{
RB_RenderShadowmap( input );
}
//
// reset polygon offset
//.........这里部分代码省略.........
示例4: RB_DoShadowTessEnd
//.........这里部分代码省略.........
planeEq[2] = v1[0]*(v2[1]-v3[1]) + v2[0]*(v3[1]-v1[1]) + v3[0]*(v1[1]-v2[1]);
planeEq[3] = -( v1[0]*( v2[1]*v3[2] - v3[1]*v2[2] ) +
v2[0]*(v3[1]*v1[2] - v1[1]*v3[2]) +
v3[0]*(v1[1]*v2[2] - v2[1]*v1[2]) );
d = planeEq[0]*lightPos[0]+
planeEq[1]*lightPos[1]+
planeEq[2]*lightPos[2]+
planeEq[3];
}
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 ] );
}
GL_Bind( tr.whiteImage );
//qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
#ifndef _DEBUG_STENCIL_SHADOWS
qglColor3f( 0.2f, 0.2f, 0.2f );
// don't write to the color buffer
qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_ALWAYS, 1, 255 );
#else
qglColor3f( 1.0f, 0.0f, 0.0f );
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
//qglDisable(GL_DEPTH_TEST);
#endif
#ifdef _STENCIL_REVERSE
qglDepthFunc(GL_LESS);
//now using the Carmack Reverse<tm> -rww
if ( backEnd.viewParms.isMirror ) {
//qglCullFace( GL_BACK );
GL_Cull(CT_BACK_SIDED);
qglStencilOp( GL_KEEP, GL_INCR, GL_KEEP );
R_RenderShadowEdges();
//qglCullFace( GL_FRONT );
GL_Cull(CT_FRONT_SIDED);
qglStencilOp( GL_KEEP, GL_DECR, GL_KEEP );
R_RenderShadowEdges();
} else {
//qglCullFace( GL_FRONT );
GL_Cull(CT_FRONT_SIDED);
qglStencilOp( GL_KEEP, GL_INCR, GL_KEEP );
R_RenderShadowEdges();
//qglCullFace( GL_BACK );
GL_Cull(CT_BACK_SIDED);
示例5: RB_StageIteratorGeneric
/*
** RB_StageIteratorGeneric
*/
void RB_StageIteratorGeneric( void ) {
shaderCommands_t *input;
input = &tess;
RB_DeformTessGeometry();
//
// 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( "--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name ) );
}
// set GL fog
SetIteratorFog();
if ( qglPNTrianglesiATI && tess.ATI_tess ) {
// RF< so we can send the normals as an array
qglEnableClientState( GL_NORMAL_ARRAY );
#ifdef __MACOS__ //DAJ ATI
qglPNTrianglesiATI( GL_PN_TRIANGLES_ATI, 1 );
#else
qglEnable( GL_PN_TRIANGLES_ATI ); // ATI PN-Triangles extension
#endif
}
//
// set face culling appropriately
//
GL_Cull( input->shader->cullType );
// set polygon offset if necessary
if ( input->shader->polygonOffset ) {
qglEnable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
//
// if there is only a single pass then we can enable color
// and texture arrays before we compile, otherwise we need
// to avoid compiling those arrays since they will change
// during multipass rendering
//
if ( tess.numPasses > 1 || input->shader->multitextureEnv ) {
setArraysOnce = qfalse;
qglDisableClientState( GL_COLOR_ARRAY );
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
} else
{
setArraysOnce = qtrue;
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
}
// RF, send normals only if required
// This must be done first, since we can't change the arrays once they have been
// locked
if ( qglPNTrianglesiATI && tess.ATI_tess ) {
qglNormalPointer( GL_FLOAT, 16, input->normal );
}
//
// lock XYZ
//
qglVertexPointer( 3, GL_FLOAT, 16, input->xyz ); // padded for SIMD
if ( qglLockArraysEXT ) {
qglLockArraysEXT( 0, input->numVertexes );
GLimp_LogComment( "glLockArraysEXT\n" );
}
//
// enable color and texcoord arrays after the lock if necessary
//
if ( !setArraysOnce ) {
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglEnableClientState( GL_COLOR_ARRAY );
}
//
// call shader function
//
RB_IterateStagesGeneric( input );
//
// now do any dynamic lighting needed
//
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE
&& !( tess.shader->surfaceFlags & ( SURF_NODLIGHT | SURF_SKY ) ) ) {
ProjectDlightTexture();
//.........这里部分代码省略.........
示例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);
}
示例7: RE_BeginFrame
// If running in stereo, RE_BeginFrame will be called twice for each RE_EndFrame
void RE_BeginFrame( stereoFrame_t stereoFrame ) {
drawBufferCommand_t *cmd = NULL;
colorMaskCommand_t *colcmd = NULL;
if ( !tr.registered ) {
return;
}
glState.finishCalled = qfalse;
tr.frameCount++;
tr.frameSceneNum = 0;
//
// do overdraw measurement
//
if ( r_measureOverdraw->integer )
{
if ( glConfig.stencilBits < 4 )
{
ri->Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits );
ri->Cvar_Set( "r_measureOverdraw", "0" );
r_measureOverdraw->modified = qfalse;
}
else if ( r_shadows->integer == 2 )
{
ri->Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" );
ri->Cvar_Set( "r_measureOverdraw", "0" );
r_measureOverdraw->modified = qfalse;
}
else
{
R_SyncRenderThread();
qglEnable( GL_STENCIL_TEST );
qglStencilMask( ~0U );
qglClearStencil( 0U );
qglStencilFunc( GL_ALWAYS, 0U, ~0U );
qglStencilOp( GL_KEEP, GL_INCR, GL_INCR );
}
r_measureOverdraw->modified = qfalse;
}
else
{
// this is only reached if it was on and is now off
if ( r_measureOverdraw->modified ) {
R_SyncRenderThread();
qglDisable( GL_STENCIL_TEST );
}
r_measureOverdraw->modified = qfalse;
}
//
// texturemode stuff
//
if ( r_textureMode->modified ) {
R_SyncRenderThread();
GL_TextureMode( r_textureMode->string );
r_textureMode->modified = qfalse;
}
//
// gamma stuff
//
if ( r_gamma->modified ) {
r_gamma->modified = qfalse;
R_SyncRenderThread();
R_SetColorMappings();
}
// check for errors
if ( !r_ignoreGLErrors->integer )
{
int err;
R_SyncRenderThread();
if ((err = qglGetError()) != GL_NO_ERROR)
ri->Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err);
}
if (glConfig.stereoEnabled) {
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
return;
cmd->commandId = RC_DRAW_BUFFER;
if ( stereoFrame == STEREO_LEFT ) {
cmd->buffer = (int)GL_BACK_LEFT;
} else if ( stereoFrame == STEREO_RIGHT ) {
cmd->buffer = (int)GL_BACK_RIGHT;
} else {
ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
}
}
else
{
if(r_anaglyphMode->integer)
{
if(r_anaglyphMode->modified)
{
//.........这里部分代码省略.........
示例8: gtk_glwidget_print_string
// Renders the input text at the current location with the current color.
// The X position of the current location is used to place the left edge of the text image,
// where the text image bounds are defined as the logical extents of the line of text.
// The Y position of the current location is used to place the bottom of the text image.
// You should offset the Y position by the amount returned by gtk_glwidget_font_descent()
// if you want to place the baseline of the text image at the current Y position.
// Note: A problem with this function is that if the lower left corner of the text falls
// just a hair outside of the viewport (meaning the current raster position is invalid),
// then no text will be rendered. The solution to this is a very hacky one. You can search
// Google for "glDrawPixels clipping".
void gtk_glwidget_print_string( const char *s ){
// The idea for this code initially came from the font-pangoft2.c example that comes with GtkGLExt.
PangoLayout *layout;
PangoRectangle log_rect;
FT_Bitmap bitmap;
unsigned char *begin_bitmap_buffer;
GLfloat color[4];
GLint previous_unpack_alignment;
GLboolean previous_blend_enabled;
GLint previous_blend_func_src;
GLint previous_blend_func_dst;
GLfloat previous_red_bias;
GLfloat previous_green_bias;
GLfloat previous_blue_bias;
GLfloat previous_alpha_scale;
if ( !_debug_font_created ) {
Error( "Programming error: gtk_glwidget_print_string() called but font does not exist; "
"you should have called gtk_glwidget_create_font() first" );
}
layout = pango_layout_new( ft2_context );
pango_layout_set_width( layout, -1 ); // -1 no wrapping. All text on one line.
pango_layout_set_text( layout, s, -1 ); // -1 null-terminated string.
pango_layout_get_extents( layout, NULL, &log_rect );
if ( log_rect.width > 0 && log_rect.height > 0 ) {
bitmap.rows = font_ascent + font_descent;
bitmap.width = PANGO_PIXELS_CEIL( log_rect.width );
bitmap.pitch = -bitmap.width; // Rendering it "upside down" for OpenGL.
begin_bitmap_buffer = (unsigned char *) g_malloc( bitmap.rows * bitmap.width );
memset( begin_bitmap_buffer, 0, bitmap.rows * bitmap.width );
bitmap.buffer = begin_bitmap_buffer + ( bitmap.rows - 1 ) * bitmap.width; // See pitch above.
bitmap.num_grays = 0xff;
bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
pango_ft2_render_layout_subpixel( &bitmap, layout, -log_rect.x,
y_offset_bitmap_render_pango_units );
qglGetFloatv( GL_CURRENT_COLOR, color );
// Save state. I didn't see any OpenGL push/pop operations for these.
// Question: Is saving/restoring this state necessary? Being safe.
qglGetIntegerv( GL_UNPACK_ALIGNMENT, &previous_unpack_alignment );
previous_blend_enabled = qglIsEnabled( GL_BLEND );
qglGetIntegerv( GL_BLEND_SRC, &previous_blend_func_src );
qglGetIntegerv( GL_BLEND_DST, &previous_blend_func_dst );
qglGetFloatv( GL_RED_BIAS, &previous_red_bias );
qglGetFloatv( GL_GREEN_BIAS, &previous_green_bias );
qglGetFloatv( GL_BLUE_BIAS, &previous_blue_bias );
qglGetFloatv( GL_ALPHA_SCALE, &previous_alpha_scale );
qglPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
qglEnable( GL_BLEND );
qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
qglPixelTransferf( GL_RED_BIAS, color[0] );
qglPixelTransferf( GL_GREEN_BIAS, color[1] );
qglPixelTransferf( GL_BLUE_BIAS, color[2] );
qglPixelTransferf( GL_ALPHA_SCALE, color[3] );
qglDrawPixels( bitmap.width, bitmap.rows,
GL_ALPHA, GL_UNSIGNED_BYTE, begin_bitmap_buffer );
g_free( begin_bitmap_buffer );
// Restore state in reverse order of how we set it.
qglPixelTransferf( GL_ALPHA_SCALE, previous_alpha_scale );
qglPixelTransferf( GL_BLUE_BIAS, previous_blue_bias );
qglPixelTransferf( GL_GREEN_BIAS, previous_green_bias );
qglPixelTransferf( GL_RED_BIAS, previous_red_bias );
qglBlendFunc( previous_blend_func_src, previous_blend_func_dst );
if ( !previous_blend_enabled ) {
qglDisable( GL_BLEND );
}
qglPixelStorei( GL_UNPACK_ALIGNMENT, previous_unpack_alignment );
}
g_object_unref( G_OBJECT( layout ) );
}
示例9: SP_DrawTexture
/*********
SP_DrawTexture
*********/
void SP_DrawTexture(void* pixels, float width, float height, float vShift)
{
if (!pixels)
{
// Ug. We were not even able to load the error message texture.
return;
}
// Create a texture from the buffered file
GLuint texid;
qglGenTextures(1, &texid);
qglBindTexture(GL_TEXTURE_2D, texid);
qglTexImage2D(GL_TEXTURE_2D, 0, GL_DDS1_EXT, width, height, 0, GL_DDS1_EXT, GL_UNSIGNED_BYTE, pixels);
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
// Reset every GL state we've got. Who knows what state
// the renderer could be in when this function gets called.
qglColor3f(1.f, 1.f, 1.f);
#ifdef _XBOX
if(glw_state->isWidescreen)
qglViewport(0, 0, 720, 480);
else
#endif
qglViewport(0, 0, 640, 480);
GLboolean alpha = qglIsEnabled(GL_ALPHA_TEST);
qglDisable(GL_ALPHA_TEST);
GLboolean blend = qglIsEnabled(GL_BLEND);
qglDisable(GL_BLEND);
GLboolean cull = qglIsEnabled(GL_CULL_FACE);
qglDisable(GL_CULL_FACE);
GLboolean depth = qglIsEnabled(GL_DEPTH_TEST);
qglDisable(GL_DEPTH_TEST);
GLboolean fog = qglIsEnabled(GL_FOG);
qglDisable(GL_FOG);
GLboolean lighting = qglIsEnabled(GL_LIGHTING);
qglDisable(GL_LIGHTING);
GLboolean offset = qglIsEnabled(GL_POLYGON_OFFSET_FILL);
qglDisable(GL_POLYGON_OFFSET_FILL);
GLboolean scissor = qglIsEnabled(GL_SCISSOR_TEST);
qglDisable(GL_SCISSOR_TEST);
GLboolean stencil = qglIsEnabled(GL_STENCIL_TEST);
qglDisable(GL_STENCIL_TEST);
GLboolean texture = qglIsEnabled(GL_TEXTURE_2D);
qglEnable(GL_TEXTURE_2D);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity();
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
#ifdef _XBOX
if(glw_state->isWidescreen)
qglOrtho(0, 720, 0, 480, 0, 1);
else
#endif
qglOrtho(0, 640, 0, 480, 0, 1);
qglMatrixMode(GL_TEXTURE0);
qglLoadIdentity();
qglMatrixMode(GL_TEXTURE1);
qglLoadIdentity();
qglActiveTextureARB(GL_TEXTURE0_ARB);
qglClientActiveTextureARB(GL_TEXTURE0_ARB);
memset(&tess, 0, sizeof(tess));
// Draw the error message
qglBeginFrame();
if (!SP_LicenseDone)
{
// clear the screen if we haven't done the
// license yet...
qglClearColor(0, 0, 0, 1);
qglClear(GL_COLOR_BUFFER_BIT);
}
float x1, x2, y1, y2;
#ifdef _XBOX
if(glw_state->isWidescreen)
{
x1 = 0;
x2 = 720;
//.........这里部分代码省略.........
示例10: qglDisable
void CWind::Render(CWorldEffectsSystem *system)
{
vec3_t output;
if (!mEnabled || !debugShowWind)
{
return;
}
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_CULL_FACE);
GL_State(GLS_ALPHA);
qglColor4f(1.0, 0.0, 0.0, 0.5);
qglBegin(GL_QUADS);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, (mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, (mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, (mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, (mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
qglColor4f(0.0, 1.0, 0.0, 0.5);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, (mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, (mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, (mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
VectorMA(output, (mSize[2]/2.0), mPlanes[2], output);
qglVertex3fv(output);
qglColor4f(0.0, 0.0, 1.0, 0.5);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
qglVertex3fv(output);
VectorMA(mPoint, (mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
VectorMA(output, -(mSize[1]/2.0), mPlanes[1], output);
qglVertex3fv(output);
VectorMA(mPoint, (mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
VectorMA(output, (mSize[1]/2.0), mPlanes[1], output);
qglVertex3fv(output);
VectorMA(mPoint, -(mSize[0]/2.0), mPlanes[0], output);
VectorMA(output, -(mSize[2]/2.0), mPlanes[2], output);
VectorMA(output, (mSize[1]/2.0), mPlanes[1], output);
qglVertex3fv(output);
qglEnd();
qglEnable(GL_CULL_FACE);
qglEnable(GL_TEXTURE_2D);
}
示例11: 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();
}
示例12: DrawTris
/*
================
DrawTris
Draws triangle outlines for debugging
================
*/
static void DrawTris(shaderCommands_t *input)
{
char *s = r_trisColor->string;
vec4_t trisColor = { 1, 1, 1, 1 };
unsigned int stateBits = 0;
GL_Bind(tr.whiteImage);
if (*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
{
s += 2;
if (Q_IsHexColorString(s))
{
trisColor[0] = ((float)(gethex(*(s)) * 16 + gethex(*(s + 1)))) / 255.00;
trisColor[1] = ((float)(gethex(*(s + 2)) * 16 + gethex(*(s + 3)))) / 255.00;
trisColor[2] = ((float)(gethex(*(s + 4)) * 16 + gethex(*(s + 5)))) / 255.00;
if (Q_HexColorStringHasAlpha(s))
{
trisColor[3] = ((float)(gethex(*(s + 6)) * 16 + gethex(*(s + 7)))) / 255.00;
}
}
}
else
{
int i;
char *token;
for (i = 0 ; i < 4 ; i++)
{
token = COM_Parse(&s);
if (token)
{
trisColor[i] = atof(token);
}
else
{
trisColor[i] = 1.f;
}
}
if (!trisColor[3])
{
trisColor[3] = 1.f;
}
}
if (trisColor[3] < 1.f)
{
stateBits |= (GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
}
qglColor4fv(trisColor);
if (r_showtris->integer == 2)
{
stateBits |= (GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE);
GL_State(stateBits);
qglDepthRange(0, 0);
}
#ifdef CELSHADING_HACK
else if (r_showtris->integer == 3)
{
stateBits |= (GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE);
GL_State(stateBits);
qglEnable(GL_POLYGON_OFFSET_LINE);
qglPolygonOffset(4.0, 0.5);
qglLineWidth(5.0);
}
#endif
else
{
stateBits |= (GLS_POLYMODE_LINE);
GL_State(stateBits);
qglEnable(GL_POLYGON_OFFSET_LINE);
qglPolygonOffset(r_offsetFactor->value, r_offsetUnits->value);
}
qglDisableClientState(GL_COLOR_ARRAY);
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
qglVertexPointer(3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT)
{
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment("glLockArraysEXT\n");
}
R_DrawElements(input->numIndexes, input->indexes);
if (qglUnlockArraysEXT)
{
//.........这里部分代码省略.........
示例13: qglGetError
/*
================
rvGEWorkspace::Render
Renders the workspace to the given DC
================
*/
void rvGEWorkspace::Render ( HDC hdc )
{
int front;
int back;
float scale;
scale = g_ZoomScales[mZoom];
// Switch GL contexts to our dc
if (!qwglMakeCurrent( hdc, win32.hGLRC ))
{
common->Printf("ERROR: wglMakeCurrent failed.. Error:%i\n", qglGetError());
common->Printf("Please restart Q3Radiant if the Map view is not working\n");
return;
}
// Prepare the view and clear it
GL_State( GLS_DEFAULT );
qglViewport(0, 0, mWindowWidth, mWindowHeight );
qglScissor(0, 0, mWindowWidth, mWindowHeight );
qglClearColor ( 0.75f, 0.75f, 0.75f, 0 );
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_CULL_FACE);
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render the workspace below
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
qglColor3f ( mApplication->GetOptions().GetWorkspaceColor()[0], mApplication->GetOptions().GetWorkspaceColor()[1], mApplication->GetOptions().GetWorkspaceColor()[2] );
qglBegin ( GL_QUADS );
qglVertex2f ( mRect.x, mRect.y );
qglVertex2f ( mRect.x + mRect.w, mRect.y );
qglVertex2f ( mRect.x + mRect.w, mRect.y + mRect.h );
qglVertex2f ( mRect.x, mRect.y + mRect.h );
qglEnd ( );
// Prepare the renderSystem view to draw the GUI in
viewDef_t viewDef;
memset ( &viewDef, 0, sizeof(viewDef) );
tr.viewDef = &viewDef;
tr.viewDef->renderView.x = mRect.x;
tr.viewDef->renderView.y = mWindowHeight - mRect.y - mRect.h;
tr.viewDef->renderView.width = mRect.w;
tr.viewDef->renderView.height = mRect.h;
tr.viewDef->scissor.x1 = 0;
tr.viewDef->scissor.y1 = 0;
tr.viewDef->scissor.x2 = mRect.w;
tr.viewDef->scissor.y2 = mRect.h;
tr.viewDef->isEditor = true;
renderSystem->BeginFrame(mWindowWidth, mWindowHeight );
// Draw the gui
mInterface->Redraw ( 0 ); // eventLoop->Milliseconds() );
// We are done using the renderSystem now
renderSystem->EndFrame( &front, &back );
if ( mApplication->GetActiveWorkspace ( ) == this )
{
mApplication->GetStatusBar().SetTriangles ( backEnd.pc.c_drawIndexes/3 );
}
// Prepare the viewport for drawing selections, etc.
GL_State( GLS_DEFAULT );
qglDisable( GL_TEXTURE_CUBE_MAP_EXT );
// qglDisable(GL_BLEND);
qglDisable(GL_CULL_FACE);
qglViewport(0, 0, mWindowWidth, mWindowHeight );
qglScissor(0, 0, mWindowWidth, mWindowHeight );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
RenderGrid ( );
mSelections.Render ( );
qglFinish ( );
qwglSwapBuffers(hdc);
qglEnable( GL_TEXTURE_CUBE_MAP_EXT );
qglEnable( GL_CULL_FACE);
}
示例14: R_CheckCvars
/*
=============
R_CheckCvars
See if some cvars that we watch have changed
=============
*/
static void R_CheckCvars()
{
// gamma stuff
if( r_gamma.IsModified() || r_brightness.IsModified() )
{
r_gamma.ClearModified();
r_brightness.ClearModified();
R_SetColorMappings();
}
// filtering
if( r_maxAnisotropicFiltering.IsModified() || r_useTrilinearFiltering.IsModified() || r_lodBias.IsModified() )
{
idLib::Printf( "Updating texture filter parameters.\n" );
r_maxAnisotropicFiltering.ClearModified();
r_useTrilinearFiltering.ClearModified();
r_lodBias.ClearModified();
for( int i = 0 ; i < globalImages->images.Num() ; i++ )
{
if( globalImages->images[i] )
{
globalImages->images[i]->Bind();
globalImages->images[i]->SetTexParameters();
}
}
}
extern idCVar r_useSeamlessCubeMap;
if( r_useSeamlessCubeMap.IsModified() )
{
r_useSeamlessCubeMap.ClearModified();
if( glConfig.seamlessCubeMapAvailable )
{
if( r_useSeamlessCubeMap.GetBool() )
{
qglEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
}
else
{
qglDisable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
}
}
}
extern idCVar r_useSRGB;
if( r_useSRGB.IsModified() )
{
r_useSRGB.ClearModified();
if( glConfig.sRGBFramebufferAvailable )
{
if( r_useSRGB.GetBool() )
{
qglEnable( GL_FRAMEBUFFER_SRGB );
}
else
{
qglDisable( GL_FRAMEBUFFER_SRGB );
}
}
}
if( r_multiSamples.IsModified() )
{
if( r_multiSamples.GetInteger() > 0 )
{
qglEnable( GL_MULTISAMPLE_ARB );
}
else
{
qglDisable( GL_MULTISAMPLE_ARB );
}
}
// check for changes to logging state
GLimp_EnableLogging( r_logFile.GetInteger() != 0 );
}
示例15: 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();
//.........这里部分代码省略.........