Skip to content

Instantly share code, notes, and snippets.

View kioba's full-sized avatar
🏠
Working from home

kioba kioba

🏠
Working from home
View GitHub Profile
@kioba
kioba / QuadCurvePix.c
Last active November 7, 2015 11:24
Quadratic Curve Pixel Shader
float4 QuadraticPS(float2 p : TEXCOORD0,
float4 color : COLOR0) : COLOR
{
// Gradients
float2 px = ddx(p);
float2 py = ddy(p);
// Chain rule
float fx = (2*p.x)*px.x - px.y;
float fy = (2*p.x)*py.x - py.y;
// Signed distance
@kioba
kioba / shared_ptr.cpp
Last active November 8, 2015 23:06
std::shared_ptr question! "Is it correct?"
#include <iostream>
#include <memory>
class Base
{
public:
Base()
{
std::cout << "Base Constructor!" << std::endl;
}
@kioba
kioba / deletedfunc.cpp
Created November 10, 2015 15:20
C11 explicit delete class function
#include <iostream>
class Destructor
{
public:
Destructor();
virtual ~Destructor() = delete;
void print();
};
@kioba
kioba / nullptr.cpp
Last active January 2, 2017 22:07
c++11 what is 0, NULL and nullptr?
#include <iostream>
void whatis(int*& pointer);
int main()
{
int* isempty;
int* zero = 0;
@kioba
kioba / shader_compile.cpp
Last active November 17, 2015 17:16
Vertex and Fragment shader compile function
GLuint Shader::LoadShaders(const std::string VertexShaderCode, const std::string FragmentShaderCode)
{
GLint Result = GL_FALSE;
glGetIntegerv(GL_SHADER_COMPILER, &Result);
if (Result == GL_FALSE) {
return Result;
}
@kioba
kioba / rect.cpp
Created November 17, 2015 20:17
drawing a rectangle creat and draw function
void Rect::create()
{
static float a = 0;
a += 0.01f;
std::vector<float> vertex_buffer_data = {
0.0f + a, 0.0f + a, a,
0.3f + a, 0.0f + a, a,
0.3f + a, 0.3f + a, a,
0.0f + a, 0.0f + a, a,
0.3f + a, 0.3f + a, a,
@kioba
kioba / glmvec4.cpp
Created November 17, 2015 23:02
GLM::vec4 union names
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
value_type x, y, z, w;
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union
{
struct{value_type x, y, z, w;};
struct{value_type r, g, b, a;};
struct{value_type s, t, p, q;};
};
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
@kioba
kioba / shared_ptr_bool.cpp
Created November 30, 2015 16:23
Is it true or false?
#include <iostream>
#include <memory>
int main()
{
std::shared_ptr<bool> boolean(new bool(false));
if (boolean) {
std::cout << "True" << std::endl;
} else {
@kioba
kioba / main.cpp
Created January 28, 2016 12:09
infinite loop?
int main() {
int x = 0;
while (x < 5) {
x = x++;
}
return 0;
}
#include <stdio.h>
#include <memory>
class Base
{
public:
virtual void print() {
printf("Base");
}
};