mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 00:47:26 -04:00
opengl: properly reset buffer for uploading
This commit is contained in:
parent
2c80c8047a
commit
bb23496b8b
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -81,8 +81,8 @@ class BitmapFontType(
|
|||||||
private fun load(file: ResourceLocation, height: Int, ascent: Int, chars: List<String>, context: RenderContext): BitmapFontType? {
|
private fun load(file: ResourceLocation, height: Int, ascent: Int, chars: List<String>, context: RenderContext): BitmapFontType? {
|
||||||
if (chars.isEmpty() || height <= 0) return null
|
if (chars.isEmpty() || height <= 0) return null
|
||||||
val texture = PNGTexture(file, 0)
|
val texture = PNGTexture(file, 0)
|
||||||
context.textures.font += texture
|
|
||||||
texture.load(context) // force load it, we need to calculate the width of every char
|
texture.load(context) // force load it, we need to calculate the width of every char
|
||||||
|
context.textures.font += texture // TODO: convert to font array size and remove empty lines
|
||||||
|
|
||||||
return load(texture, texture.size.y / chars.size, ascent, chars.codePoints())
|
return load(texture, texture.size.y / chars.size, ascent, chars.codePoints())
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,8 @@ class OpenGLFontTextureArray(
|
|||||||
for (texture in textures) {
|
for (texture in textures) {
|
||||||
val renderData = texture.renderData as OpenGLTextureData
|
val renderData = texture.renderData as OpenGLTextureData
|
||||||
val buffer = texture.data.buffer
|
val buffer = texture.data.buffer
|
||||||
buffer.data.flip()
|
buffer.data.position(0)
|
||||||
|
buffer.data.limit(buffer.data.capacity())
|
||||||
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, renderData.index, buffer.size.x, buffer.size.y, 1, buffer.glFormat, buffer.glType, buffer.data)
|
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, renderData.index, buffer.size.x, buffer.size.y, 1, buffer.glFormat, buffer.glType, buffer.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -86,7 +86,8 @@ interface BaseWindow {
|
|||||||
val decoder = PNGDecoder(assetsManager[SystemUtil.ICON])
|
val decoder = PNGDecoder(assetsManager[SystemUtil.ICON])
|
||||||
val data = BufferUtils.createByteBuffer(decoder.width * decoder.height * PNGDecoder.Format.RGBA.numComponents)
|
val data = BufferUtils.createByteBuffer(decoder.width * decoder.height * PNGDecoder.Format.RGBA.numComponents)
|
||||||
decoder.decode(data, decoder.width * PNGDecoder.Format.RGBA.numComponents, PNGDecoder.Format.RGBA)
|
decoder.decode(data, decoder.width * PNGDecoder.Format.RGBA.numComponents, PNGDecoder.Format.RGBA)
|
||||||
data.flip()
|
data.position(0)
|
||||||
|
data.limit(data.capacity())
|
||||||
setIcon(Vec2i(decoder.width, decoder.height), data)
|
setIcon(Vec2i(decoder.width, decoder.height), data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user