summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/common.gypi7
-rw-r--r--gpu/demos/demos.gyp244
-rw-r--r--gpu/demos/framework/platform.h25
-rw-r--r--gpu/demos/framework/window.cc143
-rw-r--r--gpu/demos/framework/window.h16
-rw-r--r--gpu/demos/framework/window_linux.cc24
-rw-r--r--gpu/demos/framework/window_mac.mm24
-rw-r--r--gpu/demos/framework/window_win.cc100
-rw-r--r--third_party/gles2_book/Common/Include/esUtil.h10
-rw-r--r--third_party/gles2_book/Common/Include/esUtil_win.h33
-rw-r--r--third_party/gles2_book/Common/Source/Win32/esUtil_TGA.c126
-rw-r--r--third_party/gles2_book/Common/Source/esUtil.c19
-rw-r--r--third_party/gles2_book/README.chromium7
-rw-r--r--third_party/gles2_book/gles2_book.gyp1
14 files changed, 342 insertions, 437 deletions
diff --git a/build/common.gypi b/build/common.gypi
index a100fa1..877679b 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -78,6 +78,10 @@
# Set to 1 to enable fast builds. It disables debug info for fastest
# compilation.
'fastbuild%': 0,
+
+ # Set to 1 compile with -fPIC cflag on linux. This is a must for shared
+ # libraries on linux x86-64 and arm.
+ 'linux_fpic%': 0,
},
# Define branding and buildtype on the basis of their settings within the
@@ -90,6 +94,7 @@
'chromeos%': '<(chromeos)',
'inside_chromium_build%': '<(inside_chromium_build)',
'fastbuild%': '<(fastbuild)',
+ 'linux_fpic%': '<(linux_fpic)',
# The release channel that this build targets. This is used to restrict
# channel-specific build options, like which installer packages to create.
@@ -187,8 +192,6 @@
# Enable TCMalloc.
'linux_use_tcmalloc%': 0,
- 'linux_fpic%': 0,
-
# Set to select the Title Case versions of strings in GRD files.
'use_titlecase_in_grd_files%': 0,
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp
index 10d3cba..d69ae75c 100644
--- a/gpu/demos/demos.gyp
+++ b/gpu/demos/demos.gyp
@@ -5,6 +5,18 @@
{
'variables': {
'chromium_code': 1,
+ 'conditions': [
+ # Pepper demos that are compiled as shared libraries need to be compiled
+ # with -fPIC flag. All static libraries that these demos depend on must
+ # also be compiled with -fPIC flag. Setting GYP_DEFINES="linux_fpic=1"
+ # compiles everything with -fPIC. Disable pepper demos on linux/x64
+ # unless linux_fpic is 1.
+ ['OS=="linux" and (target_arch=="x64" or target_arch=="arm") and linux_fpic!=1', {
+ 'enable_pepper_demos%': 0,
+ }, {
+ 'enable_pepper_demos%': 1,
+ }],
+ ],
},
'includes': [
'../../build/common.gypi',
@@ -30,16 +42,18 @@
'../gpu.gyp:command_buffer_client',
'../gpu.gyp:command_buffer_service',
],
- 'all_dependent_settings': {
- 'sources': [
- 'framework/main_exe.cc',
- ],
- },
'sources': [
- 'framework/platform.h',
'framework/window.cc',
'framework/window.h',
],
+ 'conditions': [
+ ['OS=="linux"', {'sources': ['framework/window_linux.cc']}],
+ ['OS=="mac"', {'sources': ['framework/window_mac.mm']}],
+ ['OS=="win"', {'sources': ['framework/window_win.cc']}],
+ ],
+ 'direct_dependent_settings': {
+ 'sources': ['framework/main_exe.cc'],
+ },
},
{
'target_name': 'gpu_demo_framework_pepper',
@@ -48,27 +62,37 @@
'gpu_demo_framework',
'../gpu.gyp:pgl',
],
- 'all_dependent_settings': {
- 'sources': [
- 'framework/main_pepper.cc',
- 'framework/plugin.def',
- 'framework/plugin.rc',
- ],
- 'run_as': {
- 'action': [
- '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)chrome<(EXECUTABLE_SUFFIX)',
- '--no-sandbox',
- '--internal-pepper',
- '--enable-gpu-plugin',
- '--load-plugin=$(TargetPath)',
- 'file://$(ProjectDir)pepper_gpu_demo.html',
- ],
- },
- },
'sources': [
'framework/plugin.cc',
'framework/plugin.h',
],
+ 'direct_dependent_settings': {
+ 'sources': [
+ 'framework/main_pepper.cc',
+ ],
+ 'conditions': [
+ ['OS=="win"', {
+ 'sources': [
+ 'framework/plugin.def',
+ 'framework/plugin.rc',
+ ],
+ 'run_as': {
+ 'action': [
+ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)chrome<(EXECUTABLE_SUFFIX)',
+ '--no-sandbox',
+ '--internal-pepper',
+ '--enable-gpu-plugin',
+ '--load-plugin=$(TargetPath)',
+ 'file://$(ProjectDir)pepper_gpu_demo.html',
+ ],
+ },
+ }],
+ ['OS=="linux"', {
+ # -gstabs, used in the official builds, causes an ICE. Remove it.
+ 'cflags!': ['-gstabs'],
+ }],
+ ],
+ },
},
{
'target_name': 'hello_triangle_exe',
@@ -83,18 +107,6 @@
],
},
{
- 'target_name': 'hello_triangle_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:hello_triangle',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/hello_triangle.cc',
- ],
- },
- {
'target_name': 'mip_map_2d_exe',
'type': 'executable',
'dependencies': [
@@ -107,18 +119,6 @@
],
},
{
- 'target_name': 'mip_map_2d_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:mip_map_2d',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/mip_map_2d.cc',
- ],
- },
- {
'target_name': 'simple_texture_2d_exe',
'type': 'executable',
'dependencies': [
@@ -131,18 +131,6 @@
],
},
{
- 'target_name': 'simple_texture_2d_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:simple_texture_2d',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/simple_texture_2d.cc',
- ],
- },
- {
'target_name': 'simple_texture_cubemap_exe',
'type': 'executable',
'dependencies': [
@@ -155,18 +143,6 @@
],
},
{
- 'target_name': 'simple_texture_cubemap_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:simple_texture_cubemap',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/simple_texture_cubemap.cc',
- ],
- },
- {
'target_name': 'simple_vertex_shader_exe',
'type': 'executable',
'dependencies': [
@@ -179,18 +155,6 @@
],
},
{
- 'target_name': 'simple_vertex_shader_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:simple_vertex_shader',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/simple_vertex_shader.cc',
- ],
- },
- {
'target_name': 'stencil_test_exe',
'type': 'executable',
'dependencies': [
@@ -203,18 +167,6 @@
],
},
{
- 'target_name': 'stencil_test_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:stencil_test',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/stencil_test.cc',
- ],
- },
- {
'target_name': 'texture_wrap_exe',
'type': 'executable',
'dependencies': [
@@ -226,19 +178,97 @@
'gles2_book/texture_wrap.cc',
],
},
- {
- 'target_name': 'texture_wrap_pepper',
- 'type': 'shared_library',
- 'dependencies': [
- 'gpu_demo_framework_pepper',
- '../../third_party/gles2_book/gles2_book.gyp:texture_wrap',
- ],
- 'sources': [
- 'gles2_book/example.h',
- 'gles2_book/texture_wrap.cc',
+ ],
+ 'conditions': [
+ ['enable_pepper_demos==1', {
+ 'targets': [
+ {
+ 'target_name': 'hello_triangle_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:hello_triangle',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/hello_triangle.cc',
+ ],
+ },
+ {
+ 'target_name': 'mip_map_2d_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:mip_map_2d',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/mip_map_2d.cc',
+ ],
+ },
+ {
+ 'target_name': 'simple_texture_2d_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:simple_texture_2d',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/simple_texture_2d.cc',
+ ],
+ },
+ {
+ 'target_name': 'simple_texture_cubemap_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:simple_texture_cubemap',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/simple_texture_cubemap.cc',
+ ],
+ },
+ {
+ 'target_name': 'simple_vertex_shader_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:simple_vertex_shader',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/simple_vertex_shader.cc',
+ ],
+ },
+ {
+ 'target_name': 'stencil_test_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:stencil_test',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/stencil_test.cc',
+ ],
+ },
+ {
+ 'target_name': 'texture_wrap_pepper',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'gpu_demo_framework_pepper',
+ '../../third_party/gles2_book/gles2_book.gyp:texture_wrap',
+ ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/texture_wrap.cc',
+ ],
+ },
],
- },
- ]
+ }],
+ ],
}
# Local Variables:
diff --git a/gpu/demos/framework/platform.h b/gpu/demos/framework/platform.h
deleted file mode 100644
index cd6c003..0000000
--- a/gpu/demos/framework/platform.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Platform-specific types and definitions for native widget handles.
-
-#ifndef GPU_DEMOS_FRAMEWORK_PLATFORM_H_
-#define GPU_DEMOS_FRAMEWORK_PLATFORM_H_
-
-#ifdef _WINDOWS
-#include <windows.h>
-#endif // _WINDOWS
-
-#include "build/build_config.h"
-
-namespace gpu {
-namespace demos {
-
-#if defined(OS_WIN)
-typedef HWND NativeWindowHandle;
-#endif // defined(OS_WIN)
-
-} // namespace demos
-} // namespace gpu
-#endif // GPU_DEMOS_FRAMEWORK_PLATFORM_H_
diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc
index 41538d5..d258792 100644
--- a/gpu/demos/framework/window.cc
+++ b/gpu/demos/framework/window.cc
@@ -8,6 +8,7 @@
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/gpu_processor.h"
+#include "gpu/demos/framework/demo.h"
#include "gpu/demos/framework/demo_factory.h"
using gpu::Buffer;
@@ -16,81 +17,39 @@ using gpu::GPUProcessor;
using gpu::gles2::GLES2CmdHelper;
using gpu::gles2::GLES2Implementation;
-// TODO(alokp): Make this class cross-platform. Investigate using SDL.
namespace {
const int32 kCommandBufferSize = 1024 * 1024;
const int32 kTransferBufferSize = 512 * 1024;
+} // namespace.
-LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg,
- WPARAM w_param, LPARAM l_param) {
- LRESULT result = 0;
- switch (msg) {
- case WM_CLOSE:
- ::DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- ::PostQuitMessage(0);
- break;
- case WM_ERASEBKGND:
- break;
- case WM_PAINT: {
- gpu::demos::Window* window = reinterpret_cast<gpu::demos::Window*>(
- GetWindowLongPtr(hwnd, GWL_USERDATA));
- if (window != NULL) window->OnPaint();
- ::ValidateRect(hwnd, NULL);
- break;
- }
- default:
- result = ::DefWindowProc(hwnd, msg, w_param, l_param);
- break;
- }
- return result;
+namespace gpu {
+namespace demos {
+
+Window::Window()
+ : window_handle_(NULL),
+ demo_(CreateDemo()) {
+}
+
+Window::~Window() {
}
-HWND CreateNativeWindow(const wchar_t* title, int width, int height,
- LONG_PTR user_data) {
- WNDCLASS wnd_class = {0};
- HINSTANCE instance = GetModuleHandle(NULL);
- wnd_class.style = CS_OWNDC;
- wnd_class.lpfnWndProc = WindowProc;
- wnd_class.hInstance = instance;
- wnd_class.hbrBackground =
- reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
- wnd_class.lpszClassName = L"gpu_demo";
- if (!RegisterClass(&wnd_class)) return NULL;
-
- DWORD wnd_style = WS_VISIBLE | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION;
- RECT wnd_rect;
- wnd_rect.left = 0;
- wnd_rect.top = 0;
- wnd_rect.right = width;
- wnd_rect.bottom = height;
- AdjustWindowRect(&wnd_rect, wnd_style, FALSE);
-
- HWND hwnd = CreateWindow(
- wnd_class.lpszClassName,
- title,
- wnd_style,
- 0,
- 0,
- wnd_rect.right - wnd_rect.left,
- wnd_rect.bottom - wnd_rect.top,
- NULL,
- NULL,
- instance,
- NULL);
- if (hwnd == NULL) return NULL;
-
- ShowWindow(hwnd, SW_SHOWNORMAL);
- // Set this to the GWL_USERDATA so that it is available to WindowProc.
- SetWindowLongPtr(hwnd, GWL_USERDATA, user_data);
-
- return hwnd;
+bool Window::Init(int width, int height) {
+ window_handle_ = CreateNativeWindow(demo_->Title(), width, height);
+ if (window_handle_ == NULL)
+ return false;
+ if (!CreateRenderContext(PluginWindow(window_handle_)))
+ return false;
+
+ demo_->InitWindowSize(width, height);
+ return demo_->InitGL();
}
-bool InitRenderContext(HWND hwnd) {
- CHECK(hwnd);
+void Window::OnPaint() {
+ demo_->Draw();
+ ::gles2::GetGLContext()->SwapBuffers();
+}
+bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) {
scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService);
if (!command_buffer->Initialize(kCommandBufferSize)) {
return false;
@@ -117,54 +76,14 @@ bool InitRenderContext(HWND hwnd) {
command_buffer->GetTransferBuffer(transfer_buffer_id);
if (transfer_buffer.ptr == NULL) return false;
- gles2::Initialize();
- gles2::SetGLContext(new GLES2Implementation(helper,
- transfer_buffer.size,
- transfer_buffer.ptr,
- transfer_buffer_id));
+ ::gles2::Initialize();
+ ::gles2::SetGLContext(new GLES2Implementation(helper,
+ transfer_buffer.size,
+ transfer_buffer.ptr,
+ transfer_buffer_id));
return command_buffer.release() != NULL;
}
-} // namespace.
-
-namespace gpu {
-namespace demos {
-
-Window::Window()
- : window_handle_(NULL),
- demo_(CreateDemo()) {
-}
-
-Window::~Window() {
-}
-
-bool Window::Init(int width, int height) {
- window_handle_ = CreateNativeWindow(demo_->Title(), width, height,
- reinterpret_cast<LONG_PTR>(this));
- if (window_handle_ == NULL) return false;
- if (!InitRenderContext(window_handle_)) return false;
-
- demo_->InitWindowSize(width, height);
- return demo_->InitGL();
-}
-
-void Window::MainLoop() {
- MSG msg;
- bool done = false;
- while (!done) {
- while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
- if (msg.message == WM_QUIT) done = true;
- ::TranslateMessage(&msg);
- ::DispatchMessage(&msg);
- }
- // Message queue is empty and application has not quit yet - keep painting.
- if (!done) ::UpdateWindow(window_handle_);
- }
-}
-
-void Window::OnPaint() {
- demo_->Draw();
- ::gles2::GetGLContext()->SwapBuffers();
-}
} // namespace demos
} // namespace gpu
+
diff --git a/gpu/demos/framework/window.h b/gpu/demos/framework/window.h
index dade945..a84ecf8 100644
--- a/gpu/demos/framework/window.h
+++ b/gpu/demos/framework/window.h
@@ -5,13 +5,14 @@
#ifndef GPU_DEMOS_FRAMEWORK_WINDOW_H_
#define GPU_DEMOS_FRAMEWORK_WINDOW_H_
+#include "app/gfx/native_widget_types.h"
#include "base/scoped_ptr.h"
-#include "gpu/demos/framework/demo.h"
-#include "gpu/demos/framework/platform.h"
namespace gpu {
namespace demos {
+class Demo;
+
// Acts as a framework for standalone demos. It creates a window and delegates
// all events to demo to perform rendering and other tasks.
class Window {
@@ -28,7 +29,15 @@ class Window {
void OnPaint();
private:
- NativeWindowHandle window_handle_;
+ // Creates and shows a native window with the given title and dimensions.
+ gfx::NativeWindow CreateNativeWindow(const wchar_t* title,
+ int width, int height);
+ // Converts native window handle to NPAPI plugin window handle.
+ gfx::PluginWindowHandle PluginWindow(gfx::NativeWindow hwnd);
+ // Creates an OpenGL ES 2.0 rendering context for the given window.
+ bool CreateRenderContext(gfx::PluginWindowHandle hwnd);
+
+ gfx::NativeWindow window_handle_;
scoped_ptr<Demo> demo_;
DISALLOW_COPY_AND_ASSIGN(Window);
@@ -37,3 +46,4 @@ class Window {
} // namespace demos
} // namespace gpu
#endif // GPU_DEMOS_FRAMEWORK_WINDOW_H_
+
diff --git a/gpu/demos/framework/window_linux.cc b/gpu/demos/framework/window_linux.cc
new file mode 100644
index 0000000..4f07a24
--- /dev/null
+++ b/gpu/demos/framework/window_linux.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/demos/framework/window.h"
+
+namespace gpu {
+namespace demos {
+
+void Window::MainLoop() {
+}
+
+gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
+ int width, int height) {
+ return NULL;
+}
+
+gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
+ return gfx::kNullPluginWindow;
+}
+
+} // namespace demos
+} // namespace gpu
+
diff --git a/gpu/demos/framework/window_mac.mm b/gpu/demos/framework/window_mac.mm
new file mode 100644
index 0000000..4f07a24
--- /dev/null
+++ b/gpu/demos/framework/window_mac.mm
@@ -0,0 +1,24 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/demos/framework/window.h"
+
+namespace gpu {
+namespace demos {
+
+void Window::MainLoop() {
+}
+
+gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
+ int width, int height) {
+ return NULL;
+}
+
+gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
+ return gfx::kNullPluginWindow;
+}
+
+} // namespace demos
+} // namespace gpu
+
diff --git a/gpu/demos/framework/window_win.cc b/gpu/demos/framework/window_win.cc
new file mode 100644
index 0000000..62b2771
--- /dev/null
+++ b/gpu/demos/framework/window_win.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/demos/framework/window.h"
+
+namespace {
+LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg,
+ WPARAM w_param, LPARAM l_param) {
+ LRESULT result = 0;
+ switch (msg) {
+ case WM_CLOSE:
+ ::DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ ::PostQuitMessage(0);
+ break;
+ case WM_ERASEBKGND:
+ break;
+ case WM_PAINT: {
+ gpu::demos::Window* window = reinterpret_cast<gpu::demos::Window*>(
+ GetWindowLongPtr(hwnd, GWL_USERDATA));
+ if (window != NULL) window->OnPaint();
+ ::ValidateRect(hwnd, NULL);
+ break;
+ }
+ default:
+ result = ::DefWindowProc(hwnd, msg, w_param, l_param);
+ break;
+ }
+ return result;
+}
+} // namespace.
+
+namespace gpu {
+namespace demos {
+
+void Window::MainLoop() {
+ // Set this to the GWL_USERDATA so that it is available to WindowProc.
+ SetWindowLongPtr(window_handle_, GWL_USERDATA,
+ reinterpret_cast<LONG_PTR>(this));
+
+ MSG msg;
+ bool done = false;
+ while (!done) {
+ while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (msg.message == WM_QUIT) done = true;
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+ // Message queue is empty and application has not quit yet - keep painting.
+ if (!done) ::UpdateWindow(window_handle_);
+ }
+}
+
+gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
+ int width, int height) {
+ WNDCLASS wnd_class = {0};
+ HINSTANCE instance = GetModuleHandle(NULL);
+ wnd_class.style = CS_OWNDC;
+ wnd_class.lpfnWndProc = WindowProc;
+ wnd_class.hInstance = instance;
+ wnd_class.hbrBackground =
+ reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
+ wnd_class.lpszClassName = L"gpu_demo";
+ if (!RegisterClass(&wnd_class)) return NULL;
+
+ DWORD wnd_style = WS_VISIBLE | WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION;
+ RECT wnd_rect;
+ wnd_rect.left = 0;
+ wnd_rect.top = 0;
+ wnd_rect.right = width;
+ wnd_rect.bottom = height;
+ AdjustWindowRect(&wnd_rect, wnd_style, FALSE);
+
+ HWND hwnd = CreateWindow(
+ wnd_class.lpszClassName,
+ title,
+ wnd_style,
+ 0,
+ 0,
+ wnd_rect.right - wnd_rect.left,
+ wnd_rect.bottom - wnd_rect.top,
+ NULL,
+ NULL,
+ instance,
+ NULL);
+ if (hwnd == NULL) return NULL;
+
+ ShowWindow(hwnd, SW_SHOWNORMAL);
+ return hwnd;
+}
+
+gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
+ return hwnd;
+}
+
+} // namespace demos
+} // namespace gpu
+
diff --git a/third_party/gles2_book/Common/Include/esUtil.h b/third_party/gles2_book/Common/Include/esUtil.h
index 9897e1b..d00ac8f 100644
--- a/third_party/gles2_book/Common/Include/esUtil.h
+++ b/third_party/gles2_book/Common/Include/esUtil.h
@@ -112,16 +112,6 @@ extern int esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
GLfloat **texCoords, GLushort **indices );
//
-/// \brief Loads a 24-bit TGA image from a file
-/// \param fileName Name of the file on disk
-/// \param width Width of loaded image in pixels
-/// \param height Height of loaded image in pixels
-/// \return Pointer to loaded image. NULL on failure.
-//
-extern char* esLoadTGA ( char *fileName, int *width, int *height );
-
-
-//
/// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result
/// \param result Specifies the input matrix. Scaled matrix is returned in result.
/// \param sx, sy, sz Scale factors along the x, y and z axes respectively
diff --git a/third_party/gles2_book/Common/Include/esUtil_win.h b/third_party/gles2_book/Common/Include/esUtil_win.h
deleted file mode 100644
index d7e4104..0000000
--- a/third_party/gles2_book/Common/Include/esUtil_win.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Book: OpenGL(R) ES 2.0 Programming Guide
-// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
-// ISBN-10: 0321502795
-// ISBN-13: 9780321502797
-// Publisher: Addison-Wesley Professional
-// URLs: http://safari.informit.com/9780321563835
-// http://www.opengles-book.com
-//
-
-// esUtil_win.h
-//
-// API-neutral interface for creating windows. Implementation needs to be provided per-platform.
-
-#ifndef ESUTIL_WIN_H
-#define ESUTIL_WIN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-///
-// WinTGALoad()
-//
-// TGA loader win32 implementation
-//
-int WinTGALoad ( const char *fileName, char **buffer, int *width, int *height );
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-
-#endif // ESUTIL_WIN_H
diff --git a/third_party/gles2_book/Common/Source/Win32/esUtil_TGA.c b/third_party/gles2_book/Common/Source/Win32/esUtil_TGA.c
deleted file mode 100644
index 86a1f320..0000000
--- a/third_party/gles2_book/Common/Source/Win32/esUtil_TGA.c
+++ /dev/null
@@ -1,126 +0,0 @@
-//
-// Book: OpenGL(R) ES 2.0 Programming Guide
-// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
-// ISBN-10: 0321502795
-// ISBN-13: 9780321502797
-// Publisher: Addison-Wesley Professional
-// URLs: http://safari.informit.com/9780321563835
-// http://www.opengles-book.com
-//
-
-// esUtil_TGA.c
-//
-// This file contains the Win32 implementation of a TGA image loader
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif // WIN32_LEAN_AND_MEAN
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-///
-// Macros
-//
-#define INVERTED_BIT (1 << 5)
-
-///
-// Types
-//
-#pragma pack(push,x1) // Byte alignment (8-bit)
-#pragma pack(1)
-
-typedef struct
-{
- unsigned char IdSize,
- MapType,
- ImageType;
- unsigned short PaletteStart,
- PaletteSize;
- unsigned char PaletteEntryDepth;
- unsigned short X,
- Y,
- Width,
- Height;
- unsigned char ColorDepth,
- Descriptor;
-
-} TGA_HEADER;
-
-#pragma pack(pop,x1)
-
-////////////////////////////////////////////////////////////////////////////////////
-//
-// Private Functions
-//
-
-////////////////////////////////////////////////////////////////////////////////////
-//
-// Public Functions
-//
-//
-
-
-///
-// WinTGALoad()
-//
-int WinTGALoad( const char *fileName, char **buffer, int *width, int *height )
-{
- FILE *fp;
- TGA_HEADER Header;
-
- if ( fopen_s ( &fp, fileName, "rb" ) != 0 )
- {
- return FALSE;
- }
-
- if ( fp == NULL )
- {
- return FALSE;
- }
-
- fread ( &Header, sizeof(TGA_HEADER), 1, fp );
-
- *width = Header.Width;
- *height = Header.Height;
-
- if ( Header.ColorDepth == 24 )
- {
- RGBTRIPLE *Buffer24;
-
- Buffer24= (RGBTRIPLE*)malloc(sizeof(RGBTRIPLE) * (*width) * (*height));
-
- if(Buffer24)
- {
- int i=0;
- int x,
- y;
-
- fread(Buffer24, sizeof(RGBTRIPLE), (*width) * (*height), fp);
-
- *buffer= (LPSTR) malloc(3 * (*width) * (*height));
-
- for ( y = 0; y < *height; y++ )
- for( x = 0; x < *width; x++ )
- {
- int Index= y * (*width) + x;
-
- if(!(Header.Descriptor & INVERTED_BIT))
- Index= ((*height) - 1 - y) * (*width) + x;
-
- (*buffer)[(i * 3)]= Buffer24[Index].rgbtRed;
- (*buffer)[(i * 3) + 1]= Buffer24[Index].rgbtGreen;
- (*buffer)[(i * 3) + 2]= Buffer24[Index].rgbtBlue;
-
- i++;
- }
-
- fclose(fp);
- free(Buffer24);
- return(TRUE);
- }
- }
-
- return(FALSE);
-}
diff --git a/third_party/gles2_book/Common/Source/esUtil.c b/third_party/gles2_book/Common/Source/esUtil.c
index 7a9c9c5..cb64a29 100644
--- a/third_party/gles2_book/Common/Source/esUtil.c
+++ b/third_party/gles2_book/Common/Source/esUtil.c
@@ -26,7 +26,6 @@
#include <GLES2/gl2.h>
#include "esUtil.h"
-#include "esUtil_win.h"
///
// esInitContext()
@@ -53,26 +52,10 @@ void esLogMessage ( const char *formatStr, ... )
char buf[BUFSIZ];
va_start ( params, formatStr );
- vsprintf_s ( buf, sizeof(buf), formatStr, params );
+ vsprintf ( buf, formatStr, params );
printf ( "%s", buf );
va_end ( params );
}
-///
-// esLoadTGA()
-//
-// Loads a 24-bit TGA image from a file
-//
-char* esLoadTGA ( char *fileName, int *width, int *height )
-{
- char *buffer;
-
- if ( WinTGALoad ( fileName, &buffer, width, height ) )
- {
- return buffer;
- }
-
- return NULL;
-}
diff --git a/third_party/gles2_book/README.chromium b/third_party/gles2_book/README.chromium
index 38aaad8..6f7858aa 100644
--- a/third_party/gles2_book/README.chromium
+++ b/third_party/gles2_book/README.chromium
@@ -18,6 +18,7 @@ Local Modifications:
- Common/Include/KD/*
- Common/Lib/*
- Common/Source/esUtil_win32.c
+ - Common/Source/Win32/esUtil_TGA.c
- Lib/*
- *.vcproj, *.sln
@@ -25,3 +26,9 @@ Local Modifications:
static libraries:
- Chapter_2/Hello_Triangle/Hello_Triangle.h
- Chapter_8/Simple_VertexShader/Simple_VertexShader.h
+ - Chapter_9/MipMap2D/MipMap2D.h
+ - Chapter_9/Simple_Texture2D/Simple_Texture2D.h
+ - Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h
+ - Chapter_9/TextureWrap/TextureWrap.h
+ - Chapter_11/Stencil_Test/Stencil_Test.h
+
diff --git a/third_party/gles2_book/gles2_book.gyp b/third_party/gles2_book/gles2_book.gyp
index 97b351f..6baff32 100644
--- a/third_party/gles2_book/gles2_book.gyp
+++ b/third_party/gles2_book/gles2_book.gyp
@@ -25,7 +25,6 @@
'Common/Source/esShapes.c',
'Common/Source/esTransform.c',
'Common/Source/esUtil.c',
- 'Common/Source/Win32/esUtil_TGA.c',
],
},
{