MCPcopy Create free account
hub / github.com/android/ndk-samples / OnStartGraphics

Method OnStartGraphics

endless-tunnel/app/src/main/cpp/play_scene.cpp:230–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void PlayScene::OnStartGraphics() {
231 // build shaders
232 mOurShader = new OurShader();
233 mOurShader->Compile();
234 mTrivialShader = new TrivialShader();
235 mTrivialShader->Compile();
236
237 // build projection matrix
238 UpdateProjectionMatrix();
239
240 // build tunnel geometry
241 mTunnelGeom = new SimpleGeom(
242 new VertexBuf(TUNNEL_GEOM, sizeof(TUNNEL_GEOM), TUNNEL_GEOM_STRIDE),
243 new IndexBuf(TUNNEL_GEOM_INDICES, sizeof(TUNNEL_GEOM_INDICES)));
244 mTunnelGeom->vbuf->SetColorsOffset(TUNNEL_GEOM_COLOR_OFFSET);
245 mTunnelGeom->vbuf->SetTexCoordsOffset(TUNNEL_GEOM_TEXCOORD_OFFSET);
246
247 // build cube geometry (to draw obstacles)
248 mCubeGeom = new SimpleGeom(
249 new VertexBuf(CUBE_GEOM, sizeof(CUBE_GEOM), CUBE_GEOM_STRIDE));
250 mCubeGeom->vbuf->SetColorsOffset(CUBE_GEOM_COLOR_OFFSET);
251 mCubeGeom->vbuf->SetTexCoordsOffset(CUBE_GEOM_TEXCOORD_OFFSET);
252
253 // make the wall texture
254 mWallTexture = new Texture();
255 mWallTexture->InitFromRawRGB(WALL_TEXTURE_SIZE, WALL_TEXTURE_SIZE, false,
256 _gen_wall_texture());
257
258 // reset frame clock so the animation doesn't jump
259 mFrameClock.Reset();
260
261 // life icon geometry
262 mLifeGeom = AsciiArtToGeom(ART_LIFE, LIFE_ICON_SCALE);
263
264 // create text renderer and shape renderer
265 mTextRenderer = new TextRenderer(mTrivialShader);
266 mShapeRenderer = new ShapeRenderer(mTrivialShader);
267}
268
269void PlayScene::OnKillGraphics() {
270 CleanUp(&mTextRenderer);

Callers

nothing calls this directly

Calls 7

_gen_wall_textureFunction · 0.85
AsciiArtToGeomFunction · 0.85
SetColorsOffsetMethod · 0.80
SetTexCoordsOffsetMethod · 0.80
InitFromRawRGBMethod · 0.80
CompileMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected