scanmountgoat / sfgraphics Goto Github PK
View Code? Open in Web Editor NEWObject oriented OpenGL wrapper and rendering library using OpenTK
License: MIT License
Object oriented OpenGL wrapper and rendering library using OpenTK
License: MIT License
Simplify attaching textures to color or depth attachments.
The vector and color tools don't depend on any of the other SFGraphics classes, so there's no point keeping the projects together.
Show the shader type in error logs to display which errors belong to the which shader type.
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
Simplify the creation and management of OpenGL Renderbuffer Objects.
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.
This will make uniform buffers of matrices for vertex skinning easier to work with.
Simply testing the reference count methods themselves would be helpful. There isn't a way to ensure the finalizers are called during a test method.
This should be detected earlier, so a more meaningful exception can be thrown.
SFGraphics/src/SFGraphics/GLObjects/Textures/Texture2D.cs
Lines 121 to 122 in bba715d
OpenGL Reference
OpenGL doesn't even recommend these. There isn't a way to upload data directly in this format. The block size also can't be determined.
Create a constructor for cubemaps from mipmap data in an uncompressed format.
Not all formats are supported, which results in calls to GL.CompressedTexImage2D throwing an InvalidValue error for some formats.
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()
Sampler objects allow for modifying texture parameters for texture units without modifying the original texture.
The data can be read using GL.GetBufferSubData
after binding the buffer to the appropriate target.
Newer versions of OpenGL support precompiled shaders that are loaded from a binary format.
The actual value of a uniform can be tested with GL.GetUniform()
. This also works for arrays.
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.
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.
Depending on the shape of the object, the bounding sphere's volume may contain part of the object or none of it. Ex: the bounding sphere generated for a cube would fit fully inside the cube, which is not the intended result.
SFGraphics/src/SFGraphics/Tools/BoundingSphereGenerator.cs
Lines 63 to 65 in fa55d23
glTexParameter only works for certain targets, so the base texture constructor should not allow other targets.
Version numbers might be added once the library is more stable.
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);
Does deleting a framebuffer delete its attachments?
SFGraphics/src/SFGraphics/GLObjects/Framebuffer.cs
Lines 65 to 66 in c0fbb31
Don't allow invalid offsets to be used. GL.BufferSubData can't make a buffer bigger.
Provide methods for initializing bufferobject data from an array of structs.
ToString() returns the type (texture, framebuffer, etc) and Id.
OpenGL already calculates the correct number of mipmaps. If users want a specific number of mipmaps, they should manually specify the data themselves.
GL.GenerateMipmaps
needs to be called for manually specified mipmaps.mipCount
parameter.This would probably only require implementing an interface that provides an Attach(Framebuffer target)
method.
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);
This project doesn't even need the fancy new Visual Studio.
The mipmap loading methods generate a lot of errors for cube map targets.
The release should show the commit hash and/or timestamp to differentiate between versions.
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");
New test cases to ensure all points are in the bounding sphere.
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:
Cons:
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.
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."
Renderbuffers can be attached but not accessed. Any texture target can be used as long as it is not TextureCubeMap.
The target should be PixelUnpackBuffer. Any buffer can be bound to this target.
The tests fail with an invalid enum exception.
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);
From OpenGL 4 reference for glTexImage2D:
"GL_INVALID_OPERATION is generated if format is GL_DEPTH_COMPONENT and internalFormat is not GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F."
Compare the output to an expected value rather than just checking the sign or if it equals a zero vector.
The camera class should be tested with other SFGraphics classes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.