Last active
March 12, 2017 18:57
-
-
Save mfandl/e9ce9e71e25820f29c4a5857b3d688f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- vertex shader | |
#version 150 | |
uniform mat4 modelViewProjectionMatrix; | |
uniform float elapsedTime; | |
in vec4 position; | |
void main(){ | |
gl_Position = modelViewProjectionMatrix * vec4(position.x * sin(elapsedTime), position.y * cos(elapsedTime), position.z, position.w); | |
} | |
// -- fragment shader | |
#version 150 | |
out vec4 outputColor; | |
void main() | |
{ | |
outputColor = vec4(1.0, 1.0, 1.0, 1.0); | |
} | |
// -- | |
// shadere das do zlozky bin/data/shaders/ s nazvami shader.frag a shader.vert | |
// v ofApp.h: | |
ofShader shader; | |
//v ofApp.cpp v setup metode | |
shader.load("shaders/shader") | |
// v draw davas kreslenie meshov medzi shader.begin() a shader.end() | |
// mozes kludne spravit nieco taketo: | |
void ofApp::draw(){ | |
ofDrawBitmapString(ofGetFrameRate(), 100, 100); | |
ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); | |
shader.begin(); | |
shader.setUniform1f("elapsedTime", ofGetElapsedTimef()); | |
for (int i = 0; i < 10; ++i) { | |
ofDrawRectangle(0, 0, 10, 10); | |
} | |
shader.end(); | |
} | |
// a malo by to ficat - to ofDrawRectangle podla mna len nejak natlaci geometriu a kresli | |
// na grafickej karte. ale lepsie asi bude spravit ofMesh alebo ofVboMesh u ktorych mozes pouzivat metody | |
// addVertices a addIndices a takto si spravit ten polygon aky chces. ak chces loadnut nieco co si vygenerujes sam, | |
// v project generatore len pridaj addon ofxAssimpModelLoader a s nim to vies spravit. | |
//ten kod hore by mal byt OK, ale nevidel som vysledok, tak sa dopredu ospraveldnujem za nejake chyicky |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment