|
OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This is a simple example that draws a quad with a 2D | |
6 // texture image. The purpose of this example is to demonstrate | |
7 // the basics of 2D texturing | |
8 | |
9 #include "gpu/demos/app_framework/application.h" | |
10 #include "third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h" | |
11 | |
12 namespace gpu_demos { | |
13 class SimpleTexture2D : public Application { | |
14 public: | |
15 SimpleTexture2D(); | |
16 ~SimpleTexture2D(); | |
17 | |
18 bool Init(); | |
19 | |
20 protected: | |
21 virtual void Draw(float); | |
apatrick
2010/01/14 19:07:54
The parameter should be named. Is it delta time? S
alokp
2010/01/14 20:07:29
This variable is not used for this demo. I did not
| |
22 | |
23 private: | |
24 ESContext context_; | |
25 STUserData user_data_; | |
26 | |
27 DISALLOW_COPY_AND_ASSIGN(SimpleTexture2D); | |
28 }; | |
29 | |
30 SimpleTexture2D::SimpleTexture2D() { | |
31 esInitContext(&context_); | |
32 | |
33 memset(&user_data_, 0, sizeof(STUserData)); | |
34 context_.userData = &user_data_; | |
35 } | |
36 | |
37 SimpleTexture2D::~SimpleTexture2D() { | |
38 stShutDown(&context_); | |
39 } | |
40 | |
41 bool SimpleTexture2D::Init() { | |
42 if (!Application::InitRenderContext()) return false; | |
43 | |
44 context_.width = width(); | |
45 context_.height = height(); | |
46 if (!stInit(&context_)) return false; | |
47 | |
48 return true; | |
49 } | |
50 | |
51 void SimpleTexture2D::Draw(float) { | |
apatrick
2010/01/14 19:07:54
Name parameter.
| |
52 stDraw(&context_); | |
53 } | |
54 } // namespace gpu_demos | |
55 | |
56 int main(int argc, char *argv[]) { | |
57 gpu_demos::SimpleTexture2D app; | |
58 if (!app.Init()) { | |
59 printf("Could not init.\n"); | |
60 return EXIT_FAILURE; | |
61 } | |
62 | |
63 app.MainLoop(); | |
64 return EXIT_SUCCESS; | |
65 } | |
OLD | NEW |