Documentation ¶
Overview ¶
Package shaders contains plain vertex and fragment shaders, version 1.30 (OpenGL 3.0).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Shader ¶
type Shader struct { VertexShader **uint8 FragmentShader **uint8 VertexShaderID uint32 FragmentShaderID uint32 ProgramID uint32 PositionAttribute *uint8 ColorAttribute *uint8 CoordsAttribute *uint8 ProjectionUniform *uint8 ModelUniform *uint8 TextureUniform *uint8 PositionLocation int32 ColorLocation int32 CoordsLocation int32 ProjectionLocation int32 ModelLocation int32 TextureLocation int32 }
Shader is for storing shaders and their attributes.
func NewPrimitiveShader ¶
func NewPrimitiveShader() *Shader
NewPrimitiveShader returns an instance of Shader for primitive types.
Vertex shader:
#version 130 in vec3 positionIn; in vec4 colorIn; out vec4 fragementColor; uniform mat4 projection = mat4(1.0); uniform mat4 model = mat4(1.0); void main() { gl_Position = projection * model * vec4(positionIn, 1.0f); fragementColor = colorIn; }
Fragment shader:
#version 130 in vec4 fragementColor; out vec4 color; void main () { color = fragementColor; }
func NewTextureShader ¶
func NewTextureShader() *Shader
NewTextureShader returns an instance of Shader for textures.
Vertex shader:
#version 130 in vec3 positionIn; in vec2 textureCoordsIn; out vec2 fragmentTextureCoords; uniform mat4 projection = mat4(1.0); uniform mat4 model = mat4(1.0); void main() { gl_Position = projection * model * vec4(positionIn, 1.0f); fragmentTextureCoords = textureCoordsIn; }
Fragment shader:
#version 130 in vec2 fragmentTextureCoords; out vec4 color; uniform sampler2D imageTexture; void main () { color = texture(imageTexture, fragmentTextureCoords); }
func (*Shader) FragmentShaderStr ¶
FragmentShaderStr returns fragment shader as string.
func (*Shader) VertexShaderStr ¶
VertexShaderStr returns vertex shader as string.
Click to show internal directories.
Click to hide internal directories.