mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Compare commits
No commits in common. "435c8b75ebc001f3d1afda243bbe68ba3cfe38d1" and "b6ab7a10c1f57218499ced930a881ef1738af946" have entirely different histories.
435c8b75eb
...
b6ab7a10c1
@ -345,7 +345,7 @@ func (i *Image) ensureIsolatedFromSource(backends []*backend) {
|
|||||||
|
|
||||||
w, h := float32(i.width), float32(i.height)
|
w, h := float32(i.width), float32(i.height)
|
||||||
vs := make([]float32, 4*graphics.VertexFloatCount)
|
vs := make([]float32, 4*graphics.VertexFloatCount)
|
||||||
graphics.QuadVerticesFromDstAndSrc(vs, 0, 0, w, h, 0, 0, w, h, 1, 1, 1, 1)
|
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, i.width, i.height)
|
dr := image.Rect(0, 0, i.width, i.height)
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ func (i *Image) putOnSourceBackend() {
|
|||||||
|
|
||||||
w, h := float32(i.width), float32(i.height)
|
w, h := float32(i.width), float32(i.height)
|
||||||
vs := make([]float32, 4*graphics.VertexFloatCount)
|
vs := make([]float32, 4*graphics.VertexFloatCount)
|
||||||
graphics.QuadVerticesFromDstAndSrc(vs, 0, 0, w, h, 0, 0, w, h, 1, 1, 1, 1)
|
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, i.width, i.height)
|
dr := image.Rect(0, 0, i.width, i.height)
|
||||||
newI.drawTriangles([graphics.ShaderSrcImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderSrcImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
newI.drawTriangles([graphics.ShaderSrcImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderSrcImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
@ -52,7 +52,7 @@ func TestUnsyncedPixels(t *testing.T) {
|
|||||||
// Flush unsynced pixel cache.
|
// Flush unsynced pixel cache.
|
||||||
src := buffered.NewImage(16, 16, atlas.ImageTypeRegular)
|
src := buffered.NewImage(16, 16, atlas.ImageTypeRegular)
|
||||||
vs := make([]float32, 4*graphics.VertexFloatCount)
|
vs := make([]float32, 4*graphics.VertexFloatCount)
|
||||||
graphics.QuadVerticesFromDstAndSrc(vs, 0, 0, 16, 16, 0, 0, 16, 16, 1, 1, 1, 1)
|
graphics.QuadVerticesFromSrcAndMatrix(vs, 0, 0, 16, 16, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, 16, 16)
|
dr := image.Rect(0, 0, 16, 16)
|
||||||
sr := [graphics.ShaderSrcImageCount]image.Rectangle{image.Rect(0, 0, 16, 16)}
|
sr := [graphics.ShaderSrcImageCount]image.Rectangle{image.Rect(0, 0, 16, 16)}
|
||||||
|
@ -53,14 +53,14 @@ func (a *arrayBufferLayout) names() []string {
|
|||||||
return ns
|
return ns
|
||||||
}
|
}
|
||||||
|
|
||||||
// float32Count returns the total float32 count for one element of the array buffer.
|
// totalBytes returns the size in bytes for one element of the array buffer.
|
||||||
func (a *arrayBufferLayout) float32Count() int {
|
func (a *arrayBufferLayout) totalBytes() int {
|
||||||
if a.total != 0 {
|
if a.total != 0 {
|
||||||
return a.total
|
return a.total
|
||||||
}
|
}
|
||||||
t := 0
|
t := 0
|
||||||
for _, p := range a.parts {
|
for _, p := range a.parts {
|
||||||
t += p.num
|
t += floatSizeInBytes * p.num
|
||||||
}
|
}
|
||||||
a.total = t
|
a.total = t
|
||||||
return a.total
|
return a.total
|
||||||
@ -71,10 +71,10 @@ func (a *arrayBufferLayout) enable(context *context) {
|
|||||||
for i := range a.parts {
|
for i := range a.parts {
|
||||||
context.ctx.EnableVertexAttribArray(uint32(i))
|
context.ctx.EnableVertexAttribArray(uint32(i))
|
||||||
}
|
}
|
||||||
total := a.float32Count()
|
total := a.totalBytes()
|
||||||
offset := 0
|
offset := 0
|
||||||
for i, p := range a.parts {
|
for i, p := range a.parts {
|
||||||
context.ctx.VertexAttribPointer(uint32(i), int32(p.num), gl.FLOAT, false, int32(floatSizeInBytes*total), offset)
|
context.ctx.VertexAttribPointer(uint32(i), int32(p.num), gl.FLOAT, false, int32(total), offset)
|
||||||
offset += floatSizeInBytes * p.num
|
offset += floatSizeInBytes * p.num
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,10 +88,7 @@ func (a *arrayBufferLayout) disable(context *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// theArrayBufferLayout is the array buffer layout for Ebitengine.
|
// theArrayBufferLayout is the array buffer layout for Ebitengine.
|
||||||
var theArrayBufferLayout arrayBufferLayout
|
var theArrayBufferLayout = arrayBufferLayout{
|
||||||
|
|
||||||
func init() {
|
|
||||||
theArrayBufferLayout = arrayBufferLayout{
|
|
||||||
// Note that GL_MAX_VERTEX_ATTRIBS is at least 16.
|
// Note that GL_MAX_VERTEX_ATTRIBS is at least 16.
|
||||||
parts: []arrayBufferLayoutPart{
|
parts: []arrayBufferLayoutPart{
|
||||||
{
|
{
|
||||||
@ -107,20 +104,12 @@ func init() {
|
|||||||
num: 4,
|
num: 4,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
n := theArrayBufferLayout.float32Count()
|
|
||||||
if n > graphics.VertexFloatCount {
|
func init() {
|
||||||
panic("opengl: the array buffer layout is too large")
|
vertexFloatCount := theArrayBufferLayout.totalBytes() / floatSizeInBytes
|
||||||
}
|
if graphics.VertexFloatCount != vertexFloatCount {
|
||||||
if n < graphics.VertexFloatCount {
|
panic(fmt.Sprintf("vertex float num must be %d but %d", graphics.VertexFloatCount, vertexFloatCount))
|
||||||
d := graphics.VertexFloatCount - n
|
|
||||||
if d > 4 {
|
|
||||||
panic("opengl: the array buffer layout is too small")
|
|
||||||
}
|
|
||||||
theArrayBufferLayout.parts = append(theArrayBufferLayout.parts, arrayBufferLayoutPart{
|
|
||||||
name: "A3",
|
|
||||||
num: d,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user