Package de.ellpeck.rockbottom.api
Interface IRenderer
- All Superinterfaces:
IDisposable
The graphics context to interact with OpenGL as well as a multitude of
game-provided rendering methods. To access these methods, use the
IRenderer object given to you in render methods or access IGameInstance.getRenderer()-
Method Summary
Modifier and TypeMethodDescriptionvoidActivates a certain texture bank.voidaddEmptyRect(float x, float y, float width, float height, float lineWidth, int color) Draws a colored, unfilled rectangle at the specified x and y coordinates.voidaddEmptyRect(float x, float y, float width, float height, int color) Draws a colored, unfilled rectangle at the specified x and y coordinates.voidaddFilledRect(float x, float y, float width, float height, int color) Draws a colored, filled rectangle at the spcified x and y coordinates.voidaddTexturedRegion(ITexture texture, float x, float y, float x2, float y2, float x3, float y3, float x4, float y4, float srcX, float srcY, float srcX2, float srcY2, int[] light, int filter) Adds a certain region of a texture to this renderer.voidaddTriangle(float x1, float y1, float x2, float y2, float x3, float y3, int color1, int color2, int color3, float u1, float v1, float u2, float v2, float u3, float v3) Adds a triangle to this renderer.voidaddVertex(float x, float y, int color, float u, float v) Puts a single vertex into this renderer.voidbackgroundColor(int color) Sets the background color for this renderer to clear the screen with.voidbegin()Begins rendering with this renderer.voidCalculates the gui and world scale.Creates a new vao for any modder to usecreateVBO(boolean isStatic) Creates a new vbo for any modder to usevoiddescribeItem(IGameInstance game, IAssetManager manager, ItemInstance instance, boolean isRealItem) Renders an item's hover over information on the mouse cursor position.voiddrawHoverInfo(IGameInstance game, IAssetManager manager, float x, float y, float scale, boolean firstLineOffset, boolean canLeaveScreen, int maxLength, List<String> text) Draws a hovering information at the specified position using the specified textvoiddrawHoverInfoAtMouse(IGameInstance game, IAssetManager manager, boolean firstLineOffset, int maxLength, String... text) Draws a hovering information at the mouse's position using the specified textvoiddrawHoverInfoAtMouse(IGameInstance game, IAssetManager manager, boolean firstLineOffset, int maxLength, List<String> text) Draws a hovering information at the mouse's position using the specified textvoidend()Finishes rendering with this renderer and flushes the current rendering context.voidflush()Flushes the current rendering context, rendering everything that has been added to the renderer since the last call to this method.doubledoublefloatGets the display's ratio as a float.intfloatfloatfloatdoubleReturns the x position of the tile that the mouse is currently over.doubleReturns the y position of the tile that the mouse is currently over.floatfloatintGets the current vertices that this renderer is about to render.floatfloatfloatbooleanbooleanbooleanbooleanbooleanisDebug()booleanbooleanbooleanbooleanvoidvoidput(float f) Puts a single vertex component into this renderer and returns it for conveniencevoidrenderItemInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, int color) Renders an item and its amount.voidrenderItemInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, int color, boolean displayAmount, boolean displayDurability) Renders an item and its amount.voidrenderSlotInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, boolean hovered, boolean canPlaceInto) Renders a slot.voidrenderSlotInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, boolean hovered, boolean canPlaceInto, boolean renderBackground, int colorOverride) Renders a slot with additional argumentsvoidResets this renderer's translation, rotation, scale, mirrored states and texture origin back to their default values.voidrotate(float angle) Rotates this renderer's rendering context by the given angle.voidscale(float scale) Scales the renderer in both axes by the given amount.voidscale(float x, float y) Scales the renderer by the given amount.voidsetDefaultProgram(IShaderProgram program) Sets theIShaderProgramthat the game should fall back to whensetProgram(IShaderProgram)is called with a null parameter.voidsetProgram(IShaderProgram program) Sets theIShaderProgramthat the renderer should use to draw.voidsetTexture(ITexture texture) Sets theITexturethat the renderer should render any vertices with.voidtranslate(float x, float y) Translates this renderer's origin by the given amount.voidUnbinds all currently bound textures in all banksvoidUnbinds the currently bound shader programvoidUnbinds the currently bound texturevoidUnbinds the currently bound vaovoidUnbinds the currently bound vboMethods inherited from interface de.ellpeck.rockbottom.api.render.engine.IDisposable
dispose
-
Method Details
-
setDefaultProgram
Sets theIShaderProgramthat the game should fall back to whensetProgram(IShaderProgram)is called with a null parameter. This should only be used internally to set the world and gui shaders.- Parameters:
program- The new default shader program
-
addTexturedRegion
void addTexturedRegion(ITexture texture, float x, float y, float x2, float y2, float x3, float y3, float x4, float y4, float srcX, float srcY, float srcX2, float srcY2, int[] light, int filter) Adds a certain region of a texture to this renderer. This method gets called by allITexture.draw(float, float)methods, so using those will be more convenient in most cases.- Parameters:
texture- The texture to setx- The top left x coordinatey- The top left y coordinatex2- The top right x coordinatey2- The top right y coordinatex3- The bottom right x coordinatey3- The bottom right y coordinatex4- The bottom left x coordinatey4- The bottom left y coordinatesrcX- The top left x coordinate of the texturesrcY- The top left y coordinate of the texturesrcX2- The bottom right x coordinate of the texturesrcY2- The bottom right y coordinate of the texturelight- The light that the four corners of the drawn region should interpolate between, or null if there should be no light influencefilter- A filter color to modify this texture by- See Also:
-
addTriangle
void addTriangle(float x1, float y1, float x2, float y2, float x3, float y3, int color1, int color2, int color3, float u1, float v1, float u2, float v2, float u3, float v3) Adds a triangle to this renderer. This method gets called byaddTexturedRegion(ITexture, float, float, float, float, float, float, float, float, float, float, float, float, int[], int)twice to draw the two triangles of the square (or square-ish) region.- Parameters:
x1- The first x coordinatey1- The first y coordinatex2- The second x coordinatey2- The second y coordinatex3- The third x coordinatey3- The third y coordinatecolor1- The color at the first cornercolor2- The color at the second cornercolor3- The color at the third corneru1- The first texture xv1- The first texture yu2- The second texture xv2- The second texture yu3- The third texture xv3- The third texture y- See Also:
-
put
Puts a single vertex component into this renderer and returns it for convenience- Parameters:
f- The component to add- Returns:
- This renderer
-
addVertex
void addVertex(float x, float y, int color, float u, float v) Puts a single vertex into this renderer. This method gets called three times byaddTriangle(float, float, float, float, float, float, int, int, int, float, float, float, float, float, float)to add the three vertices for the three corners.- Parameters:
x- The x coordinatey- The y coordinatecolor- The coloru- The texture xv- The texture y- See Also:
-
begin
Begins rendering with this renderer. This method is internal and there should not be any reasons for a mod to call it. -
end
Finishes rendering with this renderer and flushes the current rendering context. This method is internal and there should not be any reasons for a mod to call it. -
flush
Flushes the current rendering context, rendering everything that has been added to the renderer since the last call to this method. This method is internal and there should not be any reasons for a mod to call it. -
pushMatrix
void pushMatrix() -
popMatrix
void popMatrix() -
rotate
void rotate(float angle) Rotates this renderer's rendering context by the given angle. This will only affect any vertices that are added to this renderer after calling this method.- Parameters:
angle- The angle
-
translate
void translate(float x, float y) Translates this renderer's origin by the given amount. This will only affect any vertices that are added to this renderer after calling this method.- Parameters:
x- The origin xy- The origin y
-
scale
void scale(float scale) Scales the renderer in both axes by the given amount. This will only affect any vertices that are added to this renderer after calling this method.- Parameters:
scale- The scale
-
scale
void scale(float x, float y) Scales the renderer by the given amount. This will only affect any vertices that are added to this renderer after calling this method.- Parameters:
x- The x scaley- The y scale
-
resetMatrix
void resetMatrix()Resets this renderer's translation, rotation, scale, mirrored states and texture origin back to their default values. -
getProgram
IShaderProgram getProgram()- Returns:
- The renderer's current shader program, set using
setProgram(IShaderProgram)
-
setProgram
Sets theIShaderProgramthat the renderer should use to draw. Calling this method while the renderer is active will cause the current vertices to be flushed and rendered with the last set shader program.- Parameters:
program- The new shader program
-
getTexture
ITexture getTexture()- Returns:
- The renderer's current texture, set using
setTexture(ITexture)
-
setTexture
Sets theITexturethat the renderer should render any vertices with. Calling this method while the renderer is active will cause the current vertices to be flushed and rendererd with the last set texture.- Parameters:
texture- The new texture
-
renderSlotInGui
void renderSlotInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, boolean hovered, boolean canPlaceInto) Renders a slot. This displays the (by default) green box based on the gui color as well as the item inside and the amount. To make a slot that has functionality, useItemContainerto create functioning slots.- Parameters:
game- The game instancemanager- The asset managerslot- The content of the slot to drawx- The x coordinatey- The y coordinatescale- The scalehovered- If the slot is currently being hovered or not. If this value is true, then the slot will be rendered with a slightly brighter colorcanPlaceInto- If the slot can contain the item that is currently on the cursor. If this value is true, then the slot will be rendered in grayscale
-
renderSlotInGui
void renderSlotInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, boolean hovered, boolean canPlaceInto, boolean renderBackground, int colorOverride) Renders a slot with additional arguments- Parameters:
game- the game instancemanager- the asset managerslot- the item instance to put into the slotx- the x coordinatey- the y coordinatescale- scalehovered- can it be hoveredcanPlaceInto- can it placed into itrenderBackground- Should the slot overlay be rendered? Usually true.colorOverride- What color should the slot be? UsuallySettings.guiColor
-
renderItemInGui
void renderItemInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, int color) Renders an item and its amount. This is similar torenderSlotInGui(IGameInstance, IAssetManager, ItemInstance, float, float, float, boolean, boolean), only that it doesn't render the box below the item.- Parameters:
game- The game instancemanager- The asset managerslot- The item to drawx- The x coordinatey- The y coordinatescale- The scalecolor- The color to filter the item's renderer with
-
renderItemInGui
void renderItemInGui(IGameInstance game, IAssetManager manager, ItemInstance slot, float x, float y, float scale, int color, boolean displayAmount, boolean displayDurability) Renders an item and its amount. This is similar torenderSlotInGui(IGameInstance, IAssetManager, ItemInstance, float, float, float, boolean, boolean), only that it doesn't render the box below the item.- Parameters:
game- The game instancemanager- The asset managerslot- The item to drawx- The x coordinatey- The y coordinatescale- The scalecolor- The color to filter the item's renderer withdisplayAmount- If the amount of items in this instance should be displayed as a little number below the itemdisplayDurability- If the durability of the item should be displayed
-
describeItem
void describeItem(IGameInstance game, IAssetManager manager, ItemInstance instance, boolean isRealItem) Renders an item's hover over information on the mouse cursor position. Additionally, it draws theisItemInfoDebug()text and also fires theTooltipEvent.- Parameters:
game- The game instancemanager- The asset managerinstance- The item whose information to drawisRealItem- Does the player own the item or is it just a preview in a GUI?
-
drawHoverInfoAtMouse
void drawHoverInfoAtMouse(IGameInstance game, IAssetManager manager, boolean firstLineOffset, int maxLength, String... text) Draws a hovering information at the mouse's position using the specified text- Parameters:
game- The game instancemanager- The asset managerfirstLineOffset- If the first line should have a bit of a gap below it making it act as a "headline"maxLength- The maximum length before the tooltip wraps into the next linetext- The array of lines of text to draw
-
drawHoverInfoAtMouse
void drawHoverInfoAtMouse(IGameInstance game, IAssetManager manager, boolean firstLineOffset, int maxLength, List<String> text) Draws a hovering information at the mouse's position using the specified text- Parameters:
game- The game instancemanager- The asset managerfirstLineOffset- If the first line should have a bit of a gap below it making it act as a "headline"maxLength- The maximum length before the tooltip wraps into the next linetext- The list of lines of text to draw
-
drawHoverInfo
void drawHoverInfo(IGameInstance game, IAssetManager manager, float x, float y, float scale, boolean firstLineOffset, boolean canLeaveScreen, int maxLength, List<String> text) Draws a hovering information at the specified position using the specified text- Parameters:
game- The game instancemanager- The asset managerx- The x positiony- The y positionscale- The scale of the tooltipfirstLineOffset- If the first line should have a bit of a gap below it making it act as a "headline"canLeaveScreen- If the tooltip can leave the screen or should stop at the bordersmaxLength- The maximum length before the tooltip wraps into the next linetext- The list of lines of text to draw
-
addEmptyRect
void addEmptyRect(float x, float y, float width, float height, int color) Draws a colored, unfilled rectangle at the specified x and y coordinates.- Parameters:
x- The x coordinatey- The y coordinatewidth- The widthheight- The heightcolor- The color
-
addEmptyRect
void addEmptyRect(float x, float y, float width, float height, float lineWidth, int color) Draws a colored, unfilled rectangle at the specified x and y coordinates.- Parameters:
x- The x coordinatey- The y coordinatewidth- The widthheight- The heightlineWidth- The width of the outlinescolor- The color
-
addFilledRect
void addFilledRect(float x, float y, float width, float height, int color) Draws a colored, filled rectangle at the spcified x and y coordinates.- Parameters:
x- The x coordinatey- The y coordinatewidth- The widthheight- The heightcolor- The color
-
activateTextureBank
Activates a certain texture bank. This can be used to draw from multiple textures at the same time, however it requires a custom shader to do so.- Parameters:
bank- The texture bank to read/write to and from
-
unbindTexture
void unbindTexture()Unbinds the currently bound texture -
unbindAllTextures
void unbindAllTextures()Unbinds all currently bound textures in all banks -
unbindVAO
void unbindVAO()Unbinds the currently bound vao -
unbindVBO
void unbindVBO()Unbinds the currently bound vbo -
unbindShaderProgram
void unbindShaderProgram()Unbinds the currently bound shader program -
createVAO
IVAO createVAO()Creates a new vao for any modder to use- Returns:
- A new vao
-
createVBO
Creates a new vbo for any modder to use- Parameters:
isStatic- Wether or not this vbo should useGL15.GL_STATIC_DRAWorGL15.GL_DYNAMIC_DRAW- Returns:
- A new vbo
-
calcScales
Calculates the gui and world scale. This is an internal method that should not be called by modders. -
getDisplayRatio
float getDisplayRatio()Gets the display's ratio as a float. For example, if the window's current display ratio was 16/9, that is the value that this method would return.- Returns:
- The display ratio
-
getGuiScale
float getGuiScale()- Returns:
- The scale with which the gui is currently being rendered. This
factors in both the gui scale option and the
getDisplayRatio().
-
getWorldScale
float getWorldScale()- Returns:
- The scale with which the world is currently being rendered. This
factors in both the world scale option and the
getDisplayRatio().
-
getWidthInWorld
float getWidthInWorld()- Returns:
- The width of the currently visible area of the world, in pixels.
- See Also:
-
getHeightInWorld
float getHeightInWorld()- Returns:
- The height of the currently visible area of the world, in pixels.
- See Also:
-
getWidthInGui
float getWidthInGui()- Returns:
- The width of the currently visible area of a gui, in pixels. This
is
IGameInstance.getWidth()multiplied bygetGuiScale(). - See Also:
-
getHeightInGui
float getHeightInGui()- Returns:
- The height of the currently visible area of a gui, in pixels.
This is
IGameInstance.getHeight()multiplied bygetGuiScale(). - See Also:
-
getMouseInGuiX
float getMouseInGuiX()- Returns:
- The y position of the mouse on gui scale level
- See Also:
-
getMouseInGuiY
float getMouseInGuiY()- Returns:
- The y position of the mouse on gui scale level
- See Also:
-
isDebug
boolean isDebug()- Returns:
- If the renderer is currently in debug mode, meaning the debug menu with a lot of additional information is open. This is activated by pressing F1.
-
isItemInfoDebug
boolean isItemInfoDebug()- Returns:
- If the renderer is currently in item info debug mode, meaning hovering over an item in an inventory will reveal additional information about its status. This is activated by pressing F5.
-
isChunkBorderDebug
boolean isChunkBorderDebug()- Returns:
- If the renderer is currently in chunk border debug mode, meaning that the borders of chunks will be shown in the world as green lines. This is activated by pressing F6.
-
isGuiDebug
boolean isGuiDebug()- Returns:
- If the renderer is currently in gui debug mode, meaning that opening and looking at a gui will show the bounding boxes of all of their components, along with their names and positions. This is activated by pressing F4.
-
isLineDebug
boolean isLineDebug()- Returns:
- If the renderer is currently in line debug mode, meaning that it will render a direct line between the drawn vertices rather than actually filling them with color or a texture. This is activated by pressing F2.
-
isBiomeDebug
boolean isBiomeDebug()- Returns:
- If the renderer is currently in biome debug mode, meaning that semi-transparent colored squares will be shown over every tile indicating its biome.
-
isHeightDebug
boolean isHeightDebug()- Returns:
- If the renderer is currently in height debug mode, meaning that a line will be shown on every tile to indicate the height of that position in the chunk.
-
isBoundBoxDebug
boolean isBoundBoxDebug() -
isCullingDebug
boolean isCullingDebug() -
getMousedTileX
double getMousedTileX()Returns the x position of the tile that the mouse is currently over. Rounding this value down using something likeUtil.floor(double)will reveal the tile's grid position in the world, whereas the decimal will reveal the percentage of how far into the tile the mouse cursor is.- Returns:
- The x position of the moused tile
-
getMousedTileY
double getMousedTileY()Returns the y position of the tile that the mouse is currently over. Rounding this value down using something likeUtil.floor(double)will reveal the tile's grid position in the world, whereas the decimal will reveal the percentage of how far into the tile the mouse cursor is.- Returns:
- The y position of the moused tile
-
getFlushes
int getFlushes()- Returns:
- The amount of flushes that this renderer has done since the last render frame.
- See Also:
-
backgroundColor
void backgroundColor(int color) Sets the background color for this renderer to clear the screen with. This is used for the sky and the main menu background's color.- Parameters:
color- The color
-
getVertices
FloatBuffer getVertices()Gets the current vertices that this renderer is about to render. These should only be modified usingput(float).- Returns:
- The vertices
-
getVertexAmount
int getVertexAmount()- Returns:
- The amount of vertices that are currently in the buffer
-
getCameraX
double getCameraX() -
getCameraY
double getCameraY() -
getMatrixStack
MatrixStack getMatrixStack()
-