Changeset 538 for trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
- Timestamp:
- 01/14/06 01:41:57 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r535 r538 21 21 22 22 GlRendererWidget *rendererWidget = NULL; 23 GlDebuggerWidget *debuggerWidget = NULL; 23 24 24 25 … … 446 447 { 447 448 static int glList = -1; 448 if (glList != -1) { 449 glCallList(glList); 450 } else { 449 if (glList == -1) 450 { 451 451 glList = glGenLists(1); 452 glNewList(glList, GL_COMPILE _AND_EXECUTE);452 glNewList(glList, GL_COMPILE); 453 453 ObjectContainer::const_iterator oi = mObjects.begin(); 454 454 for (; oi != mObjects.end(); oi++) … … 456 456 glEndList(); 457 457 } 458 459 glCallList(glList); 460 458 461 return true; 459 462 } … … 565 568 GlRendererWidget::paintGL() 566 569 { 567 RenderErrors(); 568 mFrame++; 570 RenderErrors(); 571 572 mFrame++; 569 573 } 570 574 … … 780 784 GenQueries((int)beam.mViewCells.size()); 781 785 782 // now check whether any backfacing polygon would pass the depth test 786 // now check whether any backfacing polygon would pass the depth test? 783 787 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 784 788 glDepthMask(GL_FALSE); … … 799 803 800 804 // at this point, if possible, go and do some other computation 801 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 802 glDepthMask(GL_TRUE);803 glEnable(GL_CULL_FACE);805 806 queryIdx = 0; 807 unsigned int pixelCount; 804 808 805 809 // 8. The number of visible pixels is the number of sample rays which see the source 806 // object from the corresponding viewcell -> rember these values for later update 807 // of the viewcell pvs - or update immediatelly? 808 809 // In general it is not neccessary to rember to extract all the rays cast. I hope it 810 // object from the corresponding viewcell -> remember these values for later update 811 // of the viewcell pvs - or update immediately? 812 813 for (vit = beam.mViewCells.begin(); vit != vit_end; ++ vit) 814 { 815 // fetch queries 816 glGetOcclusionQueryuivNV(sQueries[queryIdx ++], 817 GL_PIXEL_COUNT_NV, 818 &pixelCount); 819 820 Debug << "visble pixels: " << pixelCount << endl; 821 } 822 823 824 // In general it is not neccessary to remember to extract all the rays cast. I hope it 810 825 // would be sufficient to gain only the intergral statistics about the new contributions 811 826 // and so the rss tree would actually store no new rays (only the initial ones) … … 815 830 // (new viewcell has been discovered) or relative contribution greater than a threashold ... 816 831 832 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 833 glDepthMask(GL_TRUE); 834 glEnable(GL_CULL_FACE); 835 836 817 837 cgGLDisableProfile(sCgFragmentProfile); 818 838 glDisable(GL_TEXTURE_2D); … … 838 858 } 839 859 860 840 861 void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint, 841 862 const Beam &beam, … … 855 876 viewPoint.x, viewPoint.y, viewPoint.z, 856 877 up.x, up.y, up.z); 857 } 878 } 879 880 881 882 883 /***************************************************************/ 884 /* GlDebuggerWidget implementation */ 885 /***************************************************************/ 886 887 888 GlDebuggerWidget::GlDebuggerWidget(QWidget *parent, GlRendererBuffer *buf) 889 : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf) 890 { 891 // create the pbuffer 892 //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); 893 timerId = startTimer(20); 894 setWindowTitle(("OpenGL pbuffers")); 895 } 896 897 898 GlDebuggerWidget::~GlDebuggerWidget() 899 { 900 mRenderBuffer->releaseFromDynamicTexture(); 901 glDeleteTextures(1, &dynamicTexture); 902 903 DEL_PTR(mRenderBuffer); 904 } 905 906 907 void GlDebuggerWidget::initializeGL() 908 { 909 glMatrixMode(GL_PROJECTION); 910 glLoadIdentity(); 911 912 glFrustum(-1, 1, -1, 1, 10, 100); 913 glTranslatef(-0.5f, -0.5f, -0.5f); 914 glTranslatef(0.0f, 0.0f, -15.0f); 915 glMatrixMode(GL_MODELVIEW); 916 917 glEnable(GL_CULL_FACE); 918 initCommon(); 919 initPbuffer(); 920 921 } 922 923 924 void GlDebuggerWidget::resizeGL(int w, int h) 925 { 926 glViewport(0, 0, w, h); 927 } 928 929 930 void GlDebuggerWidget::paintGL() 931 { 932 // draw a spinning cube into the pbuffer.. 933 mRenderBuffer->makeCurrent(); 934 //mRenderBuffer->SampleBeamContributions(); 935 glFlush(); 936 937 // rendering directly to a texture is not supported on X11, unfortunately 938 mRenderBuffer->updateDynamicTexture(dynamicTexture); 939 940 // ..and use the pbuffer contents as a texture when rendering the 941 // background and the bouncing cubes 942 makeCurrent(); 943 glBindTexture(GL_TEXTURE_2D, dynamicTexture); 944 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 945 946 // draw the background 947 glMatrixMode(GL_MODELVIEW); 948 glPushMatrix(); 949 glLoadIdentity(); 950 glMatrixMode(GL_PROJECTION); 951 glPushMatrix(); 952 glLoadIdentity(); 953 954 glPopMatrix(); 955 glMatrixMode(GL_MODELVIEW); 956 glPopMatrix(); 957 } 958 959 960 void GlDebuggerWidget::initPbuffer() 961 { 962 // set up the pbuffer context 963 mRenderBuffer->makeCurrent(); 964 initCommon(); 965 966 glViewport(0, 0, mRenderBuffer->size().width(), mRenderBuffer->size().height()); 967 glMatrixMode(GL_PROJECTION); 968 glLoadIdentity(); 969 glOrtho(-1, 1, -1, 1, -99, 99); 970 glTranslatef(-0.5f, -0.5f, 0.0f); 971 glMatrixMode(GL_MODELVIEW); 972 glLoadIdentity(); 973 974 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 975 976 // generate a texture that has the same size/format as the pbuffer 977 dynamicTexture = mRenderBuffer->generateDynamicTexture(); 978 979 // bind the dynamic texture to the pbuffer - this is a no-op under X11 980 mRenderBuffer->bindToDynamicTexture(dynamicTexture); 981 makeCurrent(); 982 } 983 984 void GlDebuggerWidget::initCommon() 985 { 986 glEnable(GL_TEXTURE_2D); 987 glEnable(GL_DEPTH_TEST); 988 989 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 990 }
Note: See TracChangeset
for help on using the changeset viewer.