Class DisplayWindow
java.lang.Object
net.minecraftforge.fml.earlydisplay.DisplayWindow
- All Implemented Interfaces:
- ImmediateWindowProvider
The Loading Window that is opened Immediately after Forge starts.
 It is called from the ModDirTransformerDiscoverer, the soonest method that ModLauncher calls into Forge code.
 In this way, we can be sure that this will not run before any transformer or injection.
 The window itself is spun off into a secondary thread, and is handed off to the main game by Forge.
 Because it is created so early, this thread will "absorb" the context from OpenGL.
 Therefore, it is of utmost importance that the Context is made Current for the main thread before handoff,
 otherwise OS X will crash out.
 Based on the prior ClientVisualization, with some personal touches.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate ColourSchemeprivate RenderElement.DisplayContextprivate List<RenderElement>private ElementShaderprivate static final Stringprivate intprivate intprivate intprivate SimpleFontprivate EarlyFramebufferprivate intprivate static final int[][]private Stringprivate ScheduledFuture<?>private Methodprivate static final org.slf4j.Loggerprivate booleanprivate static final longprivate longprivate PerformanceInfoprivate ScheduledFuture<?>private final Semaphoreprivate ScheduledExecutorServiceprivate Runnableprivate longprivate ScheduledFuture<?>private intprivate intprivate intprivate int
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddMojangTexture(int textureId) private voidbadWindowHandler(int code, long desc) voidclose()context()private voidcrashElegantly(String errorDetails) private voidfbResize(long window, int width, int height) intThis is called to construct aForgeFeaturefor the GL_VERSION we managed to create for the window.private voidhandleLastGLFWError(BiConsumer<Integer, String> handler) initialize(String[] arguments) This is called very early on to initialize ourselves.private voidinitRender(@Nullable String mcVersion, String forgeVersion) Render initialization methods called by the Render Thread.voidinitWindow(@Nullable String mcVersion) Called to initialize the window when preparing for the Render Thread.<T> Supplier<T>Return a Supplier of an object extending the LoadingOverlay class from Mojang.name()(package private) voidCalled every frame by the Render Thread to draw to the screen.voidThis is called periodically during the loading process to "tick" the window.booleanpositionWindow(Optional<Object> monitor, IntConsumer widthSetter, IntConsumer heightSetter, IntConsumer xSetter, IntConsumer ySetter) This is called after window handoff to allow us to tell Mojang about our window's position.voidrender(int alpha) private voidThe main render loop.longsetupMinecraftWindow(IntSupplier width, IntSupplier height, Supplier<String> title, LongSupplier monitorSupplier) Hand-off the window to the vanilla game.Start the window and Render Thread; we're ready to go.voidupdateFramebufferSize(IntConsumer width, IntConsumer height) This will be called during the handoff to minecraft to update minecraft with the size of the framebuffer we have.voidupdateModuleReads(ModuleLayer layer) This is called during the module loading process to allow us to find objects inside the GAME layer, such as a later loading screen.private voidwinMove(long window, int x, int y) private voidwinResize(long window, int width, int height) 
- 
Field Details- 
GL_VERSIONSprivate static final int[][] GL_VERSIONS
- 
LOGGERprivate static final org.slf4j.Logger LOGGER
- 
animationTimerTrigger
- 
colourScheme
- 
elementShader
- 
context
- 
elements
- 
framecountprivate int framecount
- 
framebuffer
- 
windowTick
- 
initializationFuture
- 
performanceInfo
- 
performanceTick
- 
windowprivate long window
- 
renderScheduler
- 
fbWidthprivate int fbWidth
- 
fbHeightprivate int fbHeight
- 
fbScaleprivate int fbScale
- 
winWidthprivate int winWidth
- 
winHeightprivate int winHeight
- 
winXprivate int winX
- 
winYprivate int winY
- 
renderLock
- 
maximizedprivate boolean maximized
- 
glVersion
- 
font
- 
repaintTick
- 
MINFRAMETIMEprivate static final long MINFRAMETIME
- 
nextFrameTimeprivate long nextFrameTime
- 
ERROR_URL- See Also:
 
- 
loadingOverlay
 
- 
- 
Constructor Details- 
DisplayWindowpublic DisplayWindow()
 
- 
- 
Method Details- 
name- Specified by:
- namein interface- ImmediateWindowProvider
- Returns:
- The name of this window provider. Do NOT use fmlearlywindow.
 
- 
initializeDescription copied from interface:ImmediateWindowProviderThis is called very early on to initialize ourselves. Use this to initialize the window and other GL core resources. One thing we want to ensure is that we try and create the highest GL_PROFILE we can accomplish. GLFW_CONTEXT_VERSION_MAJOR,GLFW_CONTEXT_VERSION_MINOR should be as high as possible on the created window, and it should have all the typical profile settings.- Specified by:
- initializein interface- ImmediateWindowProvider
- Parameters:
- arguments- The arguments provided to the Java process. This is the entire command line, so you can process stuff from it.
- Returns:
- A runnable that will be periodically ticked by FML during startup ON THE MAIN THREAD. This is usually a good place to put glfwPollEvents() tests.
 
- 
renderThreadFuncprivate void renderThreadFunc()The main render loop. renderThread executes this. Performs initialization and then ticks the screen at 20 fps. When the thread is killed, context is destroyed.
- 
initRenderRender initialization methods called by the Render Thread. It compiles the fragment and vertex shaders for rendering text with STB, and sets up basic render framework. Nothing fancy, we just want to draw and render text.
- 
paintFramebuffervoid paintFramebuffer()Called every frame by the Render Thread to draw to the screen.
- 
renderpublic void render(int alpha) 
- 
startStart the window and Render Thread; we're ready to go.
- 
getGLVersionDescription copied from interface:ImmediateWindowProviderThis is called to construct aForgeFeaturefor the GL_VERSION we managed to create for the window. Should be a string of the format {MAJOR}.{MINOR}, such as 4.6, 4.5 or such.- Specified by:
- getGLVersionin interface- ImmediateWindowProvider
- Returns:
- the GL profile we created
 
- 
crashElegantly
- 
initWindowCalled to initialize the window when preparing for the Render Thread. The act of calling glfwInit here creates a concurrency issue; GL doesn't know whether we're gonna call any GL functions from the secondary thread and the main thread at the same time. It's then our job to make sure this doesn't happen, only calling GL functions where the Context is Current. As long as we can verify that, then GL (and things like OS X) have no complaints with doing this.- Parameters:
- mcVersion- Minecraft Version
 
- 
badWindowHandlerprivate void badWindowHandler(int code, long desc) 
- 
winResizeprivate void winResize(long window, int width, int height) 
- 
fbResizeprivate void fbResize(long window, int width, int height) 
- 
winMoveprivate void winMove(long window, int x, int y) 
- 
handleLastGLFWError
- 
setupMinecraftWindowpublic long setupMinecraftWindow(IntSupplier width, IntSupplier height, Supplier<String> title, LongSupplier monitorSupplier) Hand-off the window to the vanilla game. Called on the main thread instead of the game's initialization.- Specified by:
- setupMinecraftWindowin interface- ImmediateWindowProvider
- Parameters:
- width- This is the width of the window Mojang expects
- height- This is the height of the Window Mojang expects.
- title- This is the title for the window.
- monitorSupplier- This is the monitor it should appear on.
- Returns:
- the Window we own.
 
- 
positionWindowpublic boolean positionWindow(Optional<Object> monitor, IntConsumer widthSetter, IntConsumer heightSetter, IntConsumer xSetter, IntConsumer ySetter) Description copied from interface:ImmediateWindowProviderThis is called after window handoff to allow us to tell Mojang about our window's position. This might give a preferrable user experience to users, because we just tell Mojang our truth, rather than accept theirs.- Specified by:
- positionWindowin interface- ImmediateWindowProvider
- Parameters:
- monitor- This is the monitor we're rendering on. Note that this is the Mojang monitor object. You might have trouble unwrapping it.
- widthSetter- This sets the width on the Mojang side
- heightSetter- This sets the height on the Mojang side
- xSetter- This sets the x coordinate on the Mojang side
- ySetter- This sets the y coordinate on the Mojang side
- Returns:
- true if you've handled the window positioning - this skips the "forced fullscreen" code until a later stage
 
- 
updateFramebufferSizeDescription copied from interface:ImmediateWindowProviderThis will be called during the handoff to minecraft to update minecraft with the size of the framebuffer we have. Generally won't be called because Minecraft figures it out for itself.- Specified by:
- updateFramebufferSizein interface- ImmediateWindowProvider
- Parameters:
- width- Consumer of the framebuffer width
- height- Consumer of the framebuffer height
 
- 
loadingOverlaypublic <T> Supplier<T> loadingOverlay(Supplier<?> mc, Supplier<?> ri, Consumer<Optional<Throwable>> ex, boolean fade) Description copied from interface:ImmediateWindowProviderReturn a Supplier of an object extending the LoadingOverlay class from Mojang. This is what will be used once the Mojang window code has taken over rendering of the window, to render the later stages of the loading process.- Specified by:
- loadingOverlayin interface- ImmediateWindowProvider
- Type Parameters:
- T- This is the type LoadingOverlay to allow type binding on the Mojang side
- Parameters:
- mc- This supplies the Minecraft object
- ri- This supplies the ReloadInstance object that tells us when the loading is finished
- ex- This Consumes the final state of the loading - if it's an error you pass it the Throwable, otherwise you pass Optional.empty()
- fade- This is the fade flag passed to LoadingOverlay. You probably want to ignore it.
- Returns:
- A supplier of your later LoadingOverlay screen.
 
- 
updateModuleReadsDescription copied from interface:ImmediateWindowProviderThis is called during the module loading process to allow us to find objects inside the GAME layer, such as a later loading screen.- Specified by:
- updateModuleReadsin interface- ImmediateWindowProvider
- Parameters:
- layer- This is the GAME layer from ModLauncher
 
- 
getFramebufferTextureIdpublic int getFramebufferTextureId()
- 
context
- 
periodicTickpublic void periodicTick()Description copied from interface:ImmediateWindowProviderThis is called periodically during the loading process to "tick" the window. It is typically the same as the Runnable fromImmediateWindowProvider.initialize(String[])- Specified by:
- periodicTickin interface- ImmediateWindowProvider
 
- 
addMojangTexturepublic void addMojangTexture(int textureId) 
- 
closepublic void close()
 
-