mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
Hide some functions of RenderTarget
This commit is contained in:
parent
1b6bc12ead
commit
96c53234e5
@ -64,6 +64,12 @@ func CreateFromTexture(native NativeTexture, width, height int) *RenderTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RenderTarget) setAsViewport() {
|
func (r *RenderTarget) setAsViewport() {
|
||||||
|
current := C.GLint(0)
|
||||||
|
C.glGetIntegerv(C.GL_FRAMEBUFFER_BINDING, ¤t)
|
||||||
|
if C.GLuint(current) == r.framebuffer {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
C.glFlush()
|
C.glFlush()
|
||||||
|
|
||||||
C.glBindFramebuffer(C.GL_FRAMEBUFFER, C.GLuint(r.framebuffer))
|
C.glBindFramebuffer(C.GL_FRAMEBUFFER, C.GLuint(r.framebuffer))
|
||||||
@ -80,16 +86,7 @@ func (r *RenderTarget) setAsViewport() {
|
|||||||
C.glViewport(0, 0, C.GLsizei(width), C.GLsizei(height))
|
C.glViewport(0, 0, C.GLsizei(width), C.GLsizei(height))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RenderTarget) SetAsViewport() {
|
func (r *RenderTarget) projectionMatrix() [4][4]float64 {
|
||||||
current := C.GLint(0)
|
|
||||||
C.glGetIntegerv(C.GL_FRAMEBUFFER_BINDING, ¤t)
|
|
||||||
if C.GLuint(current) == r.framebuffer {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.setAsViewport()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RenderTarget) ProjectionMatrix() [4][4]float64 {
|
|
||||||
width := graphics.AdjustSizeForTexture(r.width)
|
width := graphics.AdjustSizeForTexture(r.width)
|
||||||
height := graphics.AdjustSizeForTexture(r.height)
|
height := graphics.AdjustSizeForTexture(r.height)
|
||||||
matrix := graphics.OrthoProjectionMatrix(0, width, 0, height)
|
matrix := graphics.OrthoProjectionMatrix(0, width, 0, height)
|
||||||
@ -106,7 +103,7 @@ func (r *RenderTarget) Dispose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RenderTarget) Fill(red, green, blue uint8) {
|
func (r *RenderTarget) Fill(red, green, blue uint8) {
|
||||||
r.SetAsViewport()
|
r.setAsViewport()
|
||||||
const max = float64(math.MaxUint8)
|
const max = float64(math.MaxUint8)
|
||||||
C.glClearColor(
|
C.glClearColor(
|
||||||
C.GLclampf(float64(red)/max),
|
C.GLclampf(float64(red)/max),
|
||||||
@ -118,15 +115,15 @@ func (r *RenderTarget) Fill(red, green, blue uint8) {
|
|||||||
|
|
||||||
func (r *RenderTarget) DrawTexture(texture Texture,
|
func (r *RenderTarget) DrawTexture(texture Texture,
|
||||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||||
r.SetAsViewport()
|
r.setAsViewport()
|
||||||
projectionMatrix := r.ProjectionMatrix()
|
projectionMatrix := r.projectionMatrix()
|
||||||
texture.Draw(projectionMatrix, geometryMatrix, colorMatrix)
|
texture.Draw(projectionMatrix, geometryMatrix, colorMatrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RenderTarget) DrawTextureParts(texture Texture,
|
func (r *RenderTarget) DrawTextureParts(texture Texture,
|
||||||
parts []graphics.TexturePart,
|
parts []graphics.TexturePart,
|
||||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||||
r.SetAsViewport()
|
r.setAsViewport()
|
||||||
projectionMatrix := r.ProjectionMatrix()
|
projectionMatrix := r.projectionMatrix()
|
||||||
texture.DrawParts(parts, projectionMatrix, geometryMatrix, colorMatrix)
|
texture.DrawParts(parts, projectionMatrix, geometryMatrix, colorMatrix)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user