GithubHelp home page GithubHelp logo

wojciech-graj / termgl Goto Github PK

View Code? Open in Web Editor NEW
274.0 4.0 9.0 14.06 MB

2D & 3D graphics engine in the terminal [C/C++]

License: MIT License

Makefile 1.16% C 98.84%
terminal-based terminal terminal-graphics linux-shell unix-shell 3d 3d-graphics graphics graphics-engine graphics-library c computer-graphics cpp cpp-library linux windows c-plus-plus unix cli

termgl's Introduction

TermGL

A terminal-based graphics library for 2D and 3D graphics.

Features:

  • Windows & *NIX support
  • C99 compliant without external dependencies
  • Custom vertex and pixel shaders
  • Affine texture mapping
  • 24 bit RGB
  • Indexed color mode: 16 Background colors, 16 foreground colors, bold and underline
  • Non-blocking input from terminal
  • Mouse tracking

Gallery

LOGO

CUBE

CANYON

Build

You can compile termgl.c as you would any other C source file. You can also compile it as a shared library libtermgl.so by calling make shared. To install the shared library, sudo make install.

To enable 3D functionality, use the -DTERMGL3D compiler flag.
To enable utility functions, use the -DTERMGLUTIL compiler flag.
To disable helper functions for vector math and shaders, use the -DTERMGL_MINIMAL compiler flag.

To use TermGL in C++, compile it as a shared library and link against the libtermgl.so file. The termgl.h header can be included from C++ files.

To compile a demo program, run make demo, creating the termgl_demo binary.

To cross-compile, set the CC variable to the appropriate compiler.

Documentation

Certain settings can be changed at the top of termgl.c prior to compilation, e.g. memory allocation functions, clear screen command, compiler-specific commands.
The header file termgl.h contains brief documentation for all functions and structs.
Compiler-specific functionality is used, therefore it is recommened to always compile using GCC.
The TermGLUtil extension contains functions for reading keyboard input, but requires either Windows or *NIX headers.

Demo

A demo program can be found at demo/termgl_demo.c.
Available demos and TermGL features used:

  1. Utah Teapot
    Renders a rotating 3D Utah Teapot.
    • Backface culling
    • Z buffering
    • Double-width characters
    • 3D rendering
    • Custom shaders
  2. Color Palette
    Renders a palette of various text colors and styles.
    • Colors & Modifiers
  3. Mandelbrot
    Renders an infinitely zooming-in Mandelbrot set.
    • Point rendering
  4. Realtime Keyboard
    Displays keyboard input in realtime.
    • Text rendering
    • Realtime keyboard input
  5. Textured Cube
    Renders a texture-mapped cube.
    • Backface culling
    • Z buffering
    • Double-width characters
    • 3D rendering
    • Shaders
    • Texture mapping
  6. RGB
    Renders overlapping red, green, and blue circles.
    • 24 bit RGB
    • Text rendering
  7. Mouse
    Displays mouse position and button state.
    • Mouse tracking
    • Text rendering

termgl's People

Contributors

wojciech-graj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

termgl's Issues

License Information

Hi,

thanks a lot for sharing this.
It's a very nice project.

I built a simple "fun"/"toy" application that uses TermGL.
My application connects to some other Open Source project of mine via a Message-oriented Middleware (MoM) and renders data received from the MoM in 3D in the terminal via TermGL.

I would like to share this application as Open Source on GitHub as well.
To properly give credit to TermGL, it would be great if there was some information about the TermGL license.
Is it possible for you to add license information to TermGL?

Thanks in advance and cheers,
Ruediger

possible memory corruption issue in `tgl_puts`?

TermGL/src/termgl.c

Lines 163 to 164 in d95752b

char *c_ptr = str;
while (c_ptr) {

What is the purpose of checking c_ptr as a pointer value itself?
Is it supposed to check if c_ptr is NULL or check if the dereference of c_ptr is 0/null terminator?

if it's supposed to be both, I'd argue for while(c_ptr && *c_ptr != 0)

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.