Skip to content

mmj-the-fighter/Spinach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spinach

A framework for starting with computer graphics. It uses SDL3 library.
But can be retargetted to other windowing frameworks by modifying the source code.
Presentation on YouTube with synthetic voice

Useful for:

  • Writing lab programs in a first course for computer graphics
    (pixels, lines, polygons, circles, ellipses, filling, clipping, transforms etc.)
  • Writing raytracers
  • Writing programs for advanced curves
  • Writing software rasterizers
  • Writing image processing routines
  • Games
  • and so on.

Known Issues

Examples / Tutorials

Build / Project Generation

Prerequisites

  • The root folder must contain the res directory.
  • CMake must be installed.

Steps

  1. Create a directory named build in the project root.
  2. Open a terminal in the project root and run:
cd build
cmake ..

This will generate the project files inside the build directory.

Key Bindings

Five keys are handled in the engine:

Key Behaviour
Esc Application closes
F12 A screenshot is saved with the current timestamp
F8 Screen recording starts; recording indication is shown in the screen
F10 Screen recording ends; the gif is saved with the current time stamp
F6 Screen recording aborts; no file is saved

Projects that use Spinach

App Skeleton

#include <iostream>
#include <spn_canvas.h>
#include <spn_core.h>

void UpdateAndRender(spn::Canvas* canvas) {
	//Draw something with the canvas
}

void HandleInput(const SDL_Event* sdlEvent) {
	//std::cout << "*";
}


int main(int argc, char* argv[])
{
	spn::SpinachCore sc;
	if (!sc.Init(640, 480, "../res/")) {
		std::cout << "initialization failed with error "
			<< sc.GetInitializationResult()
			<< std::endl;
		return 1;
	}
	sc.SetUpdateAndRenderHandler(UpdateAndRender);
	sc.SetInputHandler(HandleInput);	
	sc.SetWindowTitle("Spinach Demo");
	sc.GetCanvas()->SetPrimaryColor(255, 255, 0);
	sc.SetTargetFramesPerSecond(30);
	sc.LockFps(true);
	sc.MainLoop();
	return 0;
}

About

Easy to use framework and utilities for software rasterization, image processing and other experiments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors