blob: 0030656a8a6fedd13610031070a5abc7a90b65e1 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
twiz@google.com59a190b2011-03-14 21:23:01 +00002 Copyright 2011 Google Inc.
reed@google.comac10a2d2010-12-22 21:39:39 +00003
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#include "GrTypes.h"
19
20// must be before GrGLConfig.h
21#if GR_WIN32_BUILD
22// #include "GrGpuD3D9.h"
23#endif
24
25#include "GrGLConfig.h"
26
twiz@google.comb65e0cb2011-03-18 20:41:44 +000027#include "GrGpuGLFixed.h"
28#include "GrGpuGLShaders2.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000029
30#include "GrGpu.h"
31
32GrGpu* GrGpu::Create(Engine engine, Platform3DContext context3D) {
twiz@google.com59a190b2011-03-14 21:23:01 +000033 // If no GL bindings have been installed, fall-back to calling the
34 // GL functions that have been linked with the executable.
35 if (!GrGLGetGLInterface())
36 GrGLSetDefaultGLInterface();
37
reed@google.comac10a2d2010-12-22 21:39:39 +000038 GrGpu* gpu = NULL;
39
40 switch (engine) {
41 case kOpenGL_Shaders_Engine:
42 GrAssert(NULL == context3D);
reed@google.comac10a2d2010-12-22 21:39:39 +000043 gpu = new GrGpuGLShaders2;
reed@google.comac10a2d2010-12-22 21:39:39 +000044 break;
45 case kOpenGL_Fixed_Engine:
46 GrAssert(NULL == context3D);
reed@google.comac10a2d2010-12-22 21:39:39 +000047 gpu = new GrGpuGLFixed;
reed@google.comac10a2d2010-12-22 21:39:39 +000048 break;
49 case kDirect3D9_Engine:
50 GrAssert(NULL != context3D);
51#if GR_WIN32_BUILD
52// gpu = new GrGpuD3D9((IDirect3DDevice9*)context3D);
53#endif
54 break;
55 default:
56 GrAssert(!"unknown engine");
57 break;
58 }
59
60 return gpu;
61}