diff --git a/example/perspective2/main.go b/example/perspective2/main.go new file mode 100644 index 000000000..310e1ca4b --- /dev/null +++ b/example/perspective2/main.go @@ -0,0 +1,63 @@ +/* +Copyright 2014 Hajime Hoshi + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "github.com/hajimehoshi/ebiten" + "github.com/hajimehoshi/ebiten/ebitenutil" + _ "image/jpeg" + "log" +) + +const ( + screenWidth = 320 + screenHeight = 240 +) + +type Game struct { + gophersTexture *ebiten.Texture + textRenderTarget *ebiten.RenderTarget +} + +func (g *Game) Update(gr ebiten.GraphicsContext) error { + gr.PushRenderTarget(g.textRenderTarget) + gr.Fill(0x80, 0x40, 0x40) + ebitenutil.DebugPrint(gr, "Hello, World!") + gr.PopRenderTarget() + + gr.Fill(0x40, 0x40, 0x80) + geo := ebiten.GeometryMatrixI() + clr := ebiten.ColorMatrixI() + ebiten.DrawWholeTexture(gr, g.textRenderTarget.Texture(), geo, clr) + return nil +} + +func main() { + g := new(Game) + var err error + g.gophersTexture, _, err = ebitenutil.NewTextureFromFile("images/gophers.jpg", ebiten.FilterNearest) + if err != nil { + log.Fatal(err) + } + g.textRenderTarget, err = ebiten.NewRenderTarget(screenWidth, screenHeight, ebiten.FilterNearest) + if err != nil { + log.Fatal(err) + } + if err := ebiten.Run(g.Update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil { + log.Fatal(err) + } +} diff --git a/internal/opengl/internal/shader/shader.go b/internal/opengl/internal/shader/shader.go index f5a63e3ac..fde890a87 100644 --- a/internal/opengl/internal/shader/shader.go +++ b/internal/opengl/internal/shader/shader.go @@ -54,18 +54,6 @@ void main(void) { vertex_out_tex_coord1 = (modelview_matrix_n * vec4(tex_coord1, 0, 1)).xy; gl_Position = projection_matrix * modelview_matrix * vec4(vertex, 0, 1); } -`, - }, - // TODO: Now this shader is not used - shaderFragment: { - shaderType: gl.FRAGMENT_SHADER, - source: ` -uniform sampler2D texture; -varying vec2 vertex_out_tex_coord0; - -void main(void) { - gl_FragColor = texture2D(texture, vertex_out_tex_coord0); -} `, }, shaderColorMatrix: { @@ -86,17 +74,6 @@ void main(void) { gl_FragColor.a = color0.a + color1.a - color0.a * color1.a; gl_FragColor.rgb = (color0.a * color0.rgb + (1.0 - color0.a) * color1.a * color1.rgb) / gl_FragColor.a; } -`, - }, - // TODO: Now this shader is not used - shaderSolidColor: { - shaderType: gl.FRAGMENT_SHADER, - source: ` -uniform vec4 color; - -void main(void) { - gl_FragColor = color; -} `, }, }