




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
BuffersSoftwareCollege,ShandongUniversityInstructor:ZhouYuanfengE-mail:yuanfeng.zhou@BuffersSoftwareCollege,ShandReview2Rasterization:Polygonscanconversionalgorithm;HiddensurfaceremovalAliasingReview2Rasterization:Polygon3ObjectivesIntroduceadditionalOpenGLbuffersLearntoreadandwritebuffersLearntouseblending3ObjectivesIntroduceadditiona4BufferDefineabufferbyitsspatialresolution(nxm)anditsdepth(orprecision)k,thenumberofbits/pixelpixel4BufferDefineabufferbyits5OpenGLFrameBuffer5OpenGLFrameBuffer6OpenGLBuffersColorbufferscanbedisplayedFrontBackAuxiliaryOverlayDepthAccumulationHighresolutionbufferStencilHoldsmasks6OpenGLBuffersColorbuffersc7WritinginBuffersConceptually,wecanconsiderallofmemoryasalargetwo-dimensionalarrayofpixelsWereadandwriterectangularblockofpixelsBitblocktransfer(bitblt)operationsTheframebufferispartofthismemory(Doublebuffer)LeftandrightbuffersforStereroimagesframebuffer(destination)writingintoframebuffersourcememory7WritinginBuffersConceptuallBit-blockwritingAscan-linewritingwhilepolygonfillingCharacterdisplayClearallpixelbuffer8Bit-blockwritingAscan-linewBitBltcopyBOOLBitBlt(intx,inty,intnWidth,intnHeight,CDC*pSrcDC,intxSrc,intySrc,DWORDdwRop);//SRCCOPYCopiesabitmapfromthesourcedevicecontexttothiscurrentdevicecontext.(FromaBitmapinmemorytocurrentCDC)9BitBltcopyBOOLBitBlt(intx,10WritingModelReaddestinationpixelbeforewritingsourceSource:sDestination:d’d’=f(s,d)10WritingModelReaddestinatio11BitWritingModes(16modes)Sourceanddestinationbitsarecombinedbitwise16possiblefunctions(onepercolumnintable)replaceORXOR11BitWritingModes(16modes)Mode3&6Mode6Mode312Mode3&6Mode613XORmodeRecallfromChapter3thatwecanuseXORbyenablinglogicoperationsandselectingtheXORwritemodeS(SM)MXORisespeciallyusefulforswappingblocksofmemorysuchasmenusthatarestoredoffscreenIfSrepresentsscreenandMrepresentsamenuthesequenceSSMMSMSSMswapstheSandM13XORmodeRecallfromChapter14ThePixelPipelineOpenGLhasaseparatepipelineforpixelsWritingpixelsinvolvesMovingpixelsfromprocessormemorytotheframebufferFormatconversionsMapping,Lookups,TestsReadingpixelsFormatconversion14ThePixelPipelineOpenGLhas15RasterPositionOpenGLmaintainsarasterpositionaspartofthestateSetbyglRasterPos*()(worldcoord)glRasterPos3f(x,y,z);TherasterpositionisageometricentityPassesthroughgeometricpipelineEventuallyyieldsa2DpositioninscreencoordinatesThispositionintheframebufferiswherethenextrasterprimitiveisdrawn15RasterPositionOpenGLmainta16BufferSelectionOpenGLcandrawintoorreadfromanyofthecolorbuffers(front,back,auxiliary)DefaulttothebackbufferChangewith
glDrawBufferand
glReadBufferNotethatformatofthepixelsintheframebufferisdifferentfromthatofprocessormemoryandthesetwotypesofmemoryresideindifferentplacesNeedpackingandunpackingDrawingandreadingcanbeslow16BufferSelectionOpenGLcandOpenGLcodeLib3dsMesh
*mesh
=
f3ds->meshes[i];
//由3ds文件中读取出需要数据
glGenBuffers(1,&m_Vertex[i]);
glGenBuffers(1,&m_Index[i]);
glBindBuffer(GL_ARRAY_BUFFER,m_Vertex[i]);
glBufferData(GL_ARRAY_BUFFER,(sizeof(float)
*
9
*
mesh->nfaces)
+
(sizeof(float)
*
3
*
mesh->nvertices),TotleV,GL_STATIC_DRAW);
glVertexPointer(3,GL_FLOAT,0,BUFFER_OFFSET(0));
glNormalPointer(GL_FLOAT,0,BUFFER_OFFSET(V_size));
glBindBuffer(GL_ARRAY_BUFFER,m_Vertex[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_Index[0]);
glDrawElements(GL_TRIANGLES,DrawCount[0],GL_UNSIGNED_SHORT,NULL);
17OpenGLcodeLib3dsMesh
*mesh18BitmapsOpenGLtreats1-bitpixels(bitmaps)differentlyfrommulti-bitpixels(pixelmaps)Bitmapsaremasksthatdetermineifthecorrespondingpixelintheframebufferisdrawnwiththepresentrastercolor0colorunchanged1colorchangedbasedonwritingmodeBitmapsareusefulforrastertextcursor(XOR)GLUTfont:
GLUT_BIT_MAP_8_BY_1318BitmapsOpenGLtreats1-bitp19RasterColorSameasdrawingcolorsetbyglColor*()CurrentrastercolorisfixedbylastcalltoglRasterPos*()GeometrydrawninblueOnesinbitmapuseadrawingcolorofredglColor3f(1.0,0.0,0.0);glRasterPos3f(x,y,z);glColor3f(0.0,0.0,1.0);glBitmap(…….glBegin(GL_LINES);glVertex3f(…..)19RasterColorSameasdrawing20DrawingBitmapsglBitmap(width,height,x0,y0,xi,yi,bitmap)firstrasterpositionsecondrasterpositionoffsetfromrasterpositionincrementsinrasterpositionafterbitmapdrawn20DrawingBitmapsglBitmap(widtTextdefinitioninOpenGLRastertextisfasterthanvectortext;Times,Courier,ComputerModern;Size:10pt,24pt(1inch=72pt)21TextdefinitioninOpenGLRasteTextinOpenGL8x13textisdefinedinGLUT_BITMAP_8_BY_13;Thesizeoftextisrelatedwithresolutionofscreen;Define8x13text:GLubytemy_font[128][13];base=glGenLists(128);for(i=0;i<128;i++){glNewList(base+i,GL_COMPILE);glBitMap(8,13,0.0,0.0,10.0,0.0,my_font[i]);glEndList();}22TextinOpenGL8x13textisdef23Example:CheckerBoardGLubytewb[2]={0x00,0xFF};GLubytecheck[512];inti,j;for(i=0;i<64;i++)for(j=0;j<8,j++)check[i*8+j]=wb[(i/8+j)%2];glBitmap(64,64,0.0,0.0,0.0,0.0,check);23Example:CheckerBoardGLubyt24ImageFormatsWeoftenworkwithimagesinastandardformat(JPEG,TIFF,GIF,PS,EPS)Howdoweread/writesuchimageswithOpenGL?NosupportinOpenGLOpenGLknowsnothingofimageformatsSomecodeavailableonWebCanwritereaders/writersforsomesimpleformatsinOpenGL24ImageFormatsWeoftenworkwPS&EPSPostScript(PS)imageforcontrollingprinter
RGBimageconvertsto7bitsASCII;soPSimagecanbeidentifiedbyprinter,butitislarge.EncapsulatedPostScript(EPS)issimilartoPSimage.25PS&EPSPostScript(PS)imagefGIFimageCompuServeIncorporated(1987)GraphicsInterchangeFormatColorIndexImagelow-resolutionsmallanimations(imageslices)26GIFimageCompuServeIncorporatTIFFTagged(标签)ImageFileFormatHighqualityFirstforscannedcopyLosslesscompressionCansavevectorboundaryofimage27TIFFTagged(标签)ImageFileFormJPEGlossycompressionHighcompressionratioDiscretecosinetransform28JPEGlossycompression28SizecomparisonImage1200x1200TIFF:1440198bytes(about1.37m)JPEG:80109and38962bytes(about78kb)EPS:abouttwiceofTIFFCompressedTIFF:abouthalfsizeZIP
compression:TIFF
andEPSaresimilar29TIFFJPEG-18JPEG-37SizecomparisonImage1200x120030DisplayingaPPMImage(Linux)PPMisaverysimpleformat(24bits)EachimagefileconsistsofaheaderfollowedbyallthepixeldataHeaderP3#comment1#comment2.#commentnrowscolumnsmaxvaluepixels30DisplayingaPPMImage(Linux31ReadingtheHeaderFILE*fd;intk,nm;charc;inti;charb[100];floats; intred,green,blue;printf("enterfilename\n");scanf("%s",b);fd=fopen(b,"r");fscanf(fd,"%[^\n]",b);if(b[0]!='P'||b[1]!='3'){ printf("%sisnotaPPMfile!\n",b); exit(0);}printf("%sisaPPMfile\n",b);checkfor“P3”infirstline31ReadingtheHeaderFILE*fd;c32ReadingtheHeader(cont)fscanf(fd,"%c",&c);while(c=='#') { fscanf(fd,"%[^\n]",b); printf("%s\n",b); fscanf(fd,"%c",&c);} ungetc(c,fd);skipovercommentsbylookingfor#infirstcolumn32ReadingtheHeader(cont)fsc33ReadingtheDatafscanf(fd,"%d%d%d",&n,&m,&k);printf("%drows%dcolumnsmaxvalue=%d\n",n,m,k);nm=n*m;image=malloc(3*sizeof(GLuint)*nm);s=255./k;for(i=0;i<nm;i++){ fscanf(fd,"%d%d%d",&red,&green,&blue); image[3*nm-3*i-3]=red; image[3*nm-3*i-2]=green; image[3*nm-3*i-1]=blue;}scalefactor33ReadingtheDatafscanf(fd,"34PixelMapsOpenGLworkswithrectangulararraysofpixelscalledpixelmapsorimagesPixelsareinonebyte(8bit)chunksLuminance(grayscale)images1byte/pixelRGB3bytes/pixelThreefunctionsDrawpixels:processormemorytoframebufferReadpixels:framebuffertoprocessormemoryCopypixels:framebuffertoframebuffer34PixelMapsOpenGLworkswithPixelformatImageinmemory:RGB,RGBA,IndexFormat:intorfloatglPixelMap35PixelformatImagei
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 上海市金山区名校2025年初三2月联考生物试题含解析
- 河南应用技术职业学院《发育生物学与再生医学》2023-2024学年第二学期期末试卷
- 西安城市建设职业学院《信息数学》2023-2024学年第二学期期末试卷
- 内蒙古财经大学《半导体器件与工艺课程设计》2023-2024学年第二学期期末试卷
- 山东省菏泽单县北城三中重点达标名校2025年初三第一次质量调研普查考试化学试题含解析
- 相机感光度扩展与噪点控制考核试卷
- 矿物加工设备研发与技术创新考核试卷
- 电机制造中的人工智能技术与应用考核试卷
- 电子封装材料及技术考核试卷
- 电机在农业机械的应用考核试卷
- 胫骨横向骨搬移在糖尿病足治疗中的运用
- 钢铁生产工艺流程33
- 用双棱镜干涉测钠光波长
- 竞聘报名表 (标准模版)
- 入团志愿书表格(空白)
- 秘密花园读书交流会(课堂PPT)
- 安装工程开工报告表格
- Duncans 新复极差检验SSR值表
- 商务部商业保理企业管理办法
- 初中英语语法-介词、连词.ppt
- 【精选】配电室安全管理制度精选
评论
0/150
提交评论