本文整理汇总了C++中qglFinish函数的典型用法代码示例。如果您正苦于以下问题:C++ qglFinish函数的具体用法?C++ qglFinish怎么用?C++ qglFinish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qglFinish函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qglFinish
/**
* @brief RB_Finish
* @param[in] data
* @return
*/
const void *RB_Finish(const void *data)
{
const renderFinishCommand_t *cmd = ( const renderFinishCommand_t * ) data;
//ri.Printf( PRINT_ALL, "RB_Finish\n" );
qglFinish();
return ( const void * ) (cmd + 1);
}
示例2: RB_EndSurface
/**
* @brief RB_SwapBuffers
* @param[in] data
* @return
*/
const void *RB_SwapBuffers(const void *data)
{
const swapBuffersCommand_t *cmd;
// finish any 2D drawing if needed
if (tess.numIndexes)
{
RB_EndSurface();
}
// texture swapping test
if (r_showImages->integer)
{
RB_ShowImages();
}
RB_GammaScreen();
cmd = ( const swapBuffersCommand_t * ) data;
// we measure overdraw by reading back the stencil buffer and
// counting up the number of increments that have happened
if (r_measureOverdraw->integer)
{
int i;
long sum = 0;
unsigned char *stencilReadback;
stencilReadback = ri.Hunk_AllocateTempMemory(glConfig.vidWidth * glConfig.vidHeight);
qglReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback);
for (i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++)
{
sum += stencilReadback[i];
}
backEnd.pc.c_overDraw += sum;
ri.Hunk_FreeTempMemory(stencilReadback);
}
if (!glState.finishCalled)
{
qglFinish();
}
Ren_LogComment("***************** RB_SwapBuffers *****************\n\n\n");
ri.GLimp_SwapFrame();
backEnd.projection2D = qfalse;
return ( const void * ) (cmd + 1);
}
示例3: GLimp_DeactivateContext
/*
===================
GLimp_DeactivateContext
===================
*/
void GLimp_DeactivateContext( void ) {
qglFinish();
if ( !qwglMakeCurrent( win32.hDC, NULL ) ) {
win32.wglErrors++;
}
#ifdef REALLOC_DC
// makeCurrent NULL frees the DC, so get another
if ( ( win32.hDC = GetDC( win32.hWnd ) ) == NULL ) {
win32.wglErrors++;
}
#endif
}
示例4: RadiantInit
/*
=================
RadiantInit
This is also called when you 'quit' in doom
=================
*/
void RadiantInit( void ) {
// make sure the renderer is initialized
if ( !renderSystem->IsOpenGLRunning() ) {
common->Printf( "no OpenGL running\n" );
return;
}
g_editorAlive = true;
// allocate a renderWorld and a soundWorld
if ( g_qeglobals.rw == NULL ) {
g_qeglobals.rw = renderSystem->AllocRenderWorld();
g_qeglobals.rw->InitFromMap( NULL );
}
if ( g_qeglobals.sw == NULL ) {
g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw );
}
if ( g_DoomInstance ) {
if ( ::IsWindowVisible( win32.hWnd ) ) {
::ShowWindow( win32.hWnd, SW_HIDE );
g_pParentWnd->ShowWindow( SW_SHOW );
g_pParentWnd->SetFocus();
}
} else {
Sys_GrabMouseCursor( false );
g_DoomInstance = win32.hInstance;
CWinApp* pApp = AfxGetApp();
CWinThread *pThread = AfxGetThread();
InitAfx();
// App global initializations (rare)
pApp->InitApplication();
// Perform specific initializations
pThread->InitInstance();
qglFinish();
//qwglMakeCurrent(0, 0);
qwglMakeCurrent(win32.hDC, win32.hGLRC);
// hide the doom window by default
::ShowWindow( win32.hWnd, SW_HIDE );
}
}
示例5: RB_SwapBuffers
/*
=============
RB_SwapBuffers
=============
*/
const void RB_SwapBuffers( const void *data ) {
// texture swapping test
if ( r_showImages.GetInteger() != 0 ) {
RB_ShowImages();
}
// force a gl sync if requested
if ( r_finish.GetBool() ) {
qglFinish();
}
RB_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
// don't flip if drawing to front buffer
if ( !r_frontBuffer.GetBool() ) {
GLimp_SwapBuffers();
}
}
示例6: R_EndOcclusionPass
/*
* R_EndOcclusionPass
*/
void R_EndOcclusionPass( void )
{
assert( OCCLUSION_QUERIES_ENABLED( ri ) );
R_RenderOccludingSurfaces();
R_SurfIssueOcclusionQueries();
R_BackendResetPassMask();
R_BackendResetCounters();
if( r_occlusion_queries_finish->integer )
qglFinish();
else
qglFlush();
qglEnable( GL_TEXTURE_2D );
}
示例7: GLimp_TestSwapBuffers
/*
========================
GLimp_TestSwapBuffers
========================
*/
void GLimp_TestSwapBuffers( const idCmdArgs& args )
{
idLib::Printf( "GLimp_TimeSwapBuffers\n" );
static const int MAX_FRAMES = 5;
uint64 timestamps[MAX_FRAMES];
qglDisable( GL_SCISSOR_TEST );
int frameMilliseconds = 16;
for( int swapInterval = 2 ; swapInterval >= -1 ; swapInterval-- )
{
wglSwapIntervalEXT( swapInterval );
for( int i = 0 ; i < MAX_FRAMES ; i++ )
{
if( swapInterval == -1 )
{
Sys_Sleep( frameMilliseconds );
}
if( i & 1 )
{
qglClearColor( 0, 1, 0, 1 );
}
else
{
qglClearColor( 1, 0, 0, 1 );
}
qglClear( GL_COLOR_BUFFER_BIT );
qwglSwapBuffers( win32.hDC );
qglFinish();
timestamps[i] = Sys_Microseconds();
}
idLib::Printf( "\nswapinterval %i\n", swapInterval );
for( int i = 1 ; i < MAX_FRAMES ; i++ )
{
idLib::Printf( "%i microseconds\n", ( int )( timestamps[i] - timestamps[i - 1] ) );
}
}
}
示例8: GLimp_EndFrame
/*
** GLimp_EndFrame
**
** Responsible for doing a swapbuffers and possibly for other stuff
** as yet to be determined. Probably better not to make this a GLimp
** function and instead do a call to GLimp_SwapBuffers.
*/
void GLimp_EndFrame (void)
{
#if 0
int err;
if ( !glState.finishCalled )
qglFinish();
// check for errors
if ( !gl_ignore_errors->value ) {
if ( ( err = qglGetError() ) != GL_NO_ERROR )
{
ri.Error( ERR_FATAL, "GLimp_EndFrame() - glGetError() failed (0x%x)!\n", err );
}
}
#endif
// don't flip if drawing to front buffer
if ( stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
{
qglXSwapBuffers(dpy, win);
}
// check logging
QGL_EnableLogging( r_logFile->value );
#if 0
GLimp_LogComment( "*** RE_EndFrame ***\n" );
// decrement log
if ( gl_log->value )
{
ri.Cvar_Set( "gl_log", va("%i",gl_log->value - 1 ) );
}
#endif
}
示例9: RB_BeginDrawingView
/*
=================
RB_BeginDrawingView
Any mirrored or portaled views have already been drawn, so prepare
to actually render the visible surfaces for this view
=================
*/
void RB_BeginDrawingView (void) {
int clearBits = 0;
// sync with gl if needed
if ( r_finish->integer == 1 && !glState.finishCalled ) {
qglFinish ();
glState.finishCalled = qtrue;
}
if ( r_finish->integer == 0 ) {
glState.finishCalled = qtrue;
}
// we will need to change the projection matrix before drawing
// 2D images again
backEnd.projection2D = qfalse;
if (glRefConfig.framebufferObject)
{
FBO_t *fbo = backEnd.viewParms.targetFbo;
// FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world
// drawing more world check is in case of double renders, such as skyportals
if (fbo == NULL && !(backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)))
fbo = tr.renderFbo;
if (tr.renderCubeFbo && fbo == tr.renderCubeFbo)
{
cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex];
FBO_AttachImage(fbo, cubemap->image, GL_COLOR_ATTACHMENT0_EXT, backEnd.viewParms.targetFboLayer);
}
FBO_Bind(fbo);
}
//
// set the modelview matrix for the viewer
//
SetViewportAndScissor();
// ensures that depth writes are enabled for the depth clear
GL_State( GLS_DEFAULT );
// clear relevant buffers
clearBits = GL_DEPTH_BUFFER_BIT;
if ( r_measureOverdraw->integer || r_shadows->integer == 2 )
{
clearBits |= GL_STENCIL_BUFFER_BIT;
}
if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )
{
clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used
}
// clear to black for cube maps
if (tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo)
{
clearBits |= GL_COLOR_BUFFER_BIT;
}
qglClear( clearBits );
if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) )
{
RB_Hyperspace();
return;
}
else
{
backEnd.isHyperspace = qfalse;
}
// we will only draw a sun if there was sky rendered in this view
backEnd.skyRenderedThisView = qfalse;
// clip to the plane of the portal
if ( backEnd.viewParms.isPortal ) {
#if 0
float plane[4];
GLdouble plane2[4];
plane[0] = backEnd.viewParms.portalPlane.normal[0];
plane[1] = backEnd.viewParms.portalPlane.normal[1];
plane[2] = backEnd.viewParms.portalPlane.normal[2];
plane[3] = backEnd.viewParms.portalPlane.dist;
plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane);
plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);
plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
#endif
GL_SetModelviewMatrix( s_flipMatrix );
}
//.........这里部分代码省略.........
示例10: RB_BeginDrawingView
/*
* RB_BeginDrawingView
*
* Any mirrored or portaled views have already been drawn, so prepare
* to actually render the visible surfaces for this view
*/
void
RB_BeginDrawingView(void)
{
int clearBits = 0;
/* sync with gl if needed */
if(r_finish->integer == 1 && !glState.finishCalled){
qglFinish ();
glState.finishCalled = qtrue;
}
if(r_finish->integer == 0){
glState.finishCalled = qtrue;
}
/* we will need to change the projection matrix before drawing
* 2D images again */
backEnd.projection2D = qfalse;
if(glRefConfig.framebufferObject){
/* FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world */
if(backEnd.viewParms.targetFbo == tr.renderFbo && backEnd.framePostProcessed &&
(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)){
FBO_Bind(tr.screenScratchFbo);
}else{
FBO_Bind(backEnd.viewParms.targetFbo);
}
}
/*
* set the modelview matrix for the viewer
* */
SetViewportAndScissor();
/* ensures that depth writes are enabled for the depth clear */
GL_State(GLS_DEFAULT);
/* clear relevant buffers */
clearBits = GL_DEPTH_BUFFER_BIT;
if(r_measureOverdraw->integer || r_shadows->integer == 2){
clearBits |= GL_STENCIL_BUFFER_BIT;
}
if(r_fastsky->integer && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)){
clearBits |= GL_COLOR_BUFFER_BIT; /* FIXME: only if sky shaders have been used */
#ifdef _DEBUG
qglClearColor(0.8f, 0.7f, 0.4f, 1.0f); /* FIXME: get color of sky */
#else
qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); /* FIXME: get color of sky */
#endif
}
/* clear to white for shadow maps */
if(backEnd.viewParms.isShadowmap){
clearBits |= GL_COLOR_BUFFER_BIT;
qglClearColor(1.0f, 1.0f, 1.0f, 1.0f);
}
qglClear(clearBits);
if((backEnd.refdef.rdflags & RDF_HYPERSPACE)){
RB_Hyperspace();
return;
}else{
backEnd.isHyperspace = qfalse;
}
glState.faceCulling = -1; /* force face culling to set next time */
/* we will only draw a sun if there was sky rendered in this view */
backEnd.skyRenderedThisView = qfalse;
#ifdef REACTION
backEnd.hasSunFlare = qfalse;
#endif
/* clip to the plane of the portal */
if(backEnd.viewParms.isPortal){
float plane[4];
double plane2[4];
plane[0] = backEnd.viewParms.portalPlane.normal[0];
plane[1] = backEnd.viewParms.portalPlane.normal[1];
plane[2] = backEnd.viewParms.portalPlane.normal[2];
plane[3] = backEnd.viewParms.portalPlane.dist;
plane2[0] = dotv3 (backEnd.viewParms.or.axis[0], plane);
plane2[1] = dotv3 (backEnd.viewParms.or.axis[1], plane);
plane2[2] = dotv3 (backEnd.viewParms.or.axis[2], plane);
plane2[3] = dotv3 (plane, backEnd.viewParms.or.origin) - plane[3];
GL_SetModelviewMatrix(s_flipMatrix);
}
}
示例11: RE_StretchRaw
/*
* RE_StretchRaw
*
* FIXME: not exactly backend
* Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle.
* Used for cinematics.
*/
void
RE_StretchRaw(int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qbool dirty)
{
int i, j;
int start, end;
shaderProgram_t *sp = &tr.textureColorShader;
Vec4 color;
if(!tr.registered){
return;
}
R_SyncRenderThread();
/* we definately want to sync every frame for the cinematics */
qglFinish();
start = 0;
if(r_speeds->integer){
start = ri.Milliseconds();
}
/* make sure rows and cols are powers of 2 */
for(i = 0; (1 << i) < cols; i++){
}
for(j = 0; (1 << j) < rows; j++){
}
if((1 << i) != cols || (1 << j) != rows){
ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows);
}
GL_Bind(tr.scratchImage[client]);
/* if the scratchImage isn't in the format we want, specify it as a new texture */
if(cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height){
tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols;
tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows;
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
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_TO_EDGE);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}else{
if(dirty){
/* otherwise, just subimage upload it so that drivers can tell we are going to be changing
* it and don't try and do a texture compression */
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
}
if(r_speeds->integer){
end = ri.Milliseconds();
ri.Printf(PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start);
}
/* FIXME: HUGE hack */
if(glRefConfig.framebufferObject && !glState.currentFBO){
if(backEnd.framePostProcessed){
FBO_Bind(tr.screenScratchFbo);
}else{
FBO_Bind(tr.renderFbo);
}
}
RB_SetGL2D();
tess.numIndexes = 0;
tess.numVertexes = 0;
tess.firstIndex = 0;
tess.xyz[tess.numVertexes][0] = x;
tess.xyz[tess.numVertexes][1] = y;
tess.xyz[tess.numVertexes][2] = 0;
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = 0.5f / cols;
tess.texCoords[tess.numVertexes][0][1] = 0.5f / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = x + w;
tess.xyz[tess.numVertexes][1] = y;
tess.xyz[tess.numVertexes][2] = 0;
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = (cols - 0.5f) / cols;
tess.texCoords[tess.numVertexes][0][1] = 0.5f / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = x + w;
tess.xyz[tess.numVertexes][1] = y + h;
tess.xyz[tess.numVertexes][2] = 0;
tess.xyz[tess.numVertexes][3] = 1;
//.........这里部分代码省略.........
示例12: RE_StretchRaw
/*
=============
RE_StretchRaw
FIXME: not exactly backend
Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle.
Used for cinematics.
=============
*/
void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) {
int i, j;
int start, end;
vec4_t quadVerts[4];
vec2_t texCoords[4];
if ( !tr.registered ) {
return;
}
R_IssuePendingRenderCommands();
if ( tess.numIndexes ) {
RB_EndSurface();
}
// we definately want to sync every frame for the cinematics
qglFinish();
start = 0;
if ( r_speeds->integer ) {
start = ri.Milliseconds();
}
// make sure rows and cols are powers of 2
for ( i = 0 ; ( 1 << i ) < cols ; i++ ) {
}
for ( j = 0 ; ( 1 << j ) < rows ; j++ ) {
}
if ( ( 1 << i ) != cols || ( 1 << j ) != rows) {
ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows);
}
RE_UploadCinematic (w, h, cols, rows, data, client, dirty);
if ( r_speeds->integer ) {
end = ri.Milliseconds();
ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start );
}
// FIXME: HUGE hack
if (glRefConfig.framebufferObject)
{
if (!tr.renderFbo || backEnd.framePostProcessed)
{
FBO_Bind(NULL);
}
else
{
FBO_Bind(tr.renderFbo);
}
}
RB_SetGL2D();
VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f);
VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f);
VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f);
VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f);
VectorSet2(texCoords[0], 0.5f / cols, 0.5f / rows);
VectorSet2(texCoords[1], (cols - 0.5f) / cols, 0.5f / rows);
VectorSet2(texCoords[2], (cols - 0.5f) / cols, (rows - 0.5f) / rows);
VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows);
GLSL_BindProgram(&tr.textureColorShader);
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
RB_InstantQuad2(quadVerts, texCoords);
}
示例13: RB_SwapBuffers
/*
* RB_SwapBuffers
*
*/
const void *
RB_SwapBuffers(const void *data)
{
const swapBuffersCommand_t *cmd;
/* finish any 2D drawing if needed */
if(tess.numIndexes){
RB_EndSurface();
}
/* texture swapping test */
if(r_showImages->integer){
RB_ShowImages();
}
cmd = (const swapBuffersCommand_t*)data;
/* we measure overdraw by reading back the stencil buffer and
* counting up the number of increments that have happened */
if(r_measureOverdraw->integer){
int i;
long sum = 0;
unsigned char *stencilReadback;
stencilReadback = ri.hunkalloctemp(glConfig.vidWidth * glConfig.vidHeight);
qglReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
stencilReadback);
for(i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++)
sum += stencilReadback[i];
backEnd.pc.c_overDraw += sum;
ri.hunkfreetemp(stencilReadback);
}
if(glRefConfig.framebufferObject){
/* copy final image to screen */
Vec2 texScale;
Vec4 srcBox, dstBox, white;
texScale[0] =
texScale[1] = 1.0f;
white[0] =
white[1] =
white[2] = pow(2, tr.overbrightBits); /* exp2(tr.overbrightBits); */
white[3] = 1.0f;
setv34(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
if(backEnd.framePostProcessed){
/* frame was postprocessed into screen fbo, copy from there */
setv34(srcBox, 0, 0, tr.screenScratchFbo->width, tr.screenScratchFbo->height);
FBO_Blit(tr.screenScratchFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader,
white,
0);
}else{
/* frame still in render fbo, copy from there */
setv34(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
FBO_Blit(tr.renderFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, white,
0);
}
}
if(!glState.finishCalled){
qglFinish();
}
GLimp_LogComment("***************** RB_SwapBuffers *****************\n\n\n");
GLimp_EndFrame();
backEnd.framePostProcessed = qfalse;
backEnd.projection2D = qfalse;
return (const void*)(cmd + 1);
}
示例14: Z_Draw
//.........这里部分代码省略.........
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_BLEND);
qglDisable(GL_DEPTH_TEST);
// draw filled interiors and edges
dir_up[0] = 0 ; dir_up[1] = 0; dir_up[2] = 1;
dir_down[0] = 0 ; dir_down[1] = 0; dir_down[2] = -1;
VectorCopy (z.origin, org_top);
org_top[2] = MAX_WORLD_COORD;//4096; // MAX_WORLD_COORD ? (John said this didn't work, Hmmmmmm) // !suspect!
VectorCopy (z.origin, org_bottom);
org_bottom[2] = MIN_WORLD_COORD;//-4096; // MIN_WORLD_COORD? " " !suspect!
for (brush = active_brushes.next ; brush != &active_brushes ; brush=brush->next)
{
if (brush->mins[0] >= z.origin[0]
|| brush->maxs[0] <= z.origin[0]
|| brush->mins[1] >= z.origin[1]
|| brush->maxs[1] <= z.origin[1])
continue;
if (!Brush_Ray (org_top, dir_down, brush, &top))
continue;
top = org_top[2] - top;
if (!Brush_Ray (org_bottom, dir_up, brush, &bottom))
continue;
bottom = org_bottom[2] + bottom;
q = Texture_ForName (brush->brush_faces->texdef.name);
qglColor3f (q->color[0], q->color[1], q->color[2]);
qglBegin (GL_QUADS);
qglVertex2f (-xCam, bottom);
qglVertex2f (xCam, bottom);
qglVertex2f (xCam, top);
qglVertex2f (-xCam, top);
qglEnd ();
qglColor3f (1,1,1);
qglBegin (GL_LINE_LOOP);
qglVertex2f (-xCam, bottom);
qglVertex2f (xCam, bottom);
qglVertex2f (xCam, top);
qglVertex2f (-xCam, top);
qglEnd ();
}
//
// now draw selected brushes
//
for (brush = selected_brushes.next ; brush != &selected_brushes ; brush=brush->next)
{
if ( !(brush->mins[0] >= z.origin[0]
|| brush->maxs[0] <= z.origin[0]
|| brush->mins[1] >= z.origin[1]
|| brush->maxs[1] <= z.origin[1]) )
{
if (Brush_Ray (org_top, dir_down, brush, &top))
{
top = org_top[2] - top;
if (Brush_Ray (org_bottom, dir_up, brush, &bottom))
{
bottom = org_bottom[2] + bottom;
q = Texture_ForName (brush->brush_faces->texdef.name);
qglColor3f (q->color[0], q->color[1], q->color[2]);
qglBegin (GL_QUADS);
qglVertex2f (-xCam, bottom);
qglVertex2f (xCam, bottom);
qglVertex2f (xCam, top);
qglVertex2f (-xCam, top);
qglEnd ();
}
}
}
qglColor3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES]);
qglBegin (GL_LINE_LOOP);
qglVertex2f (-xCam, brush->mins[2]);
qglVertex2f (xCam, brush->mins[2]);
qglVertex2f (xCam, brush->maxs[2]);
qglVertex2f (-xCam, brush->maxs[2]);
qglEnd ();
}
ZDrawCameraIcon ();
ZDrawZClip();
qglFinish();
QE_CheckOpenGLForErrors();
if (z.timing)
{
end = Sys_DoubleTime ();
Sys_Printf ("z: %i ms\n", (int)(1000*(end-start)));
}
}
示例15: RB_ShowImages
/*
===============
RB_ShowImages
Draw all the images to the screen, on top of whatever
was there. This is used to test for texture thrashing.
Also called by RE_EndRegistration
===============
*/
void RB_ShowImages( void ) {
int i;
image_t *image;
float x, y, w, h;
int start, end;
if ( !backEnd.projection2D ) {
RB_SetGL2D();
}
qglClear( GL_COLOR_BUFFER_BIT );
qglFinish();
start = ri.Milliseconds();
for ( i = 0 ; i < tr.numImages ; i++ ) {
image = tr.images[i];
w = glConfig.vidWidth / 40;
h = glConfig.vidHeight / 30;
x = i % 40 * w;
y = i / 30 * h;
// show in proportional size in mode 2
if ( r_showImages->integer == 2 ) {
w *= image->uploadWidth / 512.0f;
h *= image->uploadHeight / 512.0f;
}
#ifdef USE_OPENGLES
GLfloat tex[] = {
0, 0,
1, 0,
1, 1,
0, 1 };
GLfloat vtx[] = {
x, y,
x + w, y,
x + w, y + h,
x, y + h };
GLboolean text = qglIsEnabled(GL_TEXTURE_COORD_ARRAY);
GLboolean glcol = qglIsEnabled(GL_COLOR_ARRAY);
if (glcol)
qglDisableClientState(GL_COLOR_ARRAY);
if (!text)
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, tex );
qglVertexPointer ( 2, GL_FLOAT, 0, vtx );
qglDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
if (glcol)
qglEnableClientState(GL_COLOR_ARRAY);
if (!text)
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
#else
GL_Bind( image );
qglBegin( GL_QUADS );
qglTexCoord2f( 0, 0 );
qglVertex2f( x, y );
qglTexCoord2f( 1, 0 );
qglVertex2f( x + w, y );
qglTexCoord2f( 1, 1 );
qglVertex2f( x + w, y + h );
qglTexCoord2f( 0, 1 );
qglVertex2f( x, y + h );
qglEnd();
#endif
}
qglFinish();
end = ri.Milliseconds();
ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start );
}