mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphics: Refactoring: Reduce array buffer size
This commit is contained in:
parent
ebac6cbb81
commit
deb2ab1cbf
@ -339,7 +339,6 @@ func (c *Context) NewBuffer(bufferType BufferType, v interface{}, bufferUsage Bu
|
||||
switch v := v.(type) {
|
||||
case int:
|
||||
gl.BufferInit(mgl.Enum(bufferType), v, mgl.Enum(bufferUsage))
|
||||
return Buffer(b)
|
||||
case []uint16:
|
||||
gl.BufferData(mgl.Enum(bufferType), uint16ToBytes(v), mgl.Enum(bufferUsage))
|
||||
default:
|
||||
|
@ -78,8 +78,7 @@ func (s *openGLState) initialize(c *opengl.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 16 [bytes] is an arbitrary number which seems enough to draw anything. Fix this if necessary.
|
||||
const stride = 16
|
||||
const stride = 8 // (2 [vertices] + 2 [texels]) * 2 [sizeof(int16)/bytes]
|
||||
c.NewBuffer(c.ArrayBuffer, 4*stride*MaxQuads, c.DynamicDraw)
|
||||
|
||||
indices := make([]uint16, 6*MaxQuads)
|
||||
|
@ -163,7 +163,8 @@ func Run(g GraphicsContext, width, height, scale int, title string, fps int) err
|
||||
|
||||
// Calc the current FPS.
|
||||
if time.Second <= time.Duration(n2-beforeForFPS) {
|
||||
currentRunContext.updateFPS(float64(frames) * float64(time.Second) / float64(n2-beforeForFPS))
|
||||
fps := float64(frames) * float64(time.Second) / float64(n2-beforeForFPS)
|
||||
currentRunContext.updateFPS(fps)
|
||||
beforeForFPS = n2
|
||||
frames = 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user