GithubHelp home page GithubHelp logo

triangleraster's Introduction

triangleraster

This is an SDL-based demo written in C++ that features a simple triangle rasterization algorithm. It was originally created to accompany this article.

This demo has been tested on Ubuntu 18.10. To build it, make sure that you have the SDL2 development package installed and run 'make'. This will create an executable called 'triangleraster' that you can then run. Press the 'Escape' key to exit the demo.

License

Copyright © 2009-2018 Josh A. Beam
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

triangleraster's People

Contributors

joshb avatar

Stargazers

 avatar Juan García avatar  avatar  avatar Miles Lacey avatar Madgarden avatar  avatar Jorge Martin Juarez avatar Michael avatar Imran H. avatar Sean Siddens avatar smcameron avatar  avatar Maurits Lam avatar  avatar Andrew Takeshi avatar Lawliet Wang avatar  avatar Konstantin Khomyakov avatar YangJun avatar Rich avatar HuW avatar  avatar mrwn avatar lak avatar TridentTD avatar Tamilselvan R avatar Johan Gardhage avatar WHITE MONKEY avatar Kenny Stepney avatar Michal Kulinski avatar bearworks avatar  avatar Lucas Teixeira avatar Alex Michaud avatar Nicholas Kane avatar Nikos Papadopoulos avatar Angus H. avatar  avatar  avatar Chao Duan avatar Frédéric Devernay avatar Moises Martinez avatar  avatar Jason Wu avatar

Watchers

 avatar yasai-gyabo(kumaashi) avatar James Cloos avatar Evandro Paulino avatar Frédéric Devernay avatar Kada B avatar

triangleraster's Issues

Failing on triangles with both short sides on the left

Hey Josh,

thanks a lot for the code, I'm using it to rasterize triangles in a Delaunay triangulation. I discovered an issue in the case of triangles with both short sides on the left; the spans in this case reach from x1 to x2, where x1 > x2 and so no pixels are drawn in:

for(int x = span.X1; x < span.X2; x++) {

The failure cases are exemplified in the image below (black triangles: failure case, gray: successfully rasterized)
example

I've fixed it by simply swapping the range limits if x2>x1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.