OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 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 single triangle with | |
6 // a minimal vertex/fragment shader. The purpose of this | |
7 // example is to demonstrate the basic concepts of | |
8 // OpenGL ES 2.0 rendering. | |
9 | |
10 #include "gpu/demos/app_framework/application.h" | |
11 #include "third_party/gles_book_examples/Chapter_2/Hello_Triangle/Hello_Triangle
.h" | |
12 | |
13 namespace gpu_demos { | |
14 class HelloTriangle : public Application { | |
15 public: | |
16 HelloTriangle(); | |
17 ~HelloTriangle(); | |
18 | |
19 bool Init(); | |
20 | |
21 protected: | |
22 virtual void Draw(); | |
23 | |
24 private: | |
25 ESContext context_; | |
26 HTUserData user_data_; | |
27 }; | |
28 | |
29 HelloTriangle::HelloTriangle() { | |
30 esInitContext(&context_); | |
31 | |
32 memset(&user_data_, 0, sizeof(HTUserData)); | |
33 context_.userData = &user_data_; | |
34 } | |
35 | |
36 HelloTriangle::~HelloTriangle() { | |
37 htShutDown(&context_); | |
38 } | |
39 | |
40 bool HelloTriangle::Init() { | |
41 if (!Application::InitRenderContext()) return false; | |
42 | |
43 context_.width = width(); | |
44 context_.height = height(); | |
45 if (!htInit(&context_)) return false; | |
46 | |
47 return true; | |
48 } | |
49 | |
50 void HelloTriangle::Draw() { | |
51 htDraw(&context_); | |
52 } | |
53 } // namespace gpu_demos | |
54 | |
55 int main(int argc, char *argv[]) { | |
56 gpu_demos::HelloTriangle app; | |
57 if (!app.Init()) { | |
58 printf("Could not init.\n"); | |
59 return EXIT_FAILURE; | |
60 } | |
61 | |
62 app.MainLoop(); | |
63 return EXIT_SUCCESS; | |
64 } | |
OLD | NEW |