Coder Social home page Coder Social logo

pixelforge's Introduction

PixelForge

PixelForge

PixelForge is a lightweight software rendering library written in standard C99, designed for versatile rendering without any external dependencies beyond the C standard library.

Features

  • OpenGL-Like API: PixelForge offers an API reminiscent of OpenGL 1.X, facilitating easy adoption for those familiar with OpenGL.
  • Multiple Contexts: Allows creation of multiple rendering contexts for different purposes.
  • Framebuffer Support: Supports framebuffers, enabling rendering to various pixel buffers.
  • Texture Rendering: Supports rendering of textures using pixel buffers.
  • Perspective Correction: Applies perspective correction to texture coordinates during 3D rendering.
  • Primitive Rendering: Efficiently renders points, lines, triangles, quads, strips, and fans. Additionally, it allows for adjusting point size, line width, and polygon mode, enabling rendering of triangles and quads as lines or points.
  • Pixel Formats: Supports various commonly used pixel formats and allows users to provide their own getter/setter functions for each texture and framebuffer via function pointers.
  • Blend Modes: Offers several blend modes for color blending, such as addition, subtraction, multiplication, simple averaging, and alpha blending. Additionally, supports custom color blending functions via function pointer.
  • Depth Testing: Enables toggling depth testing for 3D rendering management. Several basic depth testing functions are provided, but it's also possible to supply custom functions via function pointers. Additionally, the clear depth value can be adjusted as needed.
  • Material Support: Rendering material support through pfMaterialf and pfMaterialfv, similar to OpenGL 1.
  • Phong Lighting: Rendering multiple lights using pfLightfv, with a default support for up to 8 lights, adjustable via a definition. The default supported lighting model is the Blinn-Phong model, but you can also activate the Phong model with perfect reflection using PF_PHONG_REFLECTION.
  • Gouraud Lighting: If you find the Phong model too slow, you have the option to enable Gouraud shading via a PF_GOURAUD_SHADING definition, making everyone happy!
  • Face Culling: Supports selection of face culling (back face culling, front face culling, "no culling").
  • Post-Processing: PixelForge supports post-processing effects through a customizable function pointer. Users can provide a function that takes the position (x, y, z) and color of each pixel on the screen and returns the color to be applied to that pixel. This feature enables various effects such as fog, bloom, and color grading to be implemented easily.
  • Double buffering: In some cases, double buffering is necessary to avoid flickering during rendering, for example. You can define an auxiliary buffer and swap the buffers as needed.
  • OpenMP Support: Added support for OpenMP to parallelize triangle rasterization loops, with verification of the number of pixels to be rasterized (adjustable) to activate this parallelization, significantly increasing rasterization performance for large triangles.

Usage

  1. Clone the repository:

    git clone https://github.com/Bigfoot71/PixelForge.git
  2. Include the PixelForge header file in your project:

    #include "pixelforge.h"
  3. Compile and link your project with PixelForge library.

Examples

The repository contains multiple examples showcasing how to use PixelForge with SDL2, raylib, the Windows API for Windows environments, and the X11 window server for Linux. These examples include functions for drawing models in raylib, as well as primitive drawing, projection configuration, and more, all of which can be utilized across different environments.

License

This library is released under the Zlib License.

Contribution

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

Screenshots

PixelForge PixelForge PixelForge

pixelforge's People

Contributors

bigfoot71 avatar burmaraider avatar

Stargazers

Jakub Arnold avatar  avatar Daniel Vincent Horgan avatar  avatar Jarrod M. avatar William Bettridge-Radford avatar Icicles avatar  avatar  avatar Julian Heinken avatar Matt avatar Jake Larson avatar Matheus da Silva Garcias avatar 大熊 avatar  avatar Milan Nikolic avatar AVA avatar Agnis Aldiņš "NeZvērs" avatar Rob Loach avatar jack avatar Justine Hizola avatar Suavesito avatar Wulferis avatar Le' me C avatar Lucas Ângelo C. da Silva avatar Chukobyte avatar BLUELOVETH avatar Samuel Gomes avatar Madara avatar Ray avatar Jussi Viitala avatar Gunko Vadim avatar Almasbek Kairat avatar  avatar Bocke avatar Mohamed Attia avatar  avatar nobbele avatar Braedon avatar Jett avatar Deftware avatar  avatar

Watchers

Wulferis avatar  avatar

pixelforge's Issues

Rendering issue with triangle vertices clipped in viewport with Phong lighting

There appears to be a problem with the vertices of triangles clipped within the viewport when using Phong lighting. This issue persists both in barycentric rendering mode and scanline mode.

The problem does not seem to originate from normal interpolation during clipping. In the raylib_FirstPerson example, normals consistently point towards either 1 or -1 along a single axis. Even when printing them to the console or displaying them on screen with color, everything appears normal.

I also do not see any issues with position interpolation.

This problem mostly manifests when triangles are clipped according to the viewport.


Screenshots of the issue:
screenshot1
screenshot2
screenshot3

Image rendering normals with color at locations where triangles are clipped, showing no apparent issues:
screenshot4
screenshot5

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.