Skip to content

Commit

Permalink
Move required resources check up to callers
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraq committed Jan 28, 2024
1 parent de619c3 commit d463961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,6 @@ class OpenGLRenderer implements GraphicsRenderer, AutoCloseable, EventTarget {
@NamedVariant
void draw(Mesh mesh, Shader shader, Material material = null) {

// TODO: This should be an error - move responsiblity to that calling draw 🤔
// Is currently an issue because of the parallel nature of creating
// graphics resources. Once many can be created and returned at once,
// then this should no longer be needed.
if (!mesh || !shader) {
logger.warn('draw() method called without a mesh or shader')
return
}

averageNanos('draw', 1f, logger) { ->
shader.use()
if (material) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Sprite implements Node<Sprite>, GraphicsElement {
@Override
void render(GraphicsRenderer renderer) {

renderer.draw(mesh, shader, material)
if (mesh && shader && material) {
renderer.draw(mesh, shader, material)
}
}
}

0 comments on commit d463961

Please sign in to comment.