Class TextFieldEntity
- All Implemented Interfaces:
RenderDataAPI
Recommend put in to the highest layer if you use rendering manage.
Only draws color and emissive to framebuffer color attachment.
Loading font info or submit string will both cost some time, usual should to preload it.
Anchor at top-left of text field.
Remember to register your font texture at settings.json, or load texture by TextureManager and set it later.
Use RESERVED_SYMBOL for create empty character (will not display anything), if you will display a dynamic value or text such as flux value.
One of the ways for how to change the text content in existed TextData:
TextFieldEntity text;
final var data = text.getTextDataList().get(0); // if the text content was in the index 0
data.setText("another text");
data.setColor(Color.RED);
// and then call submit
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefault valueTextFieldEntity.Alignment.LEFT.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byteprotected booleanprotected List<TextFieldEntity.TextData>protected List<org.lwjgl.util.vector.Vector4f>protected static final byteprotected TextSubmitFeedbackAPIprotected final intprotected final intprotected static final byteprotected TextFieldEntity.Alignmentprotected final IntBufferprotected FontMapData[]static final charstatic final charstatic final charprotected final float[]protected final boolean[]protected final int[]protected final float[]Fields inherited from class org.boxutil.base.BaseRenderData
autoSubmitDataBuffer, autoSubmitModelMat, autoSubmitPrimeMat, blendConfig, blendState, controlData, customData, globalTimer, hasDelete, isTimerPaused, layer, modelMatBuffer, modelMatrix, primeMatBuffer, primeMatrix, primeMatrixState, statePackageBuffer, sync_lock, timingWhenPaused -
Constructor Summary
ConstructorsConstructorDescriptionTextFieldEntity(boolean dynamicRefresh) TextFieldEntity(String fontPath) TextFieldEntity(String fontPath, boolean dynamicRefresh) TextFieldEntity(FontMapData map, boolean dynamicRefresh) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected intaddText(String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex) protected TextFieldEntity.TextDatacreateTextData(String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex) voidYou can directly call it when need display the text.static intFor anyone wanna made custom text rendering plugin.static voiddirectDrawDetachedEnd(int valueFromBeginReturns) voidintorg.lwjgl.util.vector.Vector4ffloat[]floatfloatfloatAfter calledsubmitText().floatAfter calledsubmitText().intintfloatfloatorg.lwjgl.util.vector.Vector4ffloatintfloat[]intfloatfloatintvoidglDraw()booleanprotected voidbooleanbooleanDefault value istrue.booleanbooleanDefault value isfalse.booleanisValid()booleanbytemallocTextData(int charNum) Optional.voidreplaceTextAtParagraph(String text, float padding, int fontMapIndex, int paragraphIndex) replaceTextAtParagraph(String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex, int paragraphIndex) replaceTextAtParagraph(String text, int fontMapIndex, int paragraphIndex) voidreset()Excludes text data.voidvoidsetAlignment(TextFieldEntity.Alignment alignment) voidsetBlendBloomColor(boolean blend) voidsetBloomColor(float r, float g, float b, float a) voidsetBloomColor(Color color) voidsetBloomColor(org.lwjgl.util.vector.Vector4f color) voidsetBloomColorStrength(float strength) voidvoidsetFieldHeight(float height) voidsetFieldSize(float width, float height) voidsetFieldWidth(float width) voidsetFontHeightSpace(float space) voidsetFontMap(String fontPath, byte index) Can use at most four maps.voidsetFontMap(FontMapData map) Apply for the first map.voidsetFontMap(FontMapData map, byte index) Can use at most four maps.voidsetFontSpace(float width, float height) voidsetFontWidthSpace(float space) voidsetGlobalColor(float r, float g, float b, float a) voidsetGlobalColor(Color color) voidsetGlobalColor(org.lwjgl.util.vector.Vector4f color) voidsetItalicFactor(float angle) voidsetItalicFactorDirect(float value) voidsetMappingModeSubmitData(boolean mappingMode) For some very slight data, useglBufferSubData()may faster.voidsetRefreshRenderingLengthWhenSubmit(boolean refresh) voidsetShouldRenderingCharCount(int charNum) voidvoidsetSynchronousSubmit(boolean sync) High performance impact when is synchronized.voidvoidsetTextDataRefreshIndex(int index) voidsetTextDataRefreshSize(int size) voidWithout matrix data or timer settings.byteCost26 Byteof vRAM each character, that if it had32768characters will cost832 KiBof vRAM.Methods inherited from class org.boxutil.base.BaseRenderData
advanceGlobalTimer, appendToEntity, appendToEntity, appendToEntity, appendToEntity, delete, getBlendAlphaDST, getBlendAlphaSRC, getBlendColorDST, getBlendColorSRC, getBlendEquation, getBlendState, getCampaignLayer, getCombatLayer, getControlData, getCustomData, getGlobalTimer, getGlobalTimerAlpha, getGlobalTimerState, getLayer, getModelMatrix, getModelMatrixBuffer, getPrimeMatrix, getPrimeMatrixBuffer, getPrimeMatrixState, hasDelete, initIdentityModelMatrix, initIdentityPrimeMatrix, isAutoSubmitEntityData, isAutoSubmitModelMatrix, isAutoSubmitPrimeMatrix, isGlobalTimerOnce, isGlobalTimerOver, isTimerPaused, isTimingWhenPaused, pickDataPackage_vec4, pickModelMatrixPackage_mat4, pickPrimeMatrixPackage_mat4, setAdditiveBlend, setAutoSubmitEntityData, setAutoSubmitModelMatrix, setAutoSubmitPrimeMatrix, setBlendEquation, setBlendFunc, setBlendFuncSeparate, setControlData, setCustomData, setCustomPrimeMatrix, setDefaultCampaignLayer, setDefaultCombatLayer, setDisableBlend, setFacingScale, setGlobalTimer, setGlobalTimerOnce, setLayer, setLocation, setLocation, setLocation, setLocation, setModelMatrix, setNegativeBlend, setNonePrimeMatrix, setNormalBlend, setPerspectivePrimeMatrix, setPrimeMatrix, setRotateScale, setStateVanilla, setStateVanilla, setTimerPaused, setTimingWhenPaused, setVanillaPrimeMatrix, submitModelMatrix, submitPrimeMatrix
-
Field Details
-
RESERVED_SYMBOL
public static final char RESERVED_SYMBOL- See Also:
-
LINE_FEED_SYMBOL
public static final char LINE_FEED_SYMBOL- See Also:
-
NOT_FOUND_SYMBOL
public static final char NOT_FOUND_SYMBOL- See Also:
-
_DEFAULT_PAD
protected static final byte _DEFAULT_PAD- See Also:
-
_VBO_SHORT_COUNT
protected static final byte _VBO_SHORT_COUNT- See Also:
-
_MAX_FONT_MAP
protected static final byte _MAX_FONT_MAP- See Also:
-
_textFieldID
protected final int _textFieldID -
_textFieldVBO
protected final int _textFieldVBO -
_isValid
protected volatile boolean _isValid -
fontMapList
-
textDataRefreshState
protected final int[] textDataRefreshState -
textStateAfterSubmit
protected final float[] textStateAfterSubmit -
_lastTextDataList
-
_lastTextDataState
-
_submitFeedback
-
state
protected final float[] state -
stateB
protected final boolean[] stateB -
alignment
-
bindTextureBuf
-
-
Constructor Details
-
TextFieldEntity
public TextFieldEntity(boolean dynamicRefresh) -
TextFieldEntity
public TextFieldEntity() -
TextFieldEntity
-
TextFieldEntity
-
TextFieldEntity
-
TextFieldEntity
-
-
Method Details
-
_StatePackageStack
protected int _StatePackageStack()- Overrides:
_StatePackageStackin classBaseRenderData
-
initResourceLayout
protected void initResourceLayout() -
getFontFieldID
public int getFontFieldID() -
getFontFieldVBO
public int getFontFieldVBO() -
isValid
public boolean isValid() -
getFontMapArray
-
setFontMap
Apply for the first map.- Parameters:
map- all the font height (or font size) should be near or equal.
-
setFontMap
Can use at most four maps.- Parameters:
map- all the font height (or font size) should be near or equal.
-
setFontMap
Can use at most four maps.- Parameters:
fontPath- all the font height (or font size) should be near or equal.
-
_deleteExc
protected void _deleteExc()- Overrides:
_deleteExcin classBaseRenderData
-
putShaderTextures
public void putShaderTextures() -
glDraw
public void glDraw()- Specified by:
glDrawin interfaceRenderDataAPI- Overrides:
glDrawin classBaseRenderData
-
directDraw
public void directDraw()You can directly call it when need display the text.And must call
BaseRenderData.delete()if unneeded. -
directDrawDetachedBegin
public static int directDrawDetachedBegin()For anyone wanna made custom text rendering plugin.- Returns:
- send to
directDrawDetachedEnd(int)
-
directDrawDetachedProcess
public void directDrawDetachedProcess() -
directDrawDetachedEnd
public static void directDrawDetachedEnd(int valueFromBeginReturns) -
_resetExc
protected void _resetExc()- Overrides:
_resetExcin classBaseRenderData
-
reset
public void reset()Excludes text data.- Specified by:
resetin interfaceRenderDataAPI- Overrides:
resetin classBaseRenderData
-
resetText
public void resetText() -
createTextData
protected TextFieldEntity.TextData createTextData(String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex) -
addText
public TextFieldEntity.TextData addText(String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex) - Parameters:
padding- offset when line feed.
-
addText
- Parameters:
padding- offset when line feed.
-
addText
-
addText
-
replaceTextAtParagraph
public TextFieldEntity.TextData replaceTextAtParagraph(@NotNull String text, float padding, Color color, boolean invert, boolean italic, boolean underline, boolean strikeout, int fontMapIndex, int paragraphIndex) - Parameters:
padding- offset when line feed.- Returns:
- the text data previously at the specified position.
-
replaceTextAtParagraph
public TextFieldEntity.TextData replaceTextAtParagraph(@NotNull String text, float padding, int fontMapIndex, int paragraphIndex) - Parameters:
padding- offset when line feed.- Returns:
- the text data previously at the specified position.
-
replaceTextAtParagraph
public TextFieldEntity.TextData replaceTextAtParagraph(@NotNull String text, int fontMapIndex, int paragraphIndex) - Returns:
- the text data previously at the specified position.
-
submitText
public byte submitText()Cost26 Byteof vRAM each character, that if it had32768characters will cost832 KiBof vRAM.If insufficient space exists on allocated buffer space, will lose data what the text data is not include in current submit.
- Returns:
- return
BoxEnum.STATE_SUCCESSwhen success.return
BoxEnum.STATE_FAILEDwhen an empty text data list or refresh count is zero.return
BoxEnum.STATE_FAILED_OTHERwhen happened another error.
-
mallocTextData
public byte mallocTextData(int charNum) Optional.Just
malloc()without any submit call.- Parameters:
charNum- must be positive integer.- Returns:
- return
BoxEnum.STATE_SUCCESSwhen success.return
BoxEnum.STATE_FAILEDwhen parameter error.return
BoxEnum.STATE_FAILED_OTHERwhen happened another error.
-
getSubmitFeedback
-
setSubmitFeedback
-
isRefreshRenderingLengthWhenSubmit
public boolean isRefreshRenderingLengthWhenSubmit() -
setRefreshRenderingLengthWhenSubmit
public void setRefreshRenderingLengthWhenSubmit(boolean refresh) -
isSynchronousSubmit
public boolean isSynchronousSubmit()Default value isfalse. -
setSynchronousSubmit
public void setSynchronousSubmit(boolean sync) High performance impact when is synchronized. -
isMappingModeSubmitData
public boolean isMappingModeSubmitData()Default value istrue. -
setMappingModeSubmitData
public void setMappingModeSubmitData(boolean mappingMode) For some very slight data, useglBufferSubData()may faster.Besides, some devices(some ARM SoC) may slower with
glMapBufferRange(), decided by the drive how implements it.- Parameters:
mappingMode- to controls whether submit useglMapBufferRange(), else useglBufferSubData().
-
getTextDataRefreshIndex
public int getTextDataRefreshIndex() -
setTextDataRefreshIndex
public void setTextDataRefreshIndex(int index) - Parameters:
index- Will refresh text data start from the index.
-
setTextDataRefreshSize
public void setTextDataRefreshSize(int size) - Parameters:
size- Will refresh text data count.
-
setTextDataRefreshAllFromCurrentIndex
public void setTextDataRefreshAllFromCurrentIndex() -
getTextDataList
-
getAllocatedValidCharLength
public int getAllocatedValidCharLength() -
haveAllocatedValidCharLength
public boolean haveAllocatedValidCharLength() -
getValidCharLength
public int getValidCharLength() -
isValidRenderingTextField
public boolean isValidRenderingTextField() -
setShouldRenderingCharCount
public void setShouldRenderingCharCount(int charNum) -
getAlignment
-
setAlignment
-
getFontWidthSpace
public float getFontWidthSpace() -
getFontHeightSpace
public float getFontHeightSpace() -
getTextFieldWidth
public float getTextFieldWidth() -
getTextFieldHeight
public float getTextFieldHeight() -
setFontWidthSpace
public void setFontWidthSpace(float space) - Parameters:
space- interval to previous font.
-
setFontHeightSpace
public void setFontHeightSpace(float space) - Parameters:
space- line interval to previous line of same(only) text data.
-
setFontSpace
public void setFontSpace(float width, float height) -
setFieldWidth
public void setFieldWidth(float width) -
setFieldHeight
public void setFieldHeight(float height) -
setFieldSize
public void setFieldSize(float width, float height) -
getCurrentVisualWidth
public float getCurrentVisualWidth()After calledsubmitText().But only counts for last submit call, not for the entity.
-
getCurrentVisualHeight
public float getCurrentVisualHeight()After calledsubmitText(). -
getCurrentItalicFactor
public float getCurrentItalicFactor() -
setItalicFactor
public void setItalicFactor(float angle) - Parameters:
angle- range at [-90, 90].
-
setItalicFactorDirect
public void setItalicFactorDirect(float value) - Parameters:
value- value of sin, and angle range at [-90, 90].
-
setDefaultItalicFactor
public void setDefaultItalicFactor() -
getGlobalColorArray
public float[] getGlobalColorArray() -
getGlobalColorC
-
getGlobalColor
public org.lwjgl.util.vector.Vector4f getGlobalColor() -
getGlobalColorAlpha
public float getGlobalColorAlpha() -
getGlobalColorAlphaI
public int getGlobalColorAlphaI() -
setGlobalColor
public void setGlobalColor(float r, float g, float b, float a) -
setGlobalColor
public void setGlobalColor(org.lwjgl.util.vector.Vector4f color) -
setGlobalColor
-
getBloomColorArray
public float[] getBloomColorArray() -
getBloomColorC
-
getBloomColor
public org.lwjgl.util.vector.Vector4f getBloomColor() -
getBloomStrength
public float getBloomStrength() -
setBloomColor
public void setBloomColor(float r, float g, float b, float a) - Parameters:
a- bloom strength
-
setBloomColor
public void setBloomColor(org.lwjgl.util.vector.Vector4f color) -
setBloomColor
-
setBloomColorStrength
public void setBloomColorStrength(float strength) -
isBlendBloomColor
public boolean isBlendBloomColor() -
setBlendBloomColor
public void setBlendBloomColor(boolean blend) - Parameters:
blend- the bloom color is bloom color blend in font color whentrue, use bloom color whenfalse.
-
submitEntityData
public void submitEntityData()Description copied from class:BaseRenderDataWithout matrix data or timer settings.- Specified by:
submitEntityDatain interfaceRenderDataAPI- Overrides:
submitEntityDatain classBaseRenderData
-
entityType
- Specified by:
entityTypein interfaceRenderDataAPI- Overrides:
entityTypein classBaseRenderData
-