OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file implements a standalone executable demo of using GLES2 over | 5 // This file implements a standalone executable demo of using GLES2 over |
6 // command buffers. This code is temporary as the setup that happens | 6 // command buffers. This code is temporary as the setup that happens |
7 // here is in a state of flux. Eventually there will be several versions of | 7 // here is in a state of flux. Eventually there will be several versions of |
8 // setup, one for trusted code, one for pepper, one for NaCl, and maybe others. | 8 // setup, one for trusted code, one for pepper, one for NaCl, and maybe others. |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
58 InitializeGLBindings(gfx::kGLImplementationEGLGLES2); | 58 InitializeGLBindings(gfx::kGLImplementationEGLGLES2); |
59 #else | 59 #else |
60 InitializeGLBindings(gfx::kGLImplementationDesktopGL); | 60 InitializeGLBindings(gfx::kGLImplementationDesktopGL); |
61 #endif | 61 #endif |
62 | 62 |
63 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); | 63 scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); |
64 if (!command_buffer->Initialize(size)) | 64 if (!command_buffer->Initialize(size)) |
65 return NULL; | 65 return NULL; |
66 | 66 |
67 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup()); | 67 gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true)); |
68 GpuScheduler* gpu_scheduler = GpuScheduler::Create(command_buffer.get(), | 68 GpuScheduler* gpu_scheduler = GpuScheduler::Create(command_buffer.get(), |
69 NULL, | 69 NULL, |
70 group.get()); | 70 group.get()); |
71 if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), | 71 if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), |
72 gfx::Size(), | 72 gfx::Size(), |
73 false, | 73 false, |
74 gpu::gles2::DisallowedExtensions(), | 74 gpu::gles2::DisallowedExtensions(), |
75 NULL, | 75 NULL, |
76 std::vector<int32>(), | 76 std::vector<int32>(), |
77 NULL)) { | 77 NULL)) { |
(...skipping 16 matching lines...) Expand all Loading... |
94 command_buffer->GetTransferBuffer(transfer_buffer_id); | 94 command_buffer->GetTransferBuffer(transfer_buffer_id); |
95 if (!transfer_buffer.ptr) | 95 if (!transfer_buffer.ptr) |
96 return false; | 96 return false; |
97 | 97 |
98 | 98 |
99 gles2::Initialize(); | 99 gles2::Initialize(); |
100 gles2::SetGLContext(new GLES2Implementation(helper, | 100 gles2::SetGLContext(new GLES2Implementation(helper, |
101 transfer_buffer.size, | 101 transfer_buffer.size, |
102 transfer_buffer.ptr, | 102 transfer_buffer.ptr, |
103 transfer_buffer_id, | 103 transfer_buffer_id, |
104 false)); | 104 false, |
| 105 true)); |
105 | 106 |
106 GLFromCPPInit(); | 107 GLFromCPPInit(); |
107 | 108 |
108 return command_buffer.release() != NULL; | 109 return command_buffer.release() != NULL; |
109 } | 110 } |
110 | 111 |
111 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
112 LRESULT CALLBACK WindowProc( | 113 LRESULT CALLBACK WindowProc( |
113 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { | 114 HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { |
114 switch (msg) { | 115 switch (msg) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 ::fprintf(stdout, "Could not setup window.\n"); | 233 ::fprintf(stdout, "Could not setup window.\n"); |
233 return EXIT_FAILURE; | 234 return EXIT_FAILURE; |
234 } | 235 } |
235 | 236 |
236 demo->Setup(hwnd, kCommandBufferSize); | 237 demo->Setup(hwnd, kCommandBufferSize); |
237 | 238 |
238 ProcessMessages(hwnd); | 239 ProcessMessages(hwnd); |
239 | 240 |
240 return EXIT_SUCCESS; | 241 return EXIT_SUCCESS; |
241 } | 242 } |
OLD | NEW |