本文整理匯總了C++中glDepthRange函數的典型用法代碼示例。
如果您正苦於以下問題:C++ glDepthRange函數的具體用法?C++ glDepthRange怎麽用?C++ glDepthRange使用的 ...
當前位置:首頁>>代碼示例>>C++>>正文
本文整理匯總了C++中glDepthRange函數的典型用法代碼示例。
如果您正苦於以下問題:C++glDepthRange函數的具體用法?C++glDepthRange怎麽用?C++glDepthRange使用的例子?那麽恭喜您,這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了glDepthRange函數的20個代碼示例,這些例子默認根據受歡迎程度排序。
您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的C++代碼示例。
示例1:wxGetApp
點讚9
voidHPoint::glCommands(boolselect,boolmarked,boolno_color)
{
if(!no_color){
wxGetApp().glColorEnsuringContrast(color);
}
GLfloatsave_depth_range[2];
if(marked){
glGetFloatv(GL_DEPTH_RANGE,save_depth_range);
glDepthRange(0,0);
}
elseif(!m_draw_unselected)
{
glBegin(GL_POINTS);
glVertex3d(m_p.X(),m_p.Y(),m_p.Z());
glEnd();
return;
}
glRasterPos3d(m_p.X(),m_p.Y(),m_p.Z());
glBitmap(16,16,8,8,10.0,0.0,marked?cross16_selected:cross16);
if(marked){
glDepthRange(save_depth_range[0],save_depth_range[1]);
}
}開發者ID:CarlosGS,項目名稱:heekscad,代碼行數:25,代碼來源:HPoint.cpp
示例2:R_DrawViewModel
點讚7
/*
=============
R_DrawViewModel--johnfitz--gutted
=============
*/
voidR_DrawViewModel(void)
{
if(!r_drawviewmodel.value||!r_drawentities.value||chase_active.value)
return;
if(cl.items&IT_INVISIBILITY||cl.stats[STAT_HEALTH]<=0)
return;
if(vr_enabled.value&&vr_crosshair.value)
VR_ShowCrosshair();
currententity=&cl.viewent;
if(!currententity->model)
return;
//johnfitz--thisfixesacrash
if(currententity->model->type!=mod_alias)
return;
//johnfitz
//hackthedepthrangetopreventviewmodelfrompokingintowalls
glDepthRange(0,0.3);
R_DrawAliasModel(currententity);
glDepthRange(0,1);
}開發者ID:phoboslab,項目名稱:Quakespasm-Rift,代碼行數:30,代碼來源:gl_rmain.c
示例3:R_DrawSkyChain
點讚5
voidR_DrawSkyChain(msurface_t*surf)
{
msurface_t*reversechain=NULL;
intnumindexes=0;
if(!surf)return;
//pushthedepthrangebacktofarendofthez-buffer
//roguehassomepretty-unusual-brushplacementandneedsthis
glDepthRange(gldepthmax,gldepthmax);
glProgramUniformMatrix4fv(gl_skycubeprog,u_skylocalMatrix,1,GL_FALSE,r_mvpmatrix.m[0]);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
GL_UseProgram(gl_skycubeprog);
GL_BindTexture(GL_TEXTURE0,GL_TEXTURE_CUBE_MAP,r_skysampler,r_skytexture);
GL_Enable(DEPTHTEST_BIT|(gl_cull->value?CULLFACE_BIT:0));
for(;surf;surf=surf->texturechain)
{
surf->reversechain=reversechain;
reversechain=surf;
numindexes+=surf->numindexes;
}
R_DrawSurfaceChain(reversechain,numindexes);
glDepthRange(gldepthmin,gldepthmax);
glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
}開發者ID:raynorpat,項目名稱:cake,代碼行數:29,代碼來源:r_sky.c
示例4:RenderFrameOpenGL
點讚2
//使用OpenGL來繪圖
voidRenderFrameOpenGL(void)
{
Vector4vPlane(0.0f,0.0f,1.0f,-g_mirror_z);
//清除畫麵
glClearColor(0.0f,0.0f,0.5f,1.0f);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
//畫出茶壼
RenderModelOpenGL(false,NULL);
//設定轉換矩陣
Matrix4x4view_matrix=g_Control.GetViewMatrix();;
Matrix4x4world_view_matrix=view_matrix;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float*)&g_projection_matrix);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float*)&world_view_matrix);
sModelMaterial_OpenGLmaterial;
material.Submit(NULL);
//設定頂點資料格式
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,sizeof(Vertex_V),&g_Quad_v[0].m_Position);
//畫出鏡子,同時把鏡子部分的stencilbuffer設為1.
{
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS,1,0xff);
glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE);
glColor4f(0.0f,0.0f,0.0f,1.0f);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
}
//把鏡子部分的zbuffer清為1.0
{
glStencilFunc(GL_EQUAL,1,0xff);
glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
//把z值的輸出範圍設定為1~1,也就是z永遠輸出1.
glDepthRange(1.0f,1.0f);
glDepthFunc(GL_ALWAYS);
//隻更新zbuffer,不需要更新顏色.
glColorMask(false,false,false,false);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
//恢復更新顏色的功能
glColorMask(true,true,true,true);
glDepthFunc(GL_LESS);
//把z值的範圍還原為0~1
glDepthRange(0.0f,1.0f);
}
//畫出鏡子裏的茶壼
{
glColor4f(1.0f,1.0f,1.0f,1.0f);
RenderModelOpenGL(true,&vPlane);
glDisable(GL_STENCIL_TEST);
}
//把背景backbuffer的畫麵呈現出來
GutSwapBuffersOpenGL();
}開發者ID:chenbk85,項目名稱:3dlearn,代碼行數:59,代碼來源:render_opengl.cpp
示例5:MyDisplay
點讚1
staticvoidMyDisplay(void)
{
staticintstarttime,stoptime;
starttime=glutGet(GLUT_ELAPSED_TIME);
glViewport(0,0,winWidth,winHeight);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,(double)winWidth/winHeight,model.radius,10.0*model.radius);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslated(0.0,0.0,-2.5*model.radius);
glPushMatrix();
tb.applyTransform();
glTranslatef(-model.center[0],-model.center[1],-model.center[2]);
glDepthRange(DEPTH_OFFSET,1.0);//Thisisforoutlinedfill.
//Drawaxes.
if(drawAxes)DrawAxes(2.0*model.radius);
if(drawStyle==0||drawStyle==2)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //Filledoroutlinedfill.
else
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); //Wireframe.
glCallList(gathererQuadsDList); //Drawgathererquads.
if(drawStyle==2) //Drawtheoutlinesoftheoutlinedfillstyle.
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_LIGHTING);
glDepthFunc(GL_LEQUAL);
glDepthRange(0.0,1.0-DEPTH_OFFSET);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); //Wireframe.
glLineWidth(1.0);
glColor3f(0.0f,0.0f,0.0f);
glCallList(gathererQuadsNoColorDList); //Drawgathererquads.
glPopAttrib();
}
glPopMatrix();
glutSwapBuffers();
stoptime=glutGet(GLUT_ELAPSED_TIME);
doublefps=1.0/((stoptime-starttime)/1000.0);
staticchars[256];
sprintf(s,"RadiosityViewer(%.1fFPS)",fps);
glutSetWindowTitle(s);
}開發者ID:emadhamdybri,項目名稱:edisontsui,代碼行數:55,代碼來源:radiosityviewer.cpp
示例6:piglit_display
點讚1
enumpiglit_result
piglit_display(void)
{
GLbooleanpass=GL_TRUE;
intx,y;
staticfloatred[]={1.0,0.0,0.0,0.0};
staticfloatgreen[]={0.0,1.0,0.0,0.0};
piglit_ortho_projection(piglit_width,piglit_height,GL_FALSE);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0,1.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor4fv(red);
glClearDepth(0.5);
glClear(GL_DEPTH_BUFFER_BIT);
draw_rect_set(10);
glDepthRange(0.5,1.0);
glClearDepth(0.5);
glClear(GL_DEPTH_BUFFER_BIT);
glDepthRange(0.0,1.0);
draw_rect_set(30);
glDepthRange(0.0,0.5);
glClearDepth(0.5);
glClear(GL_DEPTH_BUFFER_BIT);
glDepthRange(0.0,1.0);
draw_rect_set(50);
for(y=0;y<3;y++){
for(x=0;x<4;x++){
float*expected;
if(x<2)
expected=green;
else
expected=red;
pass&=piglit_probe_pixel_rgb(15+x*20,15+y*20,
expected);
}
}
glutSwapBuffers();
returnpass?PIGLIT_PASS:PIGLIT_FAIL;
}開發者ID:nobled,項目名稱:piglit,代碼行數:51,代碼來源:depthrange-clear.c
示例7:deviceRay
點讚1
voidMouseCursorFaker::glRenderActionTransparent(GLContextData&contextData)const
{
/*Getthedataitem:*/
DataItem*dataItem=contextData.retrieveDataItem(this);
/*Calculatethedevice'srayequation:*/
RaydeviceRay(device->getPosition(),device->getRayDirection());
/*Findthenearestscreenintersectedbythedeviceray:*/
std::pairfsResult=findScreen(deviceRay);
if(fsResult.first!=0)
{
/*Calculatethecursorpositiononthescreen:*/
PointcursorPos=deviceRay(fsResult.second);
Vectorx=fsResult.first->getScreenTransformation().getDirection(0)*cursorSize[0];
Vectory=fsResult.first->getScreenTransformation().getDirection(1)*cursorSize[1];
cursorPos-=x*cursorHotspot[0];
cursorPos-=y*cursorHotspot[1];
/*Drawthemousecursor:*/
glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT);
GLdoubledepthRange[2];
glGetDoublev(GL_DEPTH_RANGE,depthRange);
glDepthRange(0.0,0.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,dataItem->textureObjectId);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL,0.5f);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
glBegin(GL_QUADS);
glTexCoord(cursorTexCoordBox.getVertex(0));
glVertex(cursorPos);
glTexCoord(cursorTexCoordBox.getVertex(1));
cursorPos+=x;
glVertex(cursorPos);
glTexCoord(cursorTexCoordBox.getVertex(3));
cursorPos+=y;
glVertex(cursorPos);
glTexCoord(cursorTexCoordBox.getVertex(2));
cursorPos-=x;
glVertex(cursorPos);
glEnd();
glBindTexture(GL_TEXTURE_2D,0);
glDepthRange(depthRange[0],depthRange[1]);
glPopAttrib();
}
}開發者ID:VisualIdeation,項目名稱:Vrui-2.2-003,代碼行數:49,代碼來源:MouseCursorFaker.cpp
示例8:glViewport
點讚1
voidQSceneWidget::resizeGL(intwidth,intheight)
{
//makeCurrent();
glViewport(0,0,width,height);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glDepthRange(0.0f,1.0f);
glClearDepth(1.0f);
doubleznear=0.1;
doublezfar=500.0;
doubleaspect=(double)width/(double)height;
doublefov=90.0/aspect;
#if!defined(QT_OPENGL_ES_2)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
constdoubleDEG2RAD=3.14159265/180;
doubletangent=tan(fov/2*DEG2RAD);//tangentofhalffovY
doubleh=znear*tangent;//halfheightofnearplane
doublew=h*aspect;//halfwidthofnearplane
//params:left,right,bottom,top,near,far
glFrustum(-w,w,-h,h,znear,zfar);
#else
perspectiveMatrix.setToIdentity();
perspectiveMatrix.perspective(fov,aspect,znear,zfar);
std::cout<logEnter("QGLView::initializeGL");
QGLPainterpainter;
painter.begin();
//Setthedefaultdepthbufferoptions.
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDepthMask(GL_TRUE);
#ifdefined(QT_OPENGL_ES)
glDepthRangef(0.0f,1.0f);
#else
glDepthRange(0.0f,1.0f);
#endif
//Setthedefaultblendoptions.
if(painter.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
painter.glBlendColor(0,0,0,0);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
if(painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
painter.glBlendEquation(GL_FUNC_ADD);
elseif(painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
painter.glBlendEquationSeparate(GL_FUNC_ADD,GL_FUNC_ADD);
glDisable(GL_CULL_FACE);
initializeGL(&painter);
d->logLeave("QGLView::initializeGL");
}開發者ID:Haider-BA,項目名稱:walberla,代碼行數:32,代碼來源:qglview.cpp
示例13:glfwWindowHint
點讚1
Display::Display(intwidth,intheight,conststd::string&title){
if(!glfwInit()){
throw-1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE);
window_=glfwCreateWindow(width,height,title.c_str(),NULL,NULL);
//window_=glfwCreateWindow(width,height,title.c_str(),glfwGetPrimaryMonitor(),NULL);
if(!window_){
glfwTerminate();
throwException("GLFWwindowcouldnotbecreated");
}
glfwMakeContextCurrent(window_);
glfwSwapInterval(1);
glClearColor(0.f,0.f,0.f,0.f);
glClearDepth(1.0f);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glDepthRange(0.0f,1.0f);
}開發者ID:stuartwakefield,項目名稱:opengl-basics,代碼行數:30,代碼來源:Display.cpp
示例14:init
點讚1
GLUSbooleaninit()
{
g_program=loadProgram("./position_texture.vert","./texture_color.frag");
g_pCorridor=newMesh("./model/Corridor.xml");
g_pPlane=newMesh("./model/BigPlane.xml");
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
constfloatdepthZNear=0.0f;
constfloatdepthZFar=1.0f;
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRange(depthZNear,depthZFar);
glEnable(GL_DEPTH_CLAMP);
glGenBuffers(1,&g_projectionUniformBuffer);
glBindBuffer(GL_UNIFORM_BUFFER,g_projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER,sizeof(ProjectionBlock),NULL,GL_DYNAMIC_DRAW);
glBindBufferRange(GL_UNIFORM_BUFFER,g_projectionBlockIndex,g_projectionUniformBuffer,
0,sizeof(ProjectionBlock));
glBindBuffer(GL_UNIFORM_BUFFER,0);
initCheckerTexture();
initdMipmapTexture();
initSamplers();
returnGLUS_TRUE;
}開發者ID:cntoplolicon,項目名稱:grape,代碼行數:35,代碼來源:texture_filtering.cpp
示例15:init
點讚1
//CalledafterthewindowandOpenGLareinitialized.Calledexactlyonce,beforethemainloop.
voidinit()
{
InitializeProgram();
try
{
coneMesh=newFramework::Mesh("UnitConeTint.xml");
cylinderMesh=newFramework::Mesh("UnitCylinderTint.xml");
cubeTintMesh=newFramework::Mesh("UnitCubeTint.xml");
cubeColorMesh=newFramework::Mesh("UnitCubeColor.xml");
planeMesh=newFramework::Mesh("UnitPlane.xml");
}
catch(std::exception&except)
{
printf("%s\n",except.what());
throw;
}
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CW);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRange(0.0f,1.0f);
glEnable(GL_DEPTH_CLAMP);
}開發者ID:captainadamo,項目名稱:glfw_gltut,代碼行數:29,代碼來源:World+with+UBO.cpp
示例16:main
點讚1
intmain(intargc,char**argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(600,600);
glutCreateWindow("Demo");
glClearColor(0.0f,0.0f,0.0f,1.0f);
glEnable(GL_DEPTH_TEST);
glDepthRange(0.0,1.0);
glDepthFunc(GL_LEQUAL);
setCubes();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glFrontFace(GL_CCW);
glEnable(GL_NORMALIZE);
glutKeyboardFunc(keyboardDown);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutTimerFunc(16,update,0);
glutMainLoop();
return(0);
}開發者ID:Joel714,項目名稱:CubeCollision,代碼行數:26,代碼來源:main.cpp
示例17:fboEpilogue
點讚1
staticvoid
fboEpilogue(CompScreen*s)
{
(*s->bindFramebuffer)(GL_FRAMEBUFFER_EXT,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDepthRange(0,1);
glViewport(-1,-1,2,2);
glRasterPos2f(0,0);
s->rasterX=s->rasterY=0;
setDefaultViewport(s);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
}開發者ID:SubwayDesktop,項目名稱:compiz-stable,代碼行數:25,代碼來源:water.c
示例18:init
點讚1
voidinit(void){
gouraudShading=createShaderProgram("vertexShaderSource.vert","fragmentShaderSource.frag",g_projectionBlockIndex);
if(gouraudShading->linkStatus==GL_FALSE)
exit(0);
initWireRect();
setPrespectiveProjection();
genUniformBuffer();
loadLights();
gLoadIdentity();
gSaveTop(orientationMatrix);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRange(0.0f,1.0f);
glEnable(GL_DEPTH_CLAMP);
objectsArray=(meshObject**)malloc(sizeof(meshObject*)*MAX_OBJECTS);
loadPointMeshFile();
loadPointMeshFile();
userDefinedSegmentVertex=createArrayListf();
userDefinedSegmentColor=createArrayListui();
setMarkingColor();
}開發者ID:Dimitryk,項目名稱:repo,代碼行數:31,代碼來源:Program.c
示例19:glClearColor
點讚1
voidsa::MeshRenderer::init(){
glClearColor(0.2f,0.3f,0.5f,1.0f);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
glDepthRange(0,1);
glClearDepth(1);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
m_rectangle=PolygonTesselator>().tesselate(Shape::makeBox(2.f));
m_rectangle->build();
sa::vec4uvLimits=sa::TextureHandler::getSingleton().textureLimits("Empty",vec4(0.5f,0.5f,1.0f,1.0f));
m_line=PolygonTesselator>().tesselate(Shape::makeBox(1.f),uvLimits);
m_line->build();
std::shared_ptrshader2d=m_shaders->loadShader("renderer2d","../shaders/2d_shader_130.vs.glsl","../shaders/2d_shader_130.fs.glsl");
m_shaders->switchToShader("renderer2d");
m_modelUniform=shader2d->uniform("model");
m_viewUniform=shader2d->uniform("view");
m_projectionUniform=shader2d->uniform("projection");
m_colorUniform=shader2d->uniform("color");
m_texSamplerUniform=shader2d->uniform("tex");
glUniform1i(m_texSamplerUniform,0);
}開發者ID:Apodus,項目名稱:game_one,代碼行數:30,代碼來源:meshrenderer.cpp
示例20:glEnable
點讚1
/*!
\internal
*/
voidQGLView::initializeGL()
{
d->logEnter("QGLView::initializeGL");
QGLPainterpainter;
painter.begin();
//Setthedefaultdepthbufferoptions.
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDepthMask(GL_TRUE);
#ifdefined(QT_OPENGL_ES)
glDepthRangef(0.0f,1.0f);
#else
glDepthRange(0.0f,1.0f);
#endif
//Setthedefaultblendoptions.
qt_gl_BlendColor(0,0,0,0);
qt_gl_BlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
qt_gl_BlendEquation(GL_FUNC_ADD);
painter.setCullFaces(QGL::CullDisabled);
initializeGL(&painter);
d->logLeave("QGLView::initializeGL");
}開發者ID:slavablind91,項目名稱:code,代碼行數:28,代碼來源:qglview.cpp
注:本文中的glDepthRange函數示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。