Advertisement
teleias

Thoughts On Rasterization

Oct 4th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. //My thoughts on how to rasterize. Psuedocode.
  2.  
  3. foreach(polyID)
  4. {
  5. for(int iy = 0; iy < width; iy ++)
  6. {
  7. boolean isOn = false;
  8. int currentLineFlag;
  9. for(int ix = 0; ix < height; ix++)
  10. {
  11. Pixel p = Screen[ix,iy];
  12. if(p.isOn())
  13. {
  14. boolean partOfCurrentPolygon = ??;
  15. if(partOfCurrentPolygon)
  16. {
  17. //then this pixel is part of the current polygon.
  18. if(isOn)
  19. {
  20. boolean onlyPartOfCurrentLine = ??;
  21. if(partOfCurrentLine)
  22. {
  23. ??
  24. }
  25. else if(!partOfCurrentLine)
  26. {
  27. ??
  28. }
  29. }
  30. else if(!isOn)
  31. {
  32. ??
  33. }
  34. }
  35. else if(!partOfCurrentPolygon)
  36. {
  37. ??
  38. }
  39. }
  40. else if(!p.isOn())
  41. {
  42. if(isOn)
  43. {
  44. ??
  45. }
  46. else if(!isOn)
  47. {
  48. ??
  49. }
  50. }
  51. }
  52. }
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. foreach(polyID)
  93. {
  94. for(int iy = 0; iy < width; iy ++)
  95. {
  96. boolean isOn = false;
  97. int currentLineFlag;
  98. for(int ix = 0; ix < height; ix++)
  99. {
  100. Pixel p = Screen[ix,iy];
  101. if(p.isOn())
  102. {
  103. boolean partOfCurrentPolygon = (1<<polyID & p.getLineID() != 0);
  104. if(partOfCurrentPolygon)
  105. {
  106. //then this pixel is part of the current polygon.
  107. if(isOn)
  108. {
  109. boolean onlyPartOfCurrentLine = (currentLineFlag | p.getLineID() == currentLineFlag);
  110. if(partOfCurrentLine)
  111. {
  112. //ignore
  113. }
  114. else if(!partOfCurrentLine)
  115. {
  116. //end the rasterization!
  117. isOn = false;
  118. }
  119. }
  120. else if(!isOn)
  121. {
  122. //we've encountered the first on pixel, so init everything
  123. isOn = true;
  124. currentLineFlag = p.getLineID();
  125. }
  126. }
  127. else if(!partOfCurrentPolygon)
  128. {
  129. //ignore
  130. }
  131. }
  132. else if(!p.isOn())
  133. {
  134. if(isOn)
  135. {
  136. //rasterize this pixel
  137. p.turnOn();
  138. }
  139. else if(!isOn)
  140. {
  141. //ignore
  142. }
  143. }
  144. }
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement