Skip to content

Instantly share code, notes, and snippets.

View lewkoo's full-sized avatar

Levko Ivanchuk lewkoo

View GitHub Profile
@lewkoo
lewkoo / shader.frag
Created February 27, 2014 03:20
Fragment shader for a very simple Android shader example
precision highp float;
void main()
{
// gl_FragCoord contains the window relative coordinate for the fragment.
// we use gl_FragCoord.x position to control the red color value.
// we use gl_FragCoord.y position to control the green color value.
// please note that all r, g, b, a values are between 0 and 1.
@lewkoo
lewkoo / shader.vert
Created February 27, 2014 03:20
Vertex shader for Android simple shader example
attribute vec4 position;
uniform mat4 modelViewProjectionMatrix;
void main(){
gl_Position = modelViewProjectionMatrix * position;
}
@lewkoo
lewkoo / main.cpp
Created February 27, 2014 03:19
main.cpp of a very simple Android shader example
#include "ofMain.h"
#include "ofApp.h"
// comment out the line below if you want to use a fixed pipeline opengl renderer,
// otherwise leave this line uncommented if you want to use a programmable pipeline opengl renderer.
#define USE_PROGRAMMABLE_RENDERER
#ifdef USE_PROGRAMMABLE_RENDERER
#include "ofGLProgrammableRenderer.h"
#endif
@lewkoo
lewkoo / ofApp.h
Created February 27, 2014 03:19
ofApp.h of a very simple Android shader code
#ifndef _TEST_APP
#define _TEST_APP
#include "ofMain.h"
#include "ofxAndroid.h"
class ofApp : public ofxAndroidApp{
public:
@lewkoo
lewkoo / ofApp.cpp
Created February 27, 2014 03:18
ofApp.cpp of a very simple Android shader example code
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofSetLogLevel(OF_LOG_VERBOSE);
ofBackground(34, 34, 34);
ofSetVerticalSync(false);
ofEnableAlphaBlending();
#version 120
void main() {
vec4 color;
float xCor = gl_FragCoord.x;
vec4 white = vec4(1);
vec4 black = vec4(0);
float x = smoothstep(0, 960.0, xCor);
@lewkoo
lewkoo / testApp.cpp
Created January 25, 2014 17:41
Shader usage
void testApp::draw()
{
if(doShader)
shader.begin();
gradient.draw(0,0,960,540);
if(doShader)
shader.end();
@lewkoo
lewkoo / add_20.frag
Last active January 4, 2016 10:19
Fragment shader
#version 120
void main(){
//this is the fragment shader
//this is where the pixel level drawing happens
//gl_FragCoord gives us the x and y of the current pixel its drawing
gl_FragColor.r = gl_Color.r + 20;
gl_FragColor.g = gl_Color.g + 20;
@lewkoo
lewkoo / testApp.cpp
Created January 24, 2014 21:19
testApp inicialization
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofSetLogLevel(OF_LOG_VERBOSE);
ofBackground(34, 34, 34);
ofSetVerticalSync(false);
ofEnableAlphaBlending();
@lewkoo
lewkoo / testApp.hpp
Last active January 4, 2016 10:09
testFile.hpp
#pragma once
#include "ofMain.h"
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();