Skip to content

Instantly share code, notes, and snippets.

@patternspandemic
Last active October 5, 2017 05:58
Show Gist options
  • Save patternspandemic/e5d63b5242c62bf07253450581998dc9 to your computer and use it in GitHub Desktop.
Save patternspandemic/e5d63b5242c62bf07253450581998dc9 to your computer and use it in GitHub Desktop.
Exploded line rendering with rotation transform.
#include "pch.h"
#include <Kore/Graphics4/Graphics.h>
#include <Kore/Graphics2/Graphics.h>
#include <Kore/System.h>
#include <limits>
using namespace Kore;
namespace {
Graphics2::Graphics2* g2;
void update() {
Graphics4::begin();
g2->begin();
g2->clear(0xff333333);
float a = Kore::pi * 0.25;
g2->transformation = mat3::Translation(320, 240) * mat3::RotationZ(a) * mat3::Translation(-320, -240);
g2->setColor(0xff00ff00);
g2->drawLine(50.0, 240, 590, 240, 5.0);
// g2->drawRect(280, 200, 80, 80, 5.0);
g2->transformation = mat3::Identity();
g2->setColor(0xffffffff);
g2->end();
Graphics4::end();
Graphics4::swapBuffers();
}
}
int kore(int argc, char** argv) {
System::init("RotatedLineExample", 640, 480);
System::setCallback(update);
g2 = new Graphics2::Graphics2(640, 480);
System::start();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment