All Projects → LukasBanana → PicoRenderer

LukasBanana / PicoRenderer

Licence: BSD-3-Clause license
Low-Level, 8-bit Colored, 3D Software Renderer written in C99

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
objective c
16641 projects - #2 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to PicoRenderer

currender
Currender: A CPU renderer for computer vision
Stars: ✭ 26 (-52.73%)
Mutual labels:  rasterizer, renderer
SoftwareRenderer
Soft-only 3d renderer.
Stars: ✭ 12 (-78.18%)
Mutual labels:  rasterizer
Vitro
Experimental C++20 multiplatform graphics engine.
Stars: ✭ 14 (-74.55%)
Mutual labels:  renderer
Onyx
UNIX-like operating system written in C and C++
Stars: ✭ 52 (-5.45%)
Mutual labels:  low-level
yeelight-cli
a low level, cross-platform command line client for Yeelight
Stars: ✭ 43 (-21.82%)
Mutual labels:  low-level
wgpu-mc
Rust-based replacement for the default Minecraft renderer
Stars: ✭ 254 (+361.82%)
Mutual labels:  renderer
RazorSharp
Low-level utilities and tools for working with the CLR and memory.
Stars: ✭ 31 (-43.64%)
Mutual labels:  low-level
Tetra3d
Tetra3D is a 3D hybrid software/hardware renderer made for games written in Go with Ebitengine.
Stars: ✭ 271 (+392.73%)
Mutual labels:  renderer
AyaRay
A Modern C++ Windows-platform physically based renderer developing by Chang Yu.
Stars: ✭ 29 (-47.27%)
Mutual labels:  renderer
DuEngine
An efficient interactive C++ renderer for ShaderToy-alike demos with 2D/3D/CubeMap/Video/Camera/LightField/Volume textures. (Partially used in my I3D 2018 papers)
Stars: ✭ 62 (+12.73%)
Mutual labels:  renderer
numpy-html
Render NumPy arrays as HTML tables
Stars: ✭ 38 (-30.91%)
Mutual labels:  renderer
react-jsx-renderer
A React component for Rendering JSX
Stars: ✭ 43 (-21.82%)
Mutual labels:  renderer
ForkerRenderer
CPU-Based Software Forward / Deferred Rasterizer, A Tiny OpenGL (PBR, Soft Shadow, SSAO) 🐼
Stars: ✭ 17 (-69.09%)
Mutual labels:  rasterizer
swGL
A multithreaded software implementation of OpenGL 1.3 in C++.
Stars: ✭ 50 (-9.09%)
Mutual labels:  rasterizer
polyred
📺 3D Graphics in Go.
Stars: ✭ 31 (-43.64%)
Mutual labels:  renderer
btt
Low level MacOS management in JavaScript via BetterTouchTool
Stars: ✭ 92 (+67.27%)
Mutual labels:  low-level
DummyEngine
Small cross platform Vulkan/OpenGL 3d engine for personal experimentation
Stars: ✭ 76 (+38.18%)
Mutual labels:  renderer
ST-CGAN
Dataset and Code for our CVPR'18 paper ST-CGAN: "Stacked Conditional Generative Adversarial Networks for Jointly Learning Shadow Detection and Shadow Removal"
Stars: ✭ 64 (+16.36%)
Mutual labels:  low-level
chisel
A library to sculpt text on any device that you can handle pixels
Stars: ✭ 37 (-32.73%)
Mutual labels:  renderer
Rasterizer
CPU forward/deferred rasterizer with depth-buffering, texture mapping, normal mapping and blinn-phong shading implemented in C++
Stars: ✭ 77 (+40%)
Mutual labels:  rasterizer

PicoRenderer

This project provides a simple, 8-bit colored, 3D software renderer written in C99. It has an interface similiar to OpenGL 1.1.

Overview

Screenshots

test/media/preview_win32.png

Example scene (test1 on Windows 10)

Supported Platforms

  • Windows (tested on Windows 10)
  • MacOS (tested on OSX El Capitan)
  • Linux (demo not available)

Why C and not C++?

C code is slim, highly portable, compiles fast and for a low-level software renderer one doesn't need lots of object-oriented or templated code.

Build

Fine Tuning

There are several macros which allows you to enabled or disable specific features for fine tuning. For example if "PR_FAST_MATH" is defined, all uses of the sine function ('sinf' from the C standard library) will be replaced by "_aprx_sin" which implements an approximated and fast sine function (in src/rasterizer/ext_math.c). See src/rasterizer/static_config.h for all these macros.

Plugins

This project makes use of the "stb_image" library (see https://github.com/nothings/stb)

Getting Started

// PicoRenderer (PR) interface example
// (interface still in development)
#include <pico/pico.h>

int main()
{
  if (!prInit())
    return 1;
  
  // Create OS dependent window, this is your task ;-)
  PRuint scrWidth = 800, scrHeight = 600;
  PRcontextdesc contextDesc;
  
  /*
  #if defined(_WIN32)
  
  HWND wnd = CreateWindow(...);
  contextDesc.window = (void*)(&wnd);
  
  #elif defined(__APPLE__)
  
  NSWindow* wnd = [[NSWindow alloc] ...];
  contextDesc.window = (void*)wnd;
  
  #elif defined(__linux__)
  
  Window wnd = XCreateWindow(...);
  contextDesc.window = (void*)wnd;
  
  #endif
  */
  
  // Create render context
  PRobject context = prCreateContext(&contextDesc, scrWidth, scrHeight);
  //prMakeCurrent(context);
  
  // Create frame buffer
  PRobject frameBuffer = prCreateFrameBuffer(scrWidth, scrHeight);
  prBindFrameBuffer(frameBuffer);
  
  prViewport(0, 0, scrWidth, scrHeight);
  
  // Setup projection matrix
  PRfloat projection[16];
  prBuildPerspectiveProjection(
    projection,                   // output matrix
    (PRfloat)scrWidth/scrHeight,  // aspect ratio
    1.0f,                         // near clipping plane
    100.0f,                       // far clipping plane
    74.0f * PR_DEG2RAD            // field of view (FOV) in radians (74 degrees to radians)
  );
  prProjectionMatrix(projection);
  
  // World transform
  PRfloat worldMatrix[16];
  PRfloat rotation = 0.0f;
  
  // Main loop
  PRboolean isQuit = PR_FALSE;
  
  while (!isQuit)
  { 
    // Update user input ...

    // Setup world matrix
    prLoadIdentity(worldMatrix);
    prTranslate(worldMatrix, 0, 0, 2);
    prRotate(worldMatrix, 0, 0, 1, rotation);
    prWorldMatrix(worldMatrix);
    rotation += 0.01f;
    
    // Clear scene (with black background)
    prClearColor(0, 0, 0);
    prClearFrameBuffer(
      frameBuffer,
      0.0f,
      PR_COLOR_BUFFER_BIT | PR_DEPTH_BUFFER_BIT
    );
    
    // Draw yellow triangle
    prColor(255, 255, 0);
    prBegin(PR_TRIANGLES);
    {
      prVertex2f(0, 1.155f);
      prVertex2f(1, -0.577f);
      prVertex2f(-1, -0.577f);
    }
    prEnd();

    // Show frame buffer on render context
    prPresent(context);
  }
  
  // Release all objects
  prDeleteFrameBuffer(frameBuffer);
  prDeleteContext(context);
  
  prRelease();
  
  return 0;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].