Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: gpu/demos/simple_vertex_shader/main.cc

Issue 543015: Added simple vertex shader demo.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShad er.h"
12
13 namespace gpu_demos {
14 class SimpleVertexShader : public Application {
15 public:
16 SimpleVertexShader();
17 ~SimpleVertexShader();
18
19 bool Init();
20
21 protected:
22 virtual void Draw();
23
24 private:
25 ESContext context_;
26 SVSUserData user_data_;
27
28 DISALLOW_COPY_AND_ASSIGN(SimpleVertexShader);
29 };
30
31 SimpleVertexShader::SimpleVertexShader() {
32 esInitContext(&context_);
33
34 memset(&user_data_, 0, sizeof(SVSUserData));
35 context_.userData = &user_data_;
36 }
37
38 SimpleVertexShader::~SimpleVertexShader() {
39 svsShutDown(&context_);
40 }
41
42 bool SimpleVertexShader::Init() {
43 if (!Application::InitRenderContext()) return false;
44
45 context_.width = width();
46 context_.height = height();
47 if (!svsInit(&context_)) return false;
48 svsUpdate(&context_, 0.0f);
49
50 return true;
51 }
52
53 void SimpleVertexShader::Draw() {
54 svsDraw(&context_);
55 }
56 } // namespace gpu_demos
57
58 int main(int argc, char *argv[]) {
59 gpu_demos::SimpleVertexShader app;
60 if (!app.Init()) {
61 printf("Could not init.\n");
62 return EXIT_FAILURE;
63 }
64
65 app.MainLoop();
66 return EXIT_SUCCESS;
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698