Coder Social home page Coder Social logo

sfgraphics's People

Contributors

scanmountgoat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hengle

sfgraphics's Issues

Uniform arrays shader set methods

GetVertexAttributeAndUniformLocation(string name) won't work properly for arrays.

// Shader
#version 330

uniform float[] values;
...
// Fails because the uniform name is "values" instead of "values[0]".
GL.Uniform1(shader.GetVertexAttributeAndUniformLocation("values[0]"), 1);
  • float[]
  • int[]
  • uint[]
  • Vec2[]
  • Vec3[]
  • Vec4[]
  • Mat4[]
  • Check uniform name with brackets removed. i.e. check "name" instead of "name[0]"
  • Change name checking in shader setters to reflect above change

Implement IDisposable for GLObject?

Implementing IDisposable allows for more predictable resource cleanup. Calling delete will crash if a context isnt current, however. GLObjectManager could still be used to clean up any remaining OpenGL resources.

Renderbuffer Class

Simplify the creation and management of OpenGL Renderbuffer Objects.

  • Depth attachment for framebuffer
  • Multisampling
  • Reference counting and memory management with GLObjectManager

Sampler object class

Sampler objects allow for modifying texture parameters for texture units without modifying the original texture.

Set read buffer and draw buffers for framebuffers

It should be clearer whether the draw buffers are set for all color attachments. Allow specifying which attachments should be used.

// What are the draw buffers?
Framebuffer framebuffer = new Framebuffer(1, 1, PixelInternalFormat.Rgba, 4); 
// Set explicitly.
framebuffer.SetDrawBuffers(0, 1, 3); 
framebuffer.SetReadBuffer(2);

Make objects have immutable data storage (OpenGL 4.5)

From OpenGL Reference for glTexStorage2D:
"Once a texture is specified with this command, the format and dimensions of all levels become immutable unless it is a proxy texture. The contents of the image may still be modified, however, its storage requirements may not change."

The texture's width/height parameters become incorrect after using GL.TexImage2D to resize a mip level. Resizing a texture requires initializing all the mip levels with new data anyway, so it doesn't make much sense to allow texture resizing. Framebuffer attachments are resized, but a new texture could be created instead.

Pros:

  • Prevents resizing texture data, even though width/height parameters cannot be changed.

Cons:

  • Attempts to resize the texture will generate GL_INVALID_OPERATION error.

This also applies to buffers. Immutable storage allows for assumptions to be made about the size of the data, making accessing the data easier. The appropriate OpenGL functions aren't core in version 3.30.

Don't allow compressed attachments to framebuffers

public Framebuffer(FramebufferTarget framebufferTarget, int width, int height,

From OpenGL Image Format Reference:
"Despite being color formats, compressed images are not color-renderable, for obvious reasons. Therefore, attaching a compressed image to a framebuffer object will cause that FBO to be incomplete and thus unusable. For similar reasons, no compressed formats can be used as the internal format of renderbuffers."

  • Don't allow compressed texture attachments.
  • Don't allow compressed render buffers.

Automatically update release with Appveyor build

  • Create first release
  • Update each release with successful Appveyor build
    Update version number after each successful Appveyor build

Version numbers might be added once the library is more stable.

separate shader location check for uniforms and attributes

The collection of vertex attributes and uniforms doesn't need to be public. This could be implemented as follows:

shader.GetUniformLocation("myUniform");
shader.GetUniformLocation("myUniform[2]");
shader.GetAttribLocation("myAttrib");

type checking for sampler uniforms

Add an error message to the shader log if the user attempts to set the wrong type of sampler. Ex: trying to initialize a sampler2D uniform by binding a cube map.

generics for texture class

The texture functions already allow generic structs for the texture methods. Using generics would allow for texture data to be specified in byte, float, int, or any value type. The user would be responsible for specifying the proper format options to allow OpenGL to interpret the data correctly.

Entire Class:
The existing constructors can be preserved, but this forces collections of textures and other classes using textures to care about what value type was used to initialize the texture's data.

Texture2D<byte> texture = new Texture2D<byte>(width, height, byteArray);

Methods Only:
The original format of the image data is irrelevant once the image is loaded. This simplifies other classes that rely on textures, such as the framebuffer class. The constructors can't be used for loading image data, however.

Texture2D texture = new Texture2D();
texture.LoadData<byte>(width, height, byteArray);

Buffer get/set data type mismatch

GetData() assumes the number of items returned will be equal to the number of items used to initialize the buffer's data. This works when the types are the same for getting and setting data, but it fails for setting a float array and reading back a byte array.

Possible fix:
Require the size in bytes of T for getting data. Throw an exception if the requested data exceeds the buffer's capacity.

More consistent object binding

Object binding should be more consistent to avoid redundant and accidental binding of objects.

MyObject myObject = new MyObject(target); // not bound
myObject.LoadData(data); // binds object
myObject.Bind(); // binds object
myObject.Unbind(); // binds default if possible

consistent GL object method names

Names should be consistent for GL objects. Buffer methods should not have buffer in the name, texture methods should not have texture in the name, etc.

buffer.Data()
buffer.Bind()

extract vector tools to separate project

The vector and color tools don't depend on any of the other SFGraphics classes, so there's no point keeping the projects together.

  • Create separate project
  • Add to unstable release
  • Update online documentation

Test uniform values for valid sets

The actual value of a uniform can be tested with GL.GetUniform(). This also works for arrays.

  • Scalar types
  • Vector types
  • Matrix types
  • Arrays

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.