This file contains hidden or 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
#version 330 core | |
layout ( location = 0 ) in vec2 vertex_position; | |
layout ( location = 2 ) in vec2 vertex_uv; | |
uniform mat4 M_mvp; | |
out vec2 uv; | |
void main() | |
{ | |
gl_Position = M_mvp * vec4( vertex_position , 0.0 , 1.0 ); | |
uv = vertex_uv; | |
} |
This file contains hidden or 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
#version 330 core | |
uniform sampler2D colorTexture; | |
uniform float resolution; | |
uniform float radius; | |
uniform vec2 direction; | |
in vec2 uv; | |
out vec4 fragColor; | |
void main() | |
{ | |
float blur = radius/resolution; |
This file contains hidden or 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
#version 330 core | |
uniform float threshold; | |
uniform float strength; | |
uniform sampler2D colorTexture; | |
in vec2 uv; | |
out vec4 fragColor; | |
void main() | |
{ | |
vec4 color = texture2D( colorTexture , uv ); | |
// convert rgb to grayscale/brightness |
This file contains hidden or 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
<?php | |
function lmysql_execute( $mysql , $sql , $types , ...$params ) | |
{ | |
if ( !( $stmt = $mysql->prepare( $sql ) ) ) | |
{ | |
error_log( "LMYSQL > prepare , errno: ".$mysql->errno.", error: ".$mysql->error ); | |
return false; | |
} | |
if ( strlen( $types ) > 0 ) |
This file contains hidden or 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
<?php | |
function foobar( $arg , $arg2 ) | |
{ | |
echo __FUNCTION__, " got $arg and $arg2\n"; | |
} | |
class foo | |
{ | |
function bar( $arg , $arg2 ) | |
{ | |
echo __METHOD__, " got $arg and $arg2\n"; |
This file contains hidden or 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
<?php | |
$sql = "INSERT INTO table ( a , b , c ) VALUES ( ? , ? , ? )"; | |
// prepared statement without the wrapper function | |
if ( $stmt = $mysql->prepare( $sql ) ) | |
{ | |
if ( $stmt->bind_param( "iis" , 1 , 2 , "string" ) ) | |
{ | |
if ( $stmt->execute() ) | |
{ |
This file contains hidden or 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
<?php | |
function ppnEncrypt( $data , $key ) | |
{ | |
$method = 'aes-256-gcm'; | |
$key = base64_decode( $key ); | |
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( $method ) ); | |
$tag = ""; // openssl_encrypt will fill this | |
$result = openssl_encrypt( $data , $method , $key , OPENSSL_RAW_DATA , $iv , $tag , "" , 16 ); | |
return base64_encode( $iv.$tag.$result ); | |
} |
This file contains hidden or 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
void render() | |
{ | |
// update camera based on mouse position, WASD, etc. | |
// calculate the view frustum | |
viewFrustum.calculate( 60.0f , (float)window->getWidth()/(float)window->getHeight() , 0.1f , 100.0f ); | |
// convert the view frustum to world space | |
viewFrustum.convertToWorldSpace( camera->getInverseViewMatrix() ); |
This file contains hidden or 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
void ViewFrustum::calculate( const float fov , const float aspectratio , const float n , const float f ) | |
{ | |
float nearPlane = -n; | |
float farPlane = -f; | |
float y1 = nearPlane * tanf(torad(fov)/2.0f); | |
float y2 = farPlane * tanf(torad(fov)/2.0f); | |
// calculate the horizontal fov from the vertical one | |
float fov_horizontal = 2.0f * atanf( tanf(torad(fov)/2.0f) * aspectratio ); |
NewerOlder