Class OGLSystem<G extends OGLGraphics>
java.lang.Object
com.blackrook.gloop.opengl.OGLSystem<G>
- Type Parameters:
G- the graphics object to call.
The starting point: the OpenGL subsystem.
An implementation of OpenGL is initialized here, attached to a GLFWWindow
and spawns a thread that makes it responsible for the rendering the context
(see GLFWContext.makeContextCurrent(GLFWWindow)). The rendering thread
can either fire refreshes at a steady rate or listen for a trigger via display()
to kick off a frame draw.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA control class for the rendering thread, now locked to a window. -
Method Summary
Modifier and TypeMethodDescriptionAdds a node to this system.attachToWindow(com.blackrook.gloop.glfw.GLFWWindow window) Locks this OGLSystem to a window and returns a control for setting the screen redraw interval for the rendering thread.booleandisplay()Triggers a display refresh, telling the rendering thread to draw a frame.floatgetFPS()longReturns the length of time it took to render this frame.intGets the number of polygonal objects rendered in this canvas, gathered from the executed nodes.longGets the length of time it took to render each individual node in nanoseconds, accumulated from the executed nodes.booleanremoveNode(OGLNode<? super G> node) Removes a node from this system.
-
Method Details
-
attachToWindow
public OGLSystem<G>.RenderingThreadControl attachToWindow(com.blackrook.gloop.glfw.GLFWWindow window) Locks this OGLSystem to a window and returns a control for setting the screen redraw interval for the rendering thread.DO NOT call this method if you have generated an
OGLCanvasfor this system.- Parameters:
window- the window to lock the render context to.- Returns:
- a controller for setting rendering speed.
- Throws:
IllegalStateException- if already attached to a window.
-
display
public boolean display()Triggers a display refresh, telling the rendering thread to draw a frame. If a frame is currently being drawn, this will return false, indicating a dropped frame. Otherwise, this returns true.- Returns:
- true if redrawing, false if not.
- Throws:
IllegalStateException- if not attached to a window.
-
addNode
-
removeNode
-
getFrameRenderTimeNanos
public long getFrameRenderTimeNanos()Returns the length of time it took to render this frame. This is NOT the same asgetRenderTimeNanos(), as it takes time between frames (real time) into consideration. The methodgetFPS()uses this information.Results of this call should not be considered accurate until the node has had
display()called on it twice.- Returns:
- the length of time in nanoseconds.
-
getRenderTimeNanos
public long getRenderTimeNanos()Gets the length of time it took to render each individual node in nanoseconds, accumulated from the executed nodes. The results of this call should not be considered accurate until the node has haddisplay()called on it.- Returns:
- the length of time it took to render each individual node in nanoseconds.
-
getPolygonsRendered
public int getPolygonsRendered()Gets the number of polygonal objects rendered in this canvas, gathered from the executed nodes. The results of this call should not be considered accurate until the node has haddisplay()called on it.- Returns:
- the number of polygonal objects rendered in this canvas.
-
getFPS
public float getFPS()- Returns:
- the estimated frames per second in this context based on the time to render the nodes.
-