| 1 | // Copyright 2014 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build darwin || linux || windows |
| 6 | |
| 7 | // An app that draws a green triangle on a red background. |
| 8 | // |
| 9 | // In order to build this program as an Android APK, using the gomobile tool. |
| 10 | // |
| 11 | // See http://godoc.org/golang.org/x/mobile/cmd/gomobile to install gomobile. |
| 12 | // |
| 13 | // Get the basic example and use gomobile to build or install it on your device. |
| 14 | // |
| 15 | // $ go get -d golang.org/x/mobile/example/basic |
| 16 | // $ gomobile build golang.org/x/mobile/example/basic # will build an APK |
| 17 | // |
| 18 | // # plug your Android device to your computer or start an Android emulator. |
| 19 | // # if you have adb installed on your machine, use gomobile install to |
| 20 | // # build and deploy the APK to an Android target. |
| 21 | // $ gomobile install golang.org/x/mobile/example/basic |
| 22 | // |
| 23 | // Switch to your device or emulator to start the Basic application from |
| 24 | // the launcher. |
| 25 | // You can also run the application on your desktop by running the command |
| 26 | // below. (Note: It currently doesn't work on Windows.) |
| 27 | // |
| 28 | // $ go install golang.org/x/mobile/example/basic && basic |
| 29 | package mainscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/ |
| 30 | |
| 31 | import ( |
| 32 | "encoding/binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/" |
| 33 | "logscip-go gomod github.com/golang/go/src go1.24.0 log/" |
| 34 | |
| 35 | "golang.org/x/mobile/appscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/" |
| 36 | "golang.org/x/mobile/event/lifecyclescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/" |
| 37 | "golang.org/x/mobile/event/paintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/" |
| 38 | "golang.org/x/mobile/event/sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/" |
| 39 | "golang.org/x/mobile/event/touchscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/" |
| 40 | "golang.org/x/mobile/exp/app/debugscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/" |
| 41 | "golang.org/x/mobile/exp/f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/" |
| 42 | "golang.org/x/mobile/exp/gl/glutilscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/" |
| 43 | "golang.org/x/mobile/glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/" |
| 44 | ) |
| 45 | |
| 46 | var ( |
| 47 | imagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/images. *glutilscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/.Imagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/Images# |
| 48 | fpsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fps. *debugscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/.FPSscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/FPS# |
| 49 | programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program. glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Program# |
| 50 | positionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/position. glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Attribscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Attrib# |
| 51 | offsetscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/offset. glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Uniformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Uniform# |
| 52 | colorscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/color. glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Uniformscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Uniform# |
| 53 | bufscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/buf. glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Bufferscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Buffer# |
| 54 | |
| 55 | greenscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/green. float32 |
| 56 | touchXscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchX. float32 |
| 57 | touchYscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchY. float32 |
| 58 | ) |
| 59 | |
| 60 | func mainscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/main().() { |
| 61 | appscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/.Mainscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/Main().(func(a appscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/.Appscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#) { |
| 62 | var glctx glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Contextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context# |
| 63 | var sz sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event# |
| 64 | for e := range a.Eventsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#Events.() { |
| 65 | switch e := a.Filterscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#Filter.(e).(type) { |
| 66 | case lifecyclescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/Event#: |
| 67 | switch e.Crossesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/Event#Crosses().(lifecyclescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/.StageVisiblescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/StageVisible.) { |
| 68 | case lifecyclescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/.CrossOnscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/CrossOn.: |
| 69 | glctx, _ = e.DrawContextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/Event#DrawContext..(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Contextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#) |
| 70 | onStartscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onStart().(glctx) |
| 71 | a.Sendscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#Send.(paintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/Event#{}) |
| 72 | case lifecyclescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/.CrossOffscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/lifecycle`/CrossOff.: |
| 73 | onStopscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onStop().(glctx) |
| 74 | glctx = nil |
| 75 | } |
| 76 | case sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#: |
| 77 | sz = e |
| 78 | touchXscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchX. = float32(sz.WidthPxscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#WidthPx. / 2) |
| 79 | touchYscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchY. = float32(sz.HeightPxscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#HeightPx. / 2) |
| 80 | case paintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/Event#: |
| 81 | if glctx == nil || e.Externalscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/Event#External. { |
| 82 | // As we are actively painting as fast as |
| 83 | // we can (usually 60 FPS), skip any paint |
| 84 | // events sent by the system. |
| 85 | continue |
| 86 | } |
| 87 | |
| 88 | onPaintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onPaint().(glctx, sz) |
| 89 | a.Publishscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#Publish.() |
| 90 | // Drive the animation by preparing to paint the next frame |
| 91 | // after this one is shown. |
| 92 | a.Sendscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/app`/App#Send.(paintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/paint`/Event#{}) |
| 93 | case touchscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#: |
| 94 | touchXscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchX. = e.Xscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#X. |
| 95 | touchYscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchY. = e.Yscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#Y. |
| 96 | } |
| 97 | } |
| 98 | }) |
| 99 | } |
| 100 | |
| 101 | func onStartscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onStart().(glctx glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Contextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#) { |
| 102 | var err error |
| 103 | programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program., err = glutilscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/.CreateProgramscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/CreateProgram().(glctx, vertexShaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/vertexShader., fragmentShaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fragmentShader.) |
| 104 | if err != nil { |
| 105 | logscip-go gomod github.com/golang/go/src go1.24.0 log/.Printfscip-go gomod github.com/golang/go/src go1.24.0 log/Printf().("error creating GL program: %v", err) |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | bufscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/buf. = glctx.CreateBufferscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#CreateBuffer.() |
| 110 | glctx.BindBufferscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#BindBuffer.(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.ARRAY_BUFFERscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/ARRAY_BUFFER., bufscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/buf.) |
| 111 | glctx.BufferDatascip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#BufferData.(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.ARRAY_BUFFERscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/ARRAY_BUFFER., triangleDatascip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/triangleData., glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.STATIC_DRAWscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/STATIC_DRAW.) |
| 112 | |
| 113 | positionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/position. = glctx.GetAttribLocationscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#GetAttribLocation.(programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program., "position") |
| 114 | colorscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/color. = glctx.GetUniformLocationscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#GetUniformLocation.(programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program., "color") |
| 115 | offsetscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/offset. = glctx.GetUniformLocationscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#GetUniformLocation.(programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program., "offset") |
| 116 | |
| 117 | imagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/images. = glutilscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/.NewImagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/NewImages().(glctx) |
| 118 | fpsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fps. = debugscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/.NewFPSscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/NewFPS().(imagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/images.) |
| 119 | } |
| 120 | |
| 121 | func onStopscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onStop().(glctx glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Contextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#) { |
| 122 | glctx.DeleteProgramscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#DeleteProgram.(programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program.) |
| 123 | glctx.DeleteBufferscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#DeleteBuffer.(bufscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/buf.) |
| 124 | fpsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fps..Releasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/FPS#Release().() |
| 125 | imagesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/images..Releasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/gl/glutil`/Images#Release().() |
| 126 | } |
| 127 | |
| 128 | func onPaintscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/onPaint().(glctx glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.Contextscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#, sz sizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/.Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#) { |
| 129 | glctx.ClearColorscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#ClearColor.(1, 0, 0, 1) |
| 130 | glctx.Clearscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#Clear.(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.COLOR_BUFFER_BITscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/COLOR_BUFFER_BIT.) |
| 131 | |
| 132 | glctx.UseProgramscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#UseProgram.(programscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/program.) |
| 133 | |
| 134 | greenscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/green. += 0.01 |
| 135 | if greenscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/green. > 1 { |
| 136 | greenscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/green. = 0 |
| 137 | } |
| 138 | glctx.Uniform4fscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#Uniform4f.(colorscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/color., 0, greenscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/green., 0, 1) |
| 139 | |
| 140 | glctx.Uniform2fscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#Uniform2f.(offsetscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/offset., touchXscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchX./float32(sz.WidthPxscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#WidthPx.), touchYscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/touchY./float32(sz.HeightPxscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/size`/Event#HeightPx.)) |
| 141 | |
| 142 | glctx.BindBufferscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#BindBuffer.(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.ARRAY_BUFFERscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/ARRAY_BUFFER., bufscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/buf.) |
| 143 | glctx.EnableVertexAttribArrayscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#EnableVertexAttribArray.(positionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/position.) |
| 144 | glctx.VertexAttribPointerscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#VertexAttribPointer.(positionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/position., coordsPerVertexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/coordsPerVertex., glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.FLOATscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/FLOAT., false, 0, 0) |
| 145 | glctx.DrawArraysscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#DrawArrays.(glscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/.TRIANGLESscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/TRIANGLES., 0, vertexCountscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/vertexCount.) |
| 146 | glctx.DisableVertexAttribArrayscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/gl`/Context#DisableVertexAttribArray.(positionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/position.) |
| 147 | |
| 148 | fpsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fps..Drawscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/app/debug`/FPS#Draw().(sz) |
| 149 | } |
| 150 | |
| 151 | var triangleDatascip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/triangleData. = f32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/.Bytesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/exp/f32`/Bytes().(binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., |
| 152 | 0.0, 0.4, 0.0, // top left |
| 153 | 0.0, 0.0, 0.0, // bottom left |
| 154 | 0.4, 0.0, 0.0, // bottom right |
| 155 | ) |
| 156 | |
| 157 | const ( |
| 158 | coordsPerVertexscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/coordsPerVertex. = 3 |
| 159 | vertexCountscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/vertexCount. = 3 |
| 160 | ) |
| 161 | |
| 162 | const vertexShaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/vertexShader. = `#version 100 |
| 163 | uniform vec2 offset; |
| 164 | |
| 165 | attribute vec4 position; |
| 166 | void main() { |
| 167 | // offset comes in with x/y values between 0 and 1. |
| 168 | // position bounds are -1 to 1. |
| 169 | vec4 offset4 = vec4(2.0*offset.x-1.0, 1.0-2.0*offset.y, 0, 0); |
| 170 | gl_Position = position + offset4; |
| 171 | }` |
| 172 | |
| 173 | const fragmentShaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/example/basic`/fragmentShader. = `#version 100 |
| 174 | precision mediump float; |
| 175 | uniform vec4 color; |
| 176 | void main() { |
| 177 | gl_FragColor = color; |
| 178 | }` |