blob: f27b129c4f90fc74c0fb55febc6d37ca238223bd [file] [log] [blame]
daniel@transgaming.com621ce052012-10-31 17:52:29 +00001//
2// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Renderer.h: Defines a back-end specific class that hides the details of the
8// implementation-specific renderer.
9
10#ifndef LIBGLESV2_RENDERER_RENDERER_H_
11#define LIBGLESV2_RENDERER_RENDERER_H_
12
13#include "common/angleutils.h"
14#define GL_APICALL
15#include <GLES2/gl2.h>
16#include <GLES2/gl2ext.h>
17#define EGLAPI
18#include <EGL/egl.h>
19
20#include <d3d9.h> // D3D9_REPLACE
21
22const int versionWindowsVista = MAKEWORD(0x00, 0x06);
23const int versionWindows7 = MAKEWORD(0x01, 0x06);
24
25// Return the version of the operating system in a format suitable for ordering
26// comparison.
27inline int getComparableOSVersion()
28{
29 DWORD version = GetVersion();
30 int majorVersion = LOBYTE(LOWORD(version));
31 int minorVersion = HIBYTE(LOWORD(version));
32 return MAKEWORD(minorVersion, majorVersion);
33}
34
35namespace renderer
36{
37
38class Renderer
39{
40 public:
41 Renderer(HMODULE hModule, HDC hDc);
42 virtual ~Renderer();
43
44 virtual EGLint initialize();
45 virtual bool resetDevice();
46
47 virtual void startScene();
48 virtual void endScene();
49
50#if 0
51 // resource creation
52 virtual void *createVertexShader(const DWORD *function, size_t length);
53 virtual void *createPixelShader(const DWORD *function, size_t length);
54 virtual void *createTexture2D();
55 virtual void *createTextureCube();
56 virtual void *createQuery();;
57 virtual void *createIndexBuffer();
58 virtual void *createVertexbuffer();
59
60 // state setup
61 virtual void applyTexture();
62 virtual void applyShaders();
63 virtual void applyConstants();
64 virtual void applyRenderTargets();
65 virtual void applyState();
66#endif
67
68 // lost device
69 virtual void markDeviceLost();
70 virtual bool isDeviceLost();
71 virtual bool testDeviceLost();
72 virtual bool testDeviceResettable();
73
74 // Renderer capabilities
75 virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE
76 virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier() {return &mAdapterIdentifier;}; // D3D9_REPLACE
77 virtual D3DCAPS9 getDeviceCaps() {return mDeviceCaps;}; // D3D9_REMOVE
78 virtual IDirect3D9 *getD3D() {return mD3d9;}; // D3D9_REMOVE
79 virtual UINT getAdapter() {return mAdapter;}; // D3D9_REMOVE
80 virtual D3DDEVTYPE getDeviceType() {return mDeviceType;}; // D3D9_REMOVE
81 virtual bool isD3d9ExDevice() const { return mD3d9Ex != NULL; } // D3D9_REMOVE
82
83 virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
84 virtual bool getDXT1TextureSupport();
85 virtual bool getDXT3TextureSupport();
86 virtual bool getDXT5TextureSupport();
87 virtual bool getEventQuerySupport();
88 virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
89 virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
90 virtual bool getLuminanceTextureSupport();
91 virtual bool getLuminanceAlphaTextureSupport();
92 virtual bool getVertexTextureSupport() const;
93 virtual bool getNonPower2TextureSupport() const;
94 virtual bool getDepthTextureSupport() const;
95 virtual bool getOcclusionQuerySupport() const;
96 virtual bool getInstancingSupport() const;
97 virtual float getTextureFilterAnisotropySupport() const;
daniel@transgaming.com313e3922012-10-31 17:52:39 +000098 virtual bool getShareHandleSupport() const;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000099
100 virtual D3DPOOL getBufferPool(DWORD usage) const;
101 virtual D3DPOOL getTexturePool(DWORD usage) const;
102
103 private:
104 DISALLOW_COPY_AND_ASSIGN(Renderer);
105
106 const HDC mDc;
107 HMODULE mD3d9Module;
108
109 void initializeDevice();
110 D3DPRESENT_PARAMETERS getDefaultPresentParameters();
111
112 UINT mAdapter;
113 D3DDEVTYPE mDeviceType;
114 IDirect3D9 *mD3d9; // Always valid after successful initialization.
115 IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported.
116 IDirect3DDevice9 *mDevice;
117 IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
118
119 HWND mDeviceWindow;
120
121 bool mDeviceLost;
122 D3DCAPS9 mDeviceCaps;
123 D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
124
125 bool mSceneStarted;
126 bool mSupportsNonPower2Textures;
127};
128
129}
130#endif // LIBGLESV2_RENDERER_RENDERER_H_