#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::fmt::{Display, Formatter, Result as FmtResult};
use alloc::string::String;
use glow::HasContext;
type GlTexture = <glow::Context as HasContext>::Texture;
type GlProgram = <glow::Context as HasContext>::Program;
type GlShader = <glow::Context as HasContext>::Shader;
type GlFramebuffer = <glow::Context as HasContext>::Framebuffer;
type GlBuffer = <glow::Context as HasContext>::Buffer;
type GlVertexArray = <glow::Context as HasContext>::VertexArray;
mod attribute;
mod buffer;
mod context;
mod shader;
mod surface;
mod texture;
mod uniform;
pub mod blend;
pub mod depth;
pub use self::attribute::{Attribute, AttributeType};
pub use self::buffer::{Buffer, ElementBuffer, VertexBuffer};
pub use self::context::Context;
pub use self::shader::{ShaderDescription, ShaderProgram};
pub use self::surface::Surface;
pub use self::texture::{Texture, TextureFilter, TextureWrap};
pub use self::uniform::{Uniform, UniformType, UniformValue};
pub use glow;
pub(crate) enum Position {
Input,
Output,
}
pub enum NumberType {
Int,
Float,
}
pub enum ColorFormat {
RGB,
RGBA,
}
impl ColorFormat {
pub fn bytes_per_pixel(&self) -> u32 {
match self {
ColorFormat::RGBA => 4,
ColorFormat::RGB => 3,
}
}
fn gl_format(&self) -> u32 {
match self {
ColorFormat::RGB => glow::RGB,
ColorFormat::RGBA => glow::RGBA,
}
}
}
#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum Dimension {
D2 = 2,
D3 = 3,
D4 = 4,
}
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub enum GeometryMode {
Points,
Lines,
LineStrip,
LineLoop,
Triangles,
TriangleStrip,
TriangleFan,
}
#[derive(Debug)]
pub enum GolemError {
ShaderCompilationError(String),
ContextError(String),
NoSuchUniform(String),
NotCurrentProgram,
MipMapsUnavailable,
IllegalWrapOption,
}
impl From<String> for GolemError {
fn from(other: String) -> Self {
GolemError::ContextError(other)
}
}
impl Display for GolemError {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
match self {
GolemError::ShaderCompilationError(e) => write!(fmt, "Shader compilation: {}", e),
GolemError::ContextError(e) => write!(fmt, "OpenGL: {}", e),
GolemError::NoSuchUniform(e) => write!(fmt, "Illegal uniform: {}", e),
GolemError::NotCurrentProgram => write!(fmt, "Shader program not bound"),
GolemError::MipMapsUnavailable => write!(fmt, "Mipmaps are unavailable"),
GolemError::IllegalWrapOption => write!(fmt, "An illegal texture wrap"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for GolemError {}