Those years I saw the rasterization algorithm in the Open source project

Source: Internet
Author: User

Code Source:salvia

Code Show
Template<class t>  void Crasterizer::rasttri_constcoltex (int iy0,int iy1,sfbyte8* buf,zbuf_type* zbuf,t_ Rasterizier_point attribute,t col,t_material* material) {int affine=m_run_flags&rast_affine;int nline=0;for (int iy = iy0;iy>=iy1;--iy,buf+=m_linebytes,++nline) {int ix0 = Idmath::ftoifast (attribute.pl.x); int ix1 = Idmath:: Ftoifast (attribute.pr.x); zbuf_type* zbuf = M_zbuf + (M_context->getparam ()->height-iy-1) *m_context->getparam ()->width; t* screenbuf = (t*) buf;screenbuf +=ix0;if (affine) scanline_coltex_affine (Screenbuf, ix0,ix1,col,attribute,material); Elsescanline_coltex (Screenbuf, zbuf+ix0,ix0,ix1,col,attribute,material); Attribute.interpolateverticalcol ();}}

Conclusion Analysis

Triangles, where the Y value becomes smaller, and then the Xright-xleft gap becomes larger.

*

**

***

****

Code Detail Tags:

Process of Call Stack:
softcore.exe! crasterizer::scanline_coltex<unsigned int>//Basic function, but it's just the location of the discovery softcore.exe! crasterizer::rasttri_constcoltex<unsigned int>//Trigonometric functions here, using templates, softcore.exe! Crasterizer::d Rawtriangle_coltex (std::vector<crasterizer::t_rast_triangle,std::allocator<crasterizer::t_ Rast_triangl softcore.exe! Crasterizer::flush ()  
Swipe out of buffer contents softcore.exe! Csoftrender::rasterizer ()  
Final rasterization, including texture softcore.exe! Csoftrender::renderframe ()  line 505c++ softcore.exe! Cchildview::runframe ()  line 205c++ softcore.exe! Cmainframe::runframe ()  line 105c++ softcore.exe! Csoftcoreapp::run ()  line 172c++
Every frame is called here mfc90d.dll! Afxwinmain (hinstance__ * hinstance=0x00400000, hinstance__ * hprevinstance=0x00000000, char * lpCmdLine=0x00185289, int ncmdshow=0x00000001)  rows + 0xd bytes C + + softcore.exe! WinMain (hinstance__ * hinstance=0x00400000, hinstance__ * hprevinstance=0x00000000, char * lpcmdline=0x00185289, int ncmdshow=0x00000001)  line 30c++ softcore.exe!__tmaincrtstartup ()  row 574 + 0x35 byte c softcore.exe! WinMainCRTStartup ()  line 399C


Follow up: Add a dynamic demo diagram that you want to expand from a simple 3d model rendering

Those years I saw the rasterization algorithm in the Open source project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.