├── LICENSE.txt ├── README.md ├── app_directx.h ├── app_opengl.h ├── app_perf.cpp ├── app_perf.h ├── app_util.cpp ├── app_util.h ├── arial_12.bin ├── arial_12.tga ├── glew.c ├── glew.h ├── glext.h ├── glxew.h ├── main.cpp ├── nvToolsExt32_1.dll ├── nvToolsExt64_1.dll ├── state_view.vcproj ├── state_view.vcxproj ├── state_view.vcxproj.user ├── state_view_VS2008.sln ├── state_view_VS2010.sln ├── stateview.exe ├── stateview_slides.ppt ├── stdint.h └── wglew.h /LICENSE.txt: -------------------------------------------------------------------------------- 1 | STATEVIEWER 2 | NVIDIA Corporation (c) 2013 3 | =========================== 4 | 5 | Contact: Rama Hoetzlein, rhoetzlein@nvidia.com 6 | 7 | The StateViewer consists of two parts. 8 | 9 | The retracer for generating state tracking data is built into the 10 | apitrace tool and licensed under the apitrace license. Components 11 | of the stateviewer found in apitrace adopt that license: 12 | See https://github.com/apitrace/apitrace 13 | 14 | The StateViewer, a graphical interface used to visualize state trace 15 | data (.raw files), is licensed as follows: 16 | 17 | LICENSE 18 | 19 | 1. USAGE 20 | 21 | You are free to download, copy, compile, study, and refer to the 22 | source code for any personal or commercial use. Usage by you or your 23 | organization of any work covered by this license should not, directly 24 | or indirectly, enable its usage by other individuals or organisations 25 | outside your own. 26 | 27 | 2. MODIFICATION 28 | 29 | You are free to make any modifications to the source covered by this 30 | license. You are also free to compile the source after modifying it 31 | and use the compiled product obtained thereafter in compliance with 32 | this license. 33 | 34 | 3. REDISTRIBUTION 35 | 36 | You may NOT copy, redistribute and/or republish the source or a work 37 | based on it. Interested parties are invited to contribute their own 38 | modifications to the original github repository for the StateViewer, 39 | but are not required to submit modifications unless the intent is to 40 | redistribute. 41 | 42 | 4. NON-COMPLIANCE 43 | 44 | You may not copy, modify, sublicense, or distribute the program except 45 | as expressly provided under this license. Any attempt otherwise to copy, 46 | modify, sublicense or distribute the program is void, and will 47 | automatically terminate your rights under this license, including the 48 | rights to usage of the software. 49 | 50 | 5. DERIVATIVE WORKS 51 | 52 | NVIDIA retains the sole right to ammend, copy, modify, or reincorporate 53 | this work into future products, or to modify this work as the 54 | copyright holder. 55 | 56 | 6. DISCLAIMER 57 | 58 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS 59 | PROVIDED "AS IS" AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, 60 | EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED 61 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 62 | OR NONINFRINGEMENT. 63 | 64 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL 65 | EITHER PARTY OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 66 | INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT 67 | LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, 68 | LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT 69 | OF THE USE OF OR INABILITY TO USE THE FEEDBACK, EVEN IF THE OTHER PARTY 70 | HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 71 | 72 | 7. SUPPORT 73 | 74 | NVIDIA has no obligation to support or to provide any updates to this software. 75 | 76 | 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NVIDIA STATEVIEWER 2 | =================== 3 | NVIDIA (c) 2013 4 | 5 | Contact: Rama Hoetzlein, rhoetzlein@nvidia.com 6 | 7 | The StateViewer tracks state changes in DX11 and OpenGL graphics apps, 8 | using apitrace to initially capture and record traces to a .trace file. 9 | During retrace the state bins are tracked, and output to a .raw file 10 | which is visualized using the StateViewer. 11 | 12 | The StateViewer consists of two parts: 13 | 14 | 1) d3dretrace/glretrace - State tracing, now part of apitrace. (https://github.com/apitrace/apitrace) 15 | 2) StateViewer - This visualizer for viewing state trace data. 16 | 17 | For graphical examples and an overview of the technique, see the included PowerPoint: 18 | stateview_slides.ppt 19 | 20 | OVERVIEW 21 | ==================== 22 | - Install apitrace 23 | - Run apitrace to produce .trace file 24 | - Run the d3dretrace or glretrace with new -r and -o options (by Nvidia) to replay the trace 25 | with state tracking enabled for output to a .raw file 26 | - Run this StateViewer to visualize the state trace data from .raw files 27 | 28 | TRACING 29 | ==================== 30 | * Trace an application to produce a replayable .trace file 31 | 32 | Step 1. Start a command line, and modify path to specify 32 or 64-bit trace, 33 | depending on application to be traced. 34 | 35 | > path=%path%;c:\codes\stateview\x64\bin 36 | 37 | Step 2. Run application trace 38 | 39 | > apitrace64 trace -a dxgi -o demo.trace nvinstdemo.exe 40 | 41 | > apitrace86 trace -a gl -o demo.trace opengldemo.exe 42 | 43 | See apitrace website for additional trace options: http://apitrace.github.io/ 44 | 45 | 46 | RETRACING 47 | ===================== 48 | * Retrace the application with the new state tracking option (by Nvidia) 49 | 50 | Step 3. Retrace the application 51 | 52 | > d3dretrace demo.trace 53 | Normal usage of retrace. Just replays the trace file on the screen. 54 | Useful to confirm a good trace. 55 | 56 | > d3dretrace -r -o demo.raw demo.trace 57 | Perform state tracking in raw binary mode (-r), with output to demo.raw (-o) 58 | Due to the state track algorithm the replay will occur twice on the screen. 59 | 60 | > d3dretrace -t -o demo.txt demo.trace 61 | Perform state tracking in text mode (-t), to view detailed state information. 62 | This does the full state track algorithm, and outputs all tracked calls to txt file. 63 | 64 | > d3dretrace -r -f 10000 -o demo.raw demo.trace 65 | Perform state tracking, but start tracking after 10000th frame. 66 | Useful to reduce the size of .raw files. 67 | 68 | VISUALIZATION 69 | ====================== 70 | * Visualize the state tracking results 71 | 72 | Step 4. Run the StateViewer 73 | 74 | > stateview demo.raw 75 | Visualize all state data in the .raw file 76 | 77 | > stateview -d 5000 demo.raw 78 | Limit playback to 5000 draw calls. Useful when .raw file is large. 79 | 80 | > stateview -f 100 -d 5000 demo.raw 81 | Skip first 100 frames of visualization, and also limit playback to 5000 draw calls. 82 | 83 | 84 | BINS CURRENTLY TRACKED 85 | ====================== 86 | The StateViewier assigns all graphics API calls to a particular bin in order 87 | to track and compare values. The following bin names are used: 88 | * NA = not yet tracked 89 | 90 | 0 Shader 91 | 1 Render Target 92 | 2 Viewport 93 | 3 Rasterizer State 94 | 4 Depth State *NA* 95 | 5 Blend State *NA* 96 | 6 Sampler State *NA* 97 | 7 Input *NA* 98 | 8 Texture 99 | 9 Vertex Buffer (IA Slot 0) 100 | 10 Vertex Buffer (IA Slot 1) 101 | 11 Vertex Buffer (IA Slot 2) 102 | 12 Vertex Buffer (IA Slot 3) 103 | 13 Vertex Buffer (IA Slot 4) 104 | 14 VS Const Buffer 0 105 | 15 VS Const Buffer 1 106 | 16 VS Const Buffer 2 107 | 17 VS Const Buffer 3 108 | 18 VS Const Buffer 4 109 | 19 PS Const Buffer 0 110 | 20 PS Const Buffer 1 111 | 21 PS Const Buffer 2 112 | 22 PS Const Buffer 3 113 | 23 PS Const Buffer 4 114 | 24 Index Buffer 115 | 116 | 117 | FUNCTIONS CURRENTLY TRACKED 118 | =========================== 119 | This is the list of API functions currently tracked 120 | by the Nvidia StateViewer (c) 2013. 121 | It does not cover all the functions which apitrace supports, which is a 122 | much larger set. 123 | 124 | Updated 9/24/2013. 125 | 126 | OpenGL: 127 | memcpy 128 | wglSwapBuffers 129 | glDrawArrays 130 | glDrawElements 131 | glGenBuffers 132 | glBindBuffer 133 | glBufferData 134 | glCreateShader 135 | glCreateProgram 136 | glUseProgram 137 | glGenTextures 138 | glBindTexture 139 | glTexSubImage2D 140 | glGetUniformLocation 141 | glUniform1f/3f/4f 142 | glUniformMatrix4fv 143 | glShaderSource 144 | glVertexPointer 145 | glNormalPointer 146 | glLoadMatrixd 147 | glLoadMatrixf 148 | 149 | DX10/11: 150 | memcpy 151 | DXGISwapChain::Present 152 | D3D11Buffer:Map 153 | D3D11DeviceContext:Map 154 | D3D11Device:DrawIndexed 155 | D3D11Device:DrawInstanced 156 | D3D11Device:Draw 157 | D3D11Device:CreateBuffer 158 | D3D11Device:CreateRenderTargetView 159 | D3D11Device:OMSetRenderTargets 160 | D3D11Device:CreateRasterizerState 161 | D3D11Device:RSSetState 162 | D3D11Device:CreateVertexShader 163 | D3D11Device:CreatePixelShader 164 | D3D11Device:VSSetShader 165 | D3D11Device:PSSetShader 166 | D3D11Device:UpdateSubresource 167 | D3D11Device:IASetVertexBuffers 168 | D3D11Device:VSSetConstantBuffers 169 | D3D11Device:PSSetConstantBuffers 170 | 171 | 172 | BUILDING APITRACE 173 | ================== 174 | Building APITRACE is only needed if the goal is also to rebuild the StateViewer, 175 | or to add functionality to the StateViewer. 176 | 177 | INSTALL: 178 | 179 | 1. Requires VS 2010 64-bit Service Pack 1 180 | 181 | 2. Install cmake and Python 2.7.5 (do not install 2.7.3 or 3.3) 182 | * Make sure that later version of Python were not previously installed 183 | 184 | 3. Get apitrace: 185 | git clone git://github.com/apitrace/apitrace.git 186 | 187 | CMAKE BUILD: 188 | 189 | 4. Rename retrieved folder as: /apitrace_v5 190 | 191 | 5. Run VS 2010 Command Prompt - to get correct VC env variables 192 | 193 | 6. Include cmake-gui in path: path=%path%;c:\Program Files (x86)\CMake 2.8\bin 194 | 195 | 7. Run cmake-gui from command line (CMake 2.8): 196 | cmake-gui -H%cd% -B%cd%\build 197 | 198 | 8. Source path: c:/codes/apitrace_v5/ 199 | Build path: c:/codes/apitrace_v5/build 200 | Configure: VS 2010 64-bit 201 | 202 | 9. Confirm PYTHON_EXECUTABLE C:/Python27/python.exe (NOT /Python33 or other ver) 203 | 204 | 11. Click Configure. Click Generate. 205 | 206 | BUILD SOLUTION: 207 | 208 | 10. Build entire solution (34 projects). Rebuild again to resolve dependencies. 209 | 210 | 211 | 11. If you get this issue: 212 | Issue: Any .py file error which says 213 | print "..." ^ 214 | SyntaxError: invalid syntax. 215 | Resolve: You must use Python 2.7.5. Cannot use Python 3.x. 216 | Later version of pythong require () for print statements. 217 | http://stackoverflow.com/questions/12713648/python-3-3-0-syntax-err 218 | 12. Trace/retrace build to: \build\Release 219 | Injector builds to: \build\Release 220 | API wrappers build to: \build\wrappers\Release 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /app_directx.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | //#define PERF_HUD 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include // For PerfHUD adapter enumeration 15 | #pragma comment(lib, "dxgi.lib") 16 | 17 | #include 18 | #include 19 | 20 | extern void display (); 21 | extern void reshape (int, int); 22 | extern void keyboard_func (unsigned char, int, int); 23 | extern void mouse_click_func (int,int,int,int); 24 | extern void mouse_drag_func (int, int); 25 | extern void mouse_move_func (int, int); 26 | extern void idle_func (); 27 | extern char* initialize ( char* cmdline ); 28 | 29 | #define GLUT_UP 0 30 | #define GLUT_DOWN 1 31 | #define GLUT_LEFT_BUTTON 1 32 | #define GLUT_RIGHT_BUTTON 2 33 | 34 | float window_width = 1024; 35 | float window_height = 768; 36 | 37 | int mState; 38 | 39 | struct MatrixBuffer 40 | { 41 | float m[16]; 42 | }; 43 | typedef Vector4DF VectorBuffer; 44 | 45 | //------------------------------------------------------------------------------------ 46 | // Global Variables 47 | //-------------------------------------------------------------------------------------- 48 | HINSTANCE g_hInst = NULL; 49 | HWND g_hWnd = NULL; 50 | D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; 51 | D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; 52 | ID3D11Device* g_pDevice = NULL; 53 | ID3D11DeviceContext* g_pContext = NULL; 54 | IDXGISwapChain* g_pSwapChain = NULL; 55 | ID3D11RenderTargetView* g_pRenderTargetView = NULL; 56 | ID3D11Texture2D* g_pDepthStencil = NULL; 57 | ID3D11DepthStencilState* g_pDepthStencilState = NULL; 58 | ID3D11DepthStencilState* g_pDepthOffState = NULL; 59 | ID3D11DepthStencilView* g_pDepthStencilView = NULL; 60 | ID3D11RasterizerState* g_pRasterizerState; 61 | 62 | ID3D11Buffer* g_pMatrixBuffer[3]; 63 | 64 | FILE* m_OutCons = 0x0; 65 | 66 | //-------------------------------------------------------------------------------------- 67 | // Forward declarations 68 | //-------------------------------------------------------------------------------------- 69 | HRESULT InitWindow( HINSTANCE hInstance ); 70 | HRESULT InitDevice(); 71 | void CleanupDevice(); 72 | LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); 73 | 74 | static std::string utf16ToUTF8( const std::wstring &s ) 75 | { 76 | const int size = ::WideCharToMultiByte( CP_UTF8, 0, s.c_str(), -1, NULL, 0, 0, NULL ); 77 | std::vector buf( size ); 78 | ::WideCharToMultiByte( CP_UTF8, 0, s.c_str(), -1, &buf[0], size, 0, NULL ); 79 | return std::string( &buf[0] ); 80 | } 81 | 82 | void app_printf ( char* format, ... ) 83 | { 84 | // Note: This is the >only< way to do this. There is no general way to 85 | // pass on all the arguments from one ellipsis function to another. 86 | // The function vfprintf was specially designed to allow this. 87 | va_list argptr; 88 | va_start (argptr, format); 89 | vfprintf ( m_OutCons, format, argptr); 90 | va_end (argptr); 91 | fflush ( m_OutCons ); 92 | } 93 | 94 | bool checkHR (HRESULT hr) 95 | { 96 | if (SUCCEEDED(hr)) 97 | return true; 98 | 99 | // An error occured so find out what it was and output it to the output pane in Vis 100 | OutputDebugString("\nDirectX Error Reported:\n"); 101 | OutputDebugString(DXGetErrorString(hr)); 102 | OutputDebugString(" : "); 103 | OutputDebugString(DXGetErrorDescription(hr)); 104 | OutputDebugString("\n\n"); 105 | 106 | return false; 107 | } 108 | 109 | int checkSHADER ( HRESULT hr, ID3D10Blob* blob ) 110 | { 111 | if( FAILED( hr ) ) { 112 | if( blob != NULL ) { 113 | OutputDebugStringA( (CHAR*)blob->GetBufferPointer() ); 114 | blob->Release(); 115 | } 116 | } 117 | return hr; 118 | } 119 | 120 | 121 | //-------------------------------------------------------------------------------------- 122 | // Entry point to the program. Initializes everything and goes into a message processing 123 | // loop. Idle time is used to render the scene. 124 | //-------------------------------------------------------------------------------------- 125 | int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) 126 | { 127 | UNREFERENCED_PARAMETER( hPrevInstance ); 128 | UNREFERENCED_PARAMETER( lpCmdLine ); 129 | 130 | // Console window for printf 131 | AllocConsole (); 132 | long lStdHandle = (long) GetStdHandle( STD_OUTPUT_HANDLE ); 133 | int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); 134 | m_OutCons = _fdopen( hConHandle, "w" ); 135 | 136 | // Init window 137 | if( FAILED( InitWindow( hInstance ) ) ) return 0; 138 | 139 | // Init device 140 | if( FAILED( InitDevice() ) ) { CleanupDevice(); return 0; } 141 | 142 | // User init 143 | char* title = initialize ( lpCmdLine ); 144 | 145 | SetWindowText ( g_hWnd, title ); 146 | ShowWindow( g_hWnd, nCmdShow ); 147 | 148 | // Main message loop 149 | MSG msg = {0}; 150 | while( WM_QUIT != msg.message ) 151 | { 152 | display (); 153 | 154 | if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { 155 | TranslateMessage( &msg ); 156 | DispatchMessage( &msg ); 157 | } 158 | 159 | } 160 | 161 | CleanupDevice(); 162 | 163 | return ( int )msg.wParam; 164 | } 165 | 166 | //-------------------------------------------------------------------------------------- 167 | // Register class and create window 168 | //-------------------------------------------------------------------------------------- 169 | HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ) 170 | { 171 | const wchar_t *str = L"DirectX 11"; 172 | std::string utf8String = utf16ToUTF8( str ); 173 | LPSTR name = const_cast(utf8String.c_str()); 174 | 175 | const wchar_t *str2 = L"StateViewer (c) NVIDIA, by R.Hoetzlein - DIRECTX 11"; 176 | std::string utf8String2 = utf16ToUTF8( str2 ); 177 | LPSTR win_name = const_cast(utf8String2.c_str()); 178 | 179 | // Register class 180 | WNDCLASSEX wcex; 181 | wcex.cbSize = sizeof( WNDCLASSEX ); 182 | wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; 183 | wcex.lpfnWndProc = WndProc; 184 | wcex.cbClsExtra = 0; 185 | wcex.cbWndExtra = 0; 186 | wcex.hInstance = hInstance; 187 | wcex.hIcon = 0x0; 188 | wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); 189 | wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ); 190 | wcex.lpszMenuName = NULL; 191 | wcex.lpszClassName = name; 192 | wcex.hIconSm = 0x0; 193 | if( !RegisterClassEx( &wcex ) ) 194 | return E_FAIL; 195 | 196 | // Create window 197 | g_hInst = hInstance; 198 | RECT rc = { 0, 0, window_width, window_height }; 199 | AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); 200 | 201 | g_hWnd = CreateWindow( name, win_name, WS_OVERLAPPEDWINDOW, 202 | CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, 203 | NULL ); 204 | if( !g_hWnd ) 205 | return E_FAIL; 206 | 207 | return S_OK; 208 | } 209 | 210 | 211 | //-------------------------------------------------------------------------------------- 212 | // Called every time the application receives a message 213 | //-------------------------------------------------------------------------------------- 214 | LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) 215 | { 216 | PAINTSTRUCT ps; 217 | HDC hdc; 218 | 219 | switch( message ) 220 | { 221 | case WM_PAINT: 222 | hdc = BeginPaint( hWnd, &ps ); 223 | EndPaint( hWnd, &ps ); 224 | break; 225 | case WM_DESTROY: 226 | PostQuitMessage( 0 ); 227 | break; 228 | 229 | case WM_LBUTTONDOWN: { 230 | mState = GLUT_DOWN; 231 | mouse_click_func ( GLUT_LEFT_BUTTON, GLUT_DOWN, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 232 | } break; 233 | case WM_RBUTTONDOWN: { 234 | mState = GLUT_DOWN; 235 | mouse_click_func ( GLUT_RIGHT_BUTTON, GLUT_DOWN, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 236 | } break; 237 | case WM_LBUTTONUP: { 238 | mState = GLUT_UP; 239 | mouse_click_func ( GLUT_LEFT_BUTTON, GLUT_UP, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 240 | } break; 241 | case WM_RBUTTONUP: { 242 | mState = GLUT_UP; 243 | mouse_click_func ( GLUT_RIGHT_BUTTON, GLUT_UP, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 244 | } break; 245 | 246 | case WM_MOUSEMOVE: { 247 | int xpos = GET_X_LPARAM(lParam); 248 | int ypos = GET_Y_LPARAM(lParam); 249 | if ( mState == GLUT_DOWN ) mouse_drag_func ( xpos, ypos );// invoke GLUT-style mouse events 250 | else mouse_move_func ( xpos, ypos ); 251 | } break; 252 | 253 | case WM_KEYDOWN: { 254 | WPARAM param = wParam; 255 | char c = MapVirtualKey ( param, MAPVK_VK_TO_CHAR ); 256 | keyboard_func ( c, 0, 0 ); // invoke GLUT-style mouse events 257 | } break; 258 | 259 | default: 260 | return DefWindowProc( hWnd, message, wParam, lParam ); 261 | } 262 | 263 | return 0; 264 | } 265 | 266 | 267 | //-------------------------------------------------------------------------------------- 268 | // Create Direct3D device and swap chain 269 | //-------------------------------------------------------------------------------------- 270 | HRESULT InitDevice() 271 | { 272 | HRESULT hr = S_OK; 273 | 274 | RECT rc; 275 | GetClientRect( g_hWnd, &rc ); 276 | UINT width = rc.right - rc.left; 277 | UINT height = rc.bottom - rc.top; 278 | 279 | UINT createDeviceFlags = 0; 280 | #ifdef _DEBUG 281 | createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; 282 | #endif 283 | 284 | D3D_DRIVER_TYPE driverTypes[] = 285 | { 286 | D3D_DRIVER_TYPE_HARDWARE, 287 | D3D_DRIVER_TYPE_WARP, 288 | D3D_DRIVER_TYPE_REFERENCE 289 | }; 290 | UINT numDriverTypes = ARRAYSIZE( driverTypes ); 291 | 292 | D3D_FEATURE_LEVEL featureLevels[] = 293 | { 294 | D3D_FEATURE_LEVEL_11_0, 295 | D3D_FEATURE_LEVEL_10_1, 296 | D3D_FEATURE_LEVEL_10_0 297 | }; 298 | UINT numFeatureLevels = ARRAYSIZE( featureLevels ); 299 | 300 | DEVMODE devMode; 301 | if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode)) 302 | { 303 | MessageBoxA(NULL, "ERROR/n Failed enumerate display settings", "DX11Window::createD3DDevice", MB_OK|MB_SETFOREGROUND|MB_TOPMOST); 304 | return 0; 305 | } 306 | 307 | DXGI_SWAP_CHAIN_DESC sd; 308 | ZeroMemory( &sd, sizeof( sd ) ); 309 | sd.BufferCount = 1; 310 | sd.BufferDesc.Width = width; 311 | sd.BufferDesc.Height = height; 312 | sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; 313 | sd.BufferDesc.RefreshRate.Numerator = devMode.dmDisplayFrequency; 314 | sd.BufferDesc.RefreshRate.Denominator = 1; 315 | sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; 316 | sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; 317 | sd.OutputWindow = g_hWnd; 318 | sd.SampleDesc.Count = 1; 319 | sd.SampleDesc.Quality = 0; 320 | sd.Windowed = TRUE; 321 | 322 | IDXGIFactory* pDXGIFactory; 323 | HRESULT hRes; 324 | hRes = CreateDXGIFactory (__uuidof(IDXGIFactory), (void**) &pDXGIFactory); 325 | checkHR ( hRes ); 326 | 327 | // Search for a PerfHUD adapter. 328 | UINT nAdapter = 0; 329 | IDXGIAdapter* adapter = NULL; 330 | IDXGIAdapter* selectedAdapter = NULL; 331 | D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_HARDWARE; 332 | 333 | 334 | #ifdef PERF_HUD 335 | while (pDXGIFactory->EnumAdapters(nAdapter, &adapter) != DXGI_ERROR_NOT_FOUND) { 336 | if (adapter) { 337 | DXGI_ADAPTER_DESC adaptDesc; 338 | if (SUCCEEDED(adapter->GetDesc(&adaptDesc))) { 339 | const bool isPerfHUD = wcscmp(adaptDesc.Description, L"NVIDIA PerfHUD") == 0; 340 | // Select the first adapter in normal circumstances or the PerfHUD one if it exists. 341 | if (nAdapter == 0 || isPerfHUD) selectedAdapter = adapter; 342 | if (isPerfHUD) driverType = D3D_DRIVER_TYPE_REFERENCE; 343 | } 344 | } 345 | ++nAdapter; 346 | } 347 | hr = D3D11CreateDeviceAndSwapChain( selectedAdapter, driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, 348 | D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pDevice, &g_featureLevel, &g_pContext ); 349 | checkHR( hr ); 350 | #else 351 | for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) { 352 | g_driverType = driverTypes[driverTypeIndex]; 353 | hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, 354 | D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pDevice, &g_featureLevel, &g_pContext ); 355 | if( SUCCEEDED( hr ) ) break; 356 | } 357 | #endif 358 | if( FAILED( hr ) ) return hr; 359 | 360 | // Create a render target view 361 | ID3D11Texture2D* pBackBuffer = NULL; 362 | hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); 363 | if( FAILED( hr ) ) 364 | return hr; 365 | 366 | hr = g_pDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); 367 | pBackBuffer->Release(); 368 | if( FAILED( hr ) ) 369 | return hr; 370 | 371 | g_pContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL ); 372 | 373 | // Create depth stencil texture 374 | D3D11_TEXTURE2D_DESC descDepth; 375 | ZeroMemory( &descDepth, sizeof(descDepth) ); 376 | descDepth.Width = width; 377 | descDepth.Height = height; 378 | descDepth.MipLevels = 1; 379 | descDepth.ArraySize = 1; 380 | descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; 381 | descDepth.SampleDesc.Count = 1; 382 | descDepth.SampleDesc.Quality = 0; 383 | descDepth.Usage = D3D11_USAGE_DEFAULT; 384 | descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; 385 | descDepth.CPUAccessFlags = 0; 386 | descDepth.MiscFlags = 0; 387 | checkHR( g_pDevice->CreateTexture2D( &descDepth, NULL, &g_pDepthStencil ) ); 388 | 389 | // Create the depth stencil view 390 | D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; 391 | ZeroMemory( &descDSV, sizeof(descDSV) ); 392 | descDSV.Format = descDepth.Format; 393 | descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; 394 | descDSV.Texture2D.MipSlice = 0; 395 | checkHR( g_pDevice->CreateDepthStencilView( g_pDepthStencil, &descDSV, &g_pDepthStencilView ) ); 396 | D3D11_DEPTH_STENCIL_DESC dsDesc; 397 | 398 | // Depth test parameters 399 | dsDesc.DepthEnable = true; 400 | dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; 401 | dsDesc.DepthFunc = D3D11_COMPARISON_LESS; 402 | dsDesc.StencilEnable = true; 403 | dsDesc.StencilReadMask = 0xFF; 404 | dsDesc.StencilWriteMask = 0xFF; 405 | dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; 406 | dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; 407 | dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; 408 | dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; 409 | dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; 410 | dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; 411 | dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; 412 | dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; 413 | checkHR( g_pDevice->CreateDepthStencilState (&dsDesc, &g_pDepthStencilState) ); 414 | 415 | // Depth test parameters - OFF mode 416 | dsDesc.DepthEnable = false; 417 | dsDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; 418 | dsDesc.DepthFunc = D3D11_COMPARISON_LESS; 419 | dsDesc.StencilEnable = true; 420 | dsDesc.StencilReadMask = 0xFF; 421 | dsDesc.StencilWriteMask = 0xFF; 422 | dsDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; 423 | dsDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; 424 | dsDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; 425 | dsDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; 426 | dsDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; 427 | dsDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; 428 | dsDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; 429 | dsDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; 430 | checkHR( g_pDevice->CreateDepthStencilState (&dsDesc, &g_pDepthOffState) ); 431 | 432 | g_pContext->OMSetDepthStencilState( g_pDepthStencilState, 1 ); 433 | 434 | g_pContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView ); 435 | 436 | // Setup the raster description which will determine how and what polygons will be drawn. 437 | D3D11_RASTERIZER_DESC rasterDesc; 438 | ZeroMemory( &rasterDesc, sizeof(rasterDesc) ); 439 | rasterDesc.AntialiasedLineEnable = false; 440 | rasterDesc.CullMode = D3D11_CULL_NONE; 441 | rasterDesc.DepthBias = 0; 442 | rasterDesc.DepthBiasClamp = 0.0f; 443 | rasterDesc.DepthClipEnable = false; 444 | rasterDesc.FillMode = D3D11_FILL_SOLID; 445 | rasterDesc.FrontCounterClockwise = true; 446 | rasterDesc.MultisampleEnable = false; 447 | rasterDesc.ScissorEnable = false; 448 | rasterDesc.SlopeScaledDepthBias = 0.0f; 449 | 450 | // Create the rasterizer state from the description we just filled out. 451 | checkHR( g_pDevice->CreateRasterizerState(&rasterDesc, &g_pRasterizerState) ); 452 | 453 | // Setup the viewport 454 | D3D11_VIEWPORT vp; 455 | vp.Width = (FLOAT)width; 456 | vp.Height = (FLOAT)height; 457 | vp.MinDepth = 0.0f; 458 | vp.MaxDepth = 1.0f; 459 | vp.TopLeftX = 0; 460 | vp.TopLeftY = 0; 461 | g_pContext->RSSetViewports( 1, &vp ); 462 | 463 | // Create the transform buffers 464 | D3D11_BUFFER_DESC bd; 465 | ZeroMemory( &bd, sizeof(bd) ); 466 | bd.Usage = D3D11_USAGE_DEFAULT; 467 | bd.ByteWidth = sizeof(MatrixBuffer); 468 | bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; 469 | bd.CPUAccessFlags = 0; 470 | hr = g_pDevice->CreateBuffer( &bd, NULL, &g_pMatrixBuffer[0] ); if( FAILED( hr ) ) return hr; 471 | hr = g_pDevice->CreateBuffer( &bd, NULL, &g_pMatrixBuffer[1] ); if( FAILED( hr ) ) return hr; 472 | hr = g_pDevice->CreateBuffer( &bd, NULL, &g_pMatrixBuffer[2] ); if( FAILED( hr ) ) return hr; 473 | 474 | return S_OK; 475 | } 476 | 477 | 478 | 479 | 480 | //-------------------------------------------------------------------------------------- 481 | // Clean up the objects we've created 482 | //-------------------------------------------------------------------------------------- 483 | void CleanupDevice() 484 | { 485 | if( g_pContext ) g_pContext->ClearState(); 486 | 487 | if( g_pRenderTargetView ) g_pRenderTargetView->Release(); 488 | if( g_pSwapChain ) g_pSwapChain->Release(); 489 | if( g_pContext ) g_pContext->Release(); 490 | if( g_pDevice ) g_pDevice->Release(); 491 | } 492 | 493 | -------------------------------------------------------------------------------- /app_opengl.h: -------------------------------------------------------------------------------- 1 | 2 | #include "glew.h" 3 | 4 | #define GLCOMPAT 5 | 6 | #include 7 | #include 8 | #include "glew.h" 9 | #ifdef _WIN32 10 | #include "wglew.h" 11 | #else 12 | #include "glxew.h" 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | extern void display (); 27 | extern void keyboard_func (unsigned char, int, int); 28 | extern void reshape (int, int); 29 | extern void mouse_click_func (int,int,int,int); 30 | extern void mouse_drag_func (int, int); 31 | extern void mouse_move_func (int, int); 32 | extern void idle_func (); 33 | extern char* initialize ( char* cmdline ); 34 | extern void shutdown (); 35 | 36 | #define GLUT_UP 0 37 | #define GLUT_DOWN 1 38 | #define GLUT_LEFT_BUTTON 1 39 | #define GLUT_RIGHT_BUTTON 2 40 | 41 | //------------------------------------------------------------------------------------ 42 | // Global Variables 43 | //-------------------------------------------------------------------------------------- 44 | HDC g_hDC = NULL; 45 | HGLRC g_hRC = NULL; 46 | HWND g_hWnd = NULL; 47 | bool g_bCtrl = false; 48 | bool g_bShift = false; 49 | float window_width = 1900; 50 | float window_height = 1024; 51 | int mState; 52 | FILE* m_OutCons = 0x0; 53 | 54 | 55 | void checkGL( char* msg ) 56 | { 57 | GLenum errCode; 58 | errCode = glGetError(); 59 | if (errCode != GL_NO_ERROR) { 60 | printf ( "%s, ERROR: %s\n", msg, gluErrorString(errCode) ); 61 | _getch(); 62 | exit( errCode ); 63 | } 64 | } 65 | 66 | void app_printf ( char* format, ... ) 67 | { 68 | // Note: This is the >only< way to do this. There is no general way to 69 | // pass on all the arguments from one ellipsis function to another. 70 | // The function vfprintf was specially designed to allow this. 71 | va_list argptr; 72 | va_start (argptr, format); 73 | vfprintf ( m_OutCons, format, argptr); 74 | va_end (argptr); 75 | fflush ( m_OutCons ); 76 | } 77 | 78 | 79 | 80 | //------------------------------------------------------------------------------ 81 | 82 | void APIENTRY glErrorCallback ( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) 83 | { 84 | char *strSource = "0"; 85 | char *strType = strSource; 86 | char *strSeverity = strSource; 87 | switch(source) { 88 | case GL_DEBUG_SOURCE_API_ARB: strSource = "API"; break; 89 | case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: strSource = "WINDOWS"; break; 90 | case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: strSource = "SHADER COMP."; break; 91 | case GL_DEBUG_SOURCE_THIRD_PARTY_ARB: strSource = "3RD PARTY"; break; 92 | case GL_DEBUG_SOURCE_APPLICATION_ARB: strSource = "APP"; break; 93 | case GL_DEBUG_SOURCE_OTHER_ARB: strSource = "OTHER"; break; 94 | } 95 | switch(type) { 96 | case GL_DEBUG_TYPE_ERROR_ARB: strType = "ERROR"; break; 97 | case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: strType = "Deprecated"; break; 98 | case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB : strType = "Undefined"; break; 99 | case GL_DEBUG_TYPE_PORTABILITY_ARB: strType = "Portability"; break; 100 | case GL_DEBUG_TYPE_PERFORMANCE_ARB: strType = "Performance"; break; 101 | case GL_DEBUG_TYPE_OTHER_ARB: strType = "Other"; break; 102 | } 103 | switch(severity) { 104 | case GL_DEBUG_SEVERITY_HIGH_ARB: strSeverity = "High"; break; 105 | case GL_DEBUG_SEVERITY_MEDIUM_ARB: strSeverity = "Medium"; break; 106 | case GL_DEBUG_SEVERITY_LOW_ARB: strSeverity = "Low"; break; 107 | } 108 | app_printf ("GLError: %s - %s - %s : %s\n", strSeverity, strSource, strType, message); 109 | } 110 | 111 | bool InitGL () 112 | { 113 | GLuint PixelFormat; 114 | 115 | PIXELFORMATDESCRIPTOR pfd; 116 | memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); 117 | 118 | pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); 119 | pfd.nVersion = 1; 120 | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 121 | pfd.iPixelType = PFD_TYPE_RGBA; 122 | pfd.cColorBits = 32; 123 | pfd.cDepthBits = 24; 124 | pfd.cStencilBits = 8; 125 | 126 | g_hDC = GetDC( g_hWnd ); 127 | PixelFormat = ChoosePixelFormat( g_hDC, &pfd ); 128 | SetPixelFormat( g_hDC, PixelFormat, &pfd); 129 | g_hRC = wglCreateContext( g_hDC ); 130 | wglMakeCurrent( g_hDC, g_hRC ); 131 | 132 | // calling glewinit NOW because the inside glew, there is mistake to fix... 133 | // This is the joy of using Core. The query glGetString(GL_EXTENSIONS) is deprecated from the Core profile. 134 | // You need to use glGetStringi(GL_EXTENSIONS, ) instead. Sounds like a "bug" in GLEW. 135 | 136 | if(!wglCreateContextAttribsARB) wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); 137 | 138 | if (wglCreateContextAttribsARB) { 139 | HGLRC hRC = NULL; 140 | int attribList[] = 141 | { 142 | WGL_CONTEXT_MAJOR_VERSION_ARB, 4, 143 | WGL_CONTEXT_MINOR_VERSION_ARB, 2, 144 | #ifdef GLCOMPAT 145 | WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 146 | #else 147 | WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 148 | #endif 149 | WGL_CONTEXT_FLAGS_ARB, 150 | //WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB| 151 | #ifndef GLCOMPAT 152 | WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB| 153 | #endif 154 | #ifdef _DEBUG 155 | WGL_CONTEXT_DEBUG_BIT_ARB 156 | #else 157 | 0 158 | #endif 159 | ,0, 0 160 | }; 161 | if (!(hRC = wglCreateContextAttribsARB(g_hDC, 0, attribList))) 162 | { 163 | app_printf ("wglCreateContextAttribsARB() failed for OpenGL context.\n"); 164 | return false; 165 | } 166 | if (!wglMakeCurrent(g_hDC, hRC)) { 167 | app_printf ("wglMakeCurrent() failed for OpenGL context.\n"); 168 | } else { 169 | wglDeleteContext( g_hRC ); 170 | g_hRC = hRC; 171 | #ifdef _DEBUG 172 | if(!glDebugMessageCallbackARB) 173 | { 174 | glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)wglGetProcAddress("glDebugMessageCallbackARB"); 175 | glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)wglGetProcAddress("glDebugMessageControlARB"); 176 | } 177 | if(glDebugMessageCallbackARB) 178 | { 179 | glDebugMessageCallbackARB( glErrorCallback, NULL ); 180 | glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); 181 | } 182 | #endif 183 | } 184 | } 185 | 186 | glewInit(); 187 | 188 | return true; 189 | } 190 | 191 | LRESULT CALLBACK WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) 192 | { 193 | PAINTSTRUCT ps; 194 | HDC hdc; 195 | switch( msg ) 196 | { 197 | case WM_PAINT: 198 | hdc = BeginPaint( hWnd, &ps ); 199 | EndPaint( hWnd, &ps ); 200 | break; 201 | case WM_DESTROY: 202 | PostQuitMessage( 0 ); 203 | break; 204 | case WM_KEYUP: 205 | switch( wParam ) { 206 | case VK_CONTROL: g_bCtrl = false; break; 207 | case VK_SHIFT: g_bShift = false; break; 208 | } break; 209 | case WM_KEYDOWN: 210 | switch( wParam ) { 211 | case VK_CONTROL: g_bCtrl = true; break; 212 | case VK_SHIFT: g_bShift = true; break; 213 | default: { 214 | WPARAM param = wParam; 215 | char c = MapVirtualKey ( (UINT) param, MAPVK_VK_TO_CHAR ); 216 | keyboard_func ( c, 0, 0 ); // invoke GLUT-style mouse events 217 | } break; 218 | } break; 219 | case WM_LBUTTONDOWN: { 220 | mState = GLUT_DOWN; 221 | mouse_click_func ( GLUT_LEFT_BUTTON, GLUT_DOWN, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 222 | } break; 223 | case WM_RBUTTONDOWN: { 224 | mState = GLUT_DOWN; 225 | mouse_click_func ( GLUT_RIGHT_BUTTON, GLUT_DOWN, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 226 | } break; 227 | case WM_LBUTTONUP: { 228 | mState = GLUT_UP; 229 | mouse_click_func ( GLUT_LEFT_BUTTON, GLUT_UP, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 230 | } break; 231 | case WM_RBUTTONUP: { 232 | mState = GLUT_UP; 233 | mouse_click_func ( GLUT_RIGHT_BUTTON, GLUT_UP, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) ); // invoke GLUT-style mouse move 234 | } break; 235 | case WM_MOUSEMOVE: { 236 | int xpos = GET_X_LPARAM(lParam); 237 | int ypos = GET_Y_LPARAM(lParam); 238 | if ( mState == GLUT_DOWN ) mouse_drag_func ( xpos, ypos );// invoke GLUT-style mouse events 239 | else mouse_move_func ( xpos, ypos ); 240 | } break; 241 | case WM_SIZE: 242 | reshape(LOWORD(lParam), HIWORD(lParam)); 243 | break; 244 | default: 245 | return DefWindowProc( hWnd, msg, wParam, lParam ); 246 | break; 247 | }; 248 | return 0; 249 | } 250 | 251 | 252 | int InitWindow ( HINSTANCE hInstance ) 253 | { 254 | WNDCLASSEX winClass; 255 | MSG uMsg; 256 | 257 | memset(&uMsg,0,sizeof(uMsg)); 258 | 259 | winClass.lpszClassName = "MY_WINDOWS_CLASS"; 260 | winClass.cbSize = sizeof(WNDCLASSEX); 261 | winClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 262 | winClass.lpfnWndProc = WinProc; 263 | winClass.hInstance = hInstance; 264 | winClass.hIcon = 0x0; 265 | winClass.hIconSm = 0x0; 266 | winClass.hCursor = LoadCursor(NULL, IDC_ARROW); 267 | winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 268 | winClass.lpszMenuName = NULL; 269 | winClass.cbClsExtra = 0; 270 | winClass.cbWndExtra = 0; 271 | 272 | if(!RegisterClassEx(&winClass) ) 273 | return E_FAIL; 274 | 275 | g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "", WS_OVERLAPPEDWINDOW, 0, 0, (int) window_width, (int) window_height, NULL, NULL, hInstance, NULL ); 276 | if( g_hWnd == NULL ) 277 | return E_FAIL; 278 | 279 | return 1; 280 | } 281 | 282 | //------------------------------------------------------------------------------ 283 | int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) 284 | { 285 | MSG msg = {0}; 286 | 287 | // Console window for printf 288 | AllocConsole (); 289 | long lStdHandle = (long) GetStdHandle( STD_OUTPUT_HANDLE ); 290 | int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); 291 | m_OutCons = _fdopen( hConHandle, "w" ); 292 | 293 | InitWindow ( hInstance ); // Init OS window 294 | 295 | if ( InitGL() ) { // Init OpenGL context 296 | 297 | char* title = initialize ( lpCmdLine ); // User-init 298 | 299 | SetWindowText ( g_hWnd, title ); 300 | 301 | ShowWindow( g_hWnd, nCmdShow ); // Show main window 302 | UpdateWindow( g_hWnd ); 303 | 304 | // Message pump 305 | while( WM_QUIT != msg.message ) 306 | { 307 | display (); 308 | 309 | if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { 310 | TranslateMessage( &msg ); 311 | DispatchMessage( &msg ); 312 | } 313 | 314 | } 315 | } 316 | shutdown (); 317 | if( g_hRC != NULL ) { 318 | ReleaseDC( g_hWnd, g_hDC ); 319 | g_hDC = NULL; 320 | } 321 | UnregisterClass( "MY_WINDOWS_CLASS", hInstance ); 322 | 323 | return (int) msg.wParam; 324 | } 325 | 326 | 327 | #ifdef USE_GLUT 328 | 329 | int main ( int argc, char **argv ) 330 | { 331 | #ifdef BUILD_CUDA 332 | // Initialize CUDA 333 | cudaInit( argc, argv ); 334 | #endif 335 | 336 | // set up the window 337 | glutInit( &argc, argv ); 338 | glutInitDisplayMode( GLUT_RGBA ); //| GLUT_DEPTH | GLUT_MULTISAMPLE ); 339 | glutInitWindowPosition( 100, 100 ); 340 | glutInitWindowSize( (int) window_width, (int) window_height ); 341 | glutCreateWindow ( "" ); 342 | 343 | // callbacks 344 | glutDisplayFunc( display ); 345 | glutReshapeFunc( reshape ); 346 | glutMouseFunc( mouse_click_func ); 347 | glutKeyboardFunc( keyboard_func ); 348 | glutMotionFunc( mouse_drag_func ); 349 | glutPassiveMotionFunc ( mouse_move_func ); 350 | 351 | glewInit (); 352 | 353 | if ( !g_txt.init ( "baub_16", window_width, window_height ) ) { 354 | printf ( "ERROR: Could not load font.\n" ); 355 | exit ( -1 ); 356 | } 357 | 358 | initialize (); 359 | 360 | //wglSwapIntervalEXT(0); // no vsync 361 | 362 | glutIdleFunc( idle_func ); 363 | glutMainLoop(); 364 | 365 | return 0; 366 | } 367 | 368 | #endif -------------------------------------------------------------------------------- /app_perf.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* APP_PERF 3 | 4 | Copyright 2009-2012 NVIDIA Corporation. All rights reserved. 5 | 6 | R. Hoetzlein 7 | This lightweight performance class provides additional 8 | features for CPU and GPU profiling: 9 | 10 | 1. By default, markers are disabled if nvToolsExt32_1.dll 11 | is not found in the working path. Useful when shipping a product. 12 | 2. Providing nvToolsExt32_1.dll automatically enables CPU and GPU markers. 13 | 3. If nvToolsExt_32.dll is not present, you can still 14 | enable CPU only markers by calling PERF_INIT(false); // false = don't require dll 15 | 4. Instrument code with single PERF_PUSH, PERF_POP markers 16 | for both CPU and GPU output. 17 | 5. Perform additional printing along with markers using PERF_PRINTF 18 | 6. Output CPU markers to log file by specifing filename to PERF_SET 19 | 7. Markers can be nested, with range output for both CPU and GPU 20 | 8. Only app_perf.h and app_perf.cpp are needed. No other dependencies. 21 | No need to link with nvToolsExt.h. 22 | 9. CPU and GPU can be enabled selectively in different parts of the app. 23 | Call PERF_SET( CPUon?, CPUlevel, GPUon?, LogFilename ) at any time. 24 | 10. CPU Level specifies maximum printf level for markers. Useful when 25 | your markers are inside an inner loop. You can keep in code, but hide their output. 26 | 11. GPU markers use NVIDIA's Perfmarkers for viewing in NVIDIA NSIGHT 27 | 28 | */ 29 | 30 | /* 31 | * Copyright 2009-2012 NVIDIA Corporation. All rights reserved. 32 | * 33 | * NOTICE TO USER: 34 | * 35 | * This source code is subject to NVIDIA ownership rights under U.S. and 36 | * international Copyright laws. 37 | * 38 | * This software and the information contained herein is PROPRIETARY and 39 | * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions 40 | * of a form of NVIDIA software license agreement. 41 | * 42 | * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 43 | * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 44 | * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH 45 | * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 46 | * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. 47 | * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 48 | * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 49 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 50 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 51 | * OR PERFORMANCE OF THIS SOURCE CODE. 52 | * 53 | * U.S. Government End Users. This source code is a "commercial item" as 54 | * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of 55 | * "commercial computer software" and "commercial computer software 56 | * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 57 | * and is provided to the U.S. Government only as a commercial end item. 58 | * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 59 | * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 60 | * source code with only those rights set forth herein. 61 | * 62 | * Any use of this source code in individual and commercial software must 63 | * include, in the user documentation and internal comments to the code, 64 | * the above Disclaimer and U.S. Government End Users Notice. 65 | */ 66 | 67 | 68 | #include "app_perf.h" 69 | 70 | #include 71 | #include 72 | #include 73 | 74 | bool g_perfInit = false; // Is perf started? Checks for DLL 75 | bool g_perfOn = false; // Is perf on? DLL was found. Otherwise no perf. 76 | nvtxRangePushFunc g_nvtxPush = 0x0; // Pointer to nv-perfmarker func 77 | nvtxRangePopFunc g_nvtxPop = 0x0; // Pointer to nv-perfmarker func 78 | int g_perfLevel = 0; // Current level of push/pop 79 | sjtime g_perfStack[1024]; // Stack of recorded CPU timings 80 | char* g_perfMsg[1024][256]; // Stack of recorded messages 81 | FILE* g_perfCons = 0x0; // On-screen console to output CPU timing 82 | int g_perfPrintLev = 2; // Maximum level to print. Set with PERF_SET 83 | bool g_perfCPU = true; // Do CPU timing? Set with PERF_SET 84 | bool g_perfGPU = true; // Do GPU timing? Set with PERF_SET 85 | std::string g_perfFName = ""; // File name for CPU output. Set with PERF_SET 86 | FILE* g_perfFile = 0x0; // File handle for output 87 | 88 | void PERF_PRINTF ( char* format, ... ) 89 | { 90 | if ( g_perfCons == 0x0 ) return; 91 | va_list argptr; 92 | va_start (argptr, format); 93 | vfprintf ( g_perfCons, format, argptr); 94 | va_end (argptr); 95 | fflush ( g_perfCons ); 96 | } 97 | 98 | void PERF_PUSH ( const char* msg ) 99 | { 100 | if ( !g_perfInit ) PERF_INIT ( true ); 101 | if ( g_perfOn ) { 102 | if ( g_perfGPU ) (*g_nvtxPush) (msg); 103 | if ( g_perfCPU && g_perfLevel < g_perfPrintLev ) { 104 | strncpy ( (char*) g_perfMsg[ g_perfLevel ], msg, 256 ); 105 | g_perfStack [ g_perfLevel ] = Time::GetSystemNSec (); 106 | PERF_PRINTF ( "%*s%s\n", g_perfLevel <<1, "", msg ); 107 | if ( g_perfFile != 0x0 ) fprintf ( g_perfFile, "%*s%s\n", g_perfLevel <<1, "", msg ); 108 | } 109 | g_perfLevel++; 110 | } 111 | } 112 | float PERF_POP () 113 | { 114 | if ( g_perfOn ) { 115 | if ( g_perfGPU ) (*g_nvtxPop) (); 116 | g_perfLevel--; 117 | if ( g_perfCPU && g_perfLevel < g_perfPrintLev ) { 118 | sjtime curr = Time::GetSystemNSec (); 119 | curr -= g_perfStack [ g_perfLevel ]; 120 | float msec = ((float) curr)/MSEC_SCALAR; 121 | PERF_PRINTF ( "%*s%s: %f ms\n", g_perfLevel <<1, "", g_perfMsg[g_perfLevel], msec ); 122 | if ( g_perfFile != 0x0 ) fprintf ( g_perfFile, "%*s%s: %f ms\n", g_perfLevel <<1, "", g_perfMsg[g_perfLevel], msec ); 123 | return msec; 124 | } 125 | } 126 | return 0.0; 127 | } 128 | 129 | void PERF_SET ( bool cpu, int lev, bool gpu, char* fname ) 130 | { 131 | g_perfCPU = cpu; 132 | if ( lev == 0 ) lev = 32767; 133 | g_perfPrintLev = lev; 134 | g_perfGPU = gpu; 135 | g_perfFName = fname; 136 | if ( g_perfFName.length() > 0 ) { 137 | if ( g_perfFile == 0x0 ) g_perfFile = fopen ( g_perfFName.c_str(), "wt" ); 138 | } 139 | } 140 | 141 | void PERF_INIT ( bool bRequireDLL ) 142 | { 143 | Time x; 144 | 145 | g_perfInit = true; 146 | g_perfOn = false; 147 | g_perfLevel = 0; 148 | 149 | g_perfFile = 0x0; 150 | g_perfFName = ""; 151 | 152 | // Address of NV Perfmarker functions 153 | LoadLibrary ( TEXT("nvToolsExt64_1.dll") ); 154 | HMODULE mod = GetModuleHandle( TEXT("nvToolsExt64_1.dll") ); 155 | g_nvtxPush = (nvtxRangePushFunc) GetProcAddress( mod, "nvtxRangePushA"); 156 | g_nvtxPop = (nvtxRangePopFunc) GetProcAddress( mod, "nvtxRangePop"); 157 | 158 | if ( g_nvtxPush != 0x0 && g_nvtxPop != 0x0 ) { 159 | g_perfOn = true; 160 | PERF_PRINTF ( "PERF_INIT: nvToolsExt32.dll found. Enabling CPU and GPU markers.\n" ); 161 | } else { 162 | if ( !bRequireDLL ) { 163 | PERF_PRINTF ( "PERF_INIT: nvToolsExt32.dll not found. Doing CPU markers anyway.\n" ); 164 | g_perfOn = true; 165 | g_perfGPU = false; 166 | } else { 167 | PERF_PRINTF ( "PERF_INIT: nvToolsExt32.dll not found. Disabled both CPU and GPU markers.\n" ); 168 | } 169 | } 170 | 171 | // Console window for CPU timings 172 | if ( g_perfOn && g_perfCPU ) { 173 | AllocConsole (); 174 | long lStdHandle = (long) GetStdHandle( STD_OUTPUT_HANDLE ); 175 | int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); 176 | g_perfCons = _fdopen( hConHandle, "w" ); 177 | } 178 | } 179 | 180 | 181 | //---------------- TIMING CLASS 182 | // R.Hoetzlein 183 | 184 | #ifdef _MSC_VER 185 | #include 186 | #else 187 | #include 188 | #endif 189 | 190 | #include 191 | #include 192 | #include 193 | 194 | #ifdef _MSC_VER 195 | #define VS2005 196 | #pragma comment ( lib, "winmm.lib" ) 197 | LARGE_INTEGER m_BaseCount; 198 | LARGE_INTEGER m_BaseFreq; 199 | #endif 200 | 201 | const int Time::m_DaysInMonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 202 | bool Time::m_Started = false; 203 | sjtime m_BaseTime; 204 | sjtime m_BaseTicks; 205 | 206 | void start_timing ( sjtime base ) 207 | { 208 | m_BaseTime = base; 209 | 210 | #ifdef _MSC_VER 211 | m_BaseTicks = timeGetTime(); 212 | QueryPerformanceCounter ( &m_BaseCount ); 213 | QueryPerformanceFrequency ( &m_BaseFreq ); 214 | #else 215 | struct timeval tv; 216 | gettimeofday(&tv, NULL); 217 | m_BaseTicks = ((sjtime) tv.tv_sec * 1000000LL) + (sjtime) tv.tv_usec; 218 | #endif 219 | } 220 | 221 | sjtime Time::GetSystemMSec () 222 | { 223 | #ifdef _MSC_VER 224 | return m_BaseTime + sjtime(timeGetTime() - m_BaseTicks)*MSEC_SCALAR; 225 | #else 226 | struct timeval tv; 227 | gettimeofday(&tv, NULL); 228 | sjtime t = ((sjtime) tv.tv_sec * 1000000LL) + (sjtime) tv.tv_usec; 229 | return m_BaseTime + ( t - m_BaseTicks) * 1000LL; // 1000LL - converts microseconds to milliseconds 230 | #endif 231 | } 232 | 233 | sjtime Time::GetSystemNSec () 234 | { 235 | #ifdef _MSC_VER 236 | LARGE_INTEGER currCount; 237 | QueryPerformanceCounter ( &currCount ); 238 | return m_BaseTime + sjtime( (double(currCount.QuadPart-m_BaseCount.QuadPart) / m_BaseFreq.QuadPart) * SEC_SCALAR); 239 | #else 240 | printf ( "ERROR: GetSystemNSec not implemented. QueryPerformanceCounter not available.\n" ); 241 | #endif 242 | } 243 | 244 | void Time::SetTimeNSec () 245 | { 246 | m_CurrTime = GetSystemNSec (); 247 | } 248 | 249 | 250 | Time::Time () 251 | { 252 | if ( !m_Started ) { 253 | m_Started = true; 254 | SetSystemTime (); // Get base time from wall clock 255 | start_timing ( m_CurrTime ); // Start timing from base time 256 | } 257 | m_CurrTime = 0; 258 | } 259 | 260 | // Note regarding hours: 261 | // 0 <= hr <= 23 262 | // hr = 0 is midnight (12 am) 263 | // hr = 1 is 1 am 264 | // hr = 12 is noon 265 | // hr = 13 is 1 pm (subtract 12) 266 | // hr = 23 is 11 pm (subtact 12) 267 | 268 | // GetScaledJulianTime 269 | // Returns -1.0 if the time specified is invalid. 270 | sjtime Time::GetScaledJulianTime ( int hr, int min, int m, int d, int y, int s, int ms, int ns ) 271 | { 272 | double MJD; // Modified Julian Date (JD - 2400000.5) 273 | sjtime SJT; // Scaled Julian Time SJT = MJD * 86400000 + UT 274 | 275 | // Check if date/time is valid 276 | if (m <=0 || m > 12) return (sjtime) -1; 277 | if ( y % 4 == 0 && m == 2) { // leap year in february 278 | if (d <=0 || d > m_DaysInMonth[m]+1) return (sjtime) -1; 279 | } else { 280 | if (d <=0 || d > m_DaysInMonth[m]) return (sjtime) -1; 281 | } 282 | if (hr < 0 || hr > 23) return (sjtime) -1; 283 | if (min < 0 || min > 59) return (sjtime) -1; 284 | 285 | // Compute Modified Julian Date 286 | MJD = 367 * y - int ( 7 * (y + int (( m + 9)/12)) / 4 ); 287 | MJD -= int ( 3 * (int((y + (m - 9)/7)/100) + 1) / 4); 288 | MJD += int ( 275 * m / 9 ) + d + 1721028.5 - 1.0; 289 | MJD -= 2400000.5; 290 | // Compute Scaled Julian Time 291 | SJT = sjtime(MJD) * sjtime( DAY_SCALAR ); 292 | SJT += hr * HR_SCALAR + min * MIN_SCALAR + s * SEC_SCALAR + ms * MSEC_SCALAR + ns * NSEC_SCALAR; 293 | return SJT; 294 | } 295 | 296 | sjtime Time::GetScaledJulianTime ( int hr, int min, int m, int d, int y ) 297 | { 298 | return GetScaledJulianTime ( hr, min, m, d, y, 0, 0, 0 ); 299 | } 300 | 301 | void Time::GetTime ( sjtime SJT, int& hr, int& min, int& m, int& d, int& y) 302 | { 303 | int s = 0, ms = 0, ns = 0; 304 | GetTime ( SJT, hr, min, m, d, y, s, ms, ns ); 305 | } 306 | 307 | void Time::GetTime ( sjtime SJT, int& hr, int& min, int& m, int& d, int& y, int& s, int &ms, int& ns) 308 | { 309 | // Compute Universal Time from SJT 310 | sjtime UT = sjtime( SJT % sjtime( DAY_SCALAR ) ); 311 | 312 | // Compute Modified Julian Date from SJT 313 | double MJD = double(SJT / DAY_SCALAR); 314 | 315 | // Use MJD to get Month, Day, Year 316 | double z = floor ( MJD + 1 + 2400000.5 - 1721118.5); 317 | double g = z - 0.25; 318 | double a = floor ( g / 36524.25 ); 319 | double b = a - floor ( a / 4.0 ); 320 | y = int( floor (( b + g ) / 365.25 ) ); 321 | double c = b + z - floor ( 365.25 * y ); 322 | m = int (( 5 * c + 456) / 153 ); 323 | d = int( c - int (( 153 * m - 457) / 5) ); 324 | if (m > 12) { 325 | y++; 326 | m -= 12; 327 | } 328 | // Use UT to get Hrs, Mins, Secs, Msecs 329 | hr = int( UT / HR_SCALAR ); 330 | UT -= hr * HR_SCALAR; 331 | min = int( UT / MIN_SCALAR ); 332 | UT -= min * MIN_SCALAR; 333 | s = int ( UT / SEC_SCALAR ); 334 | UT -= s * SEC_SCALAR; 335 | ms = int ( UT / MSEC_SCALAR ); 336 | UT -= ms * MSEC_SCALAR; 337 | ns = int ( UT / NSEC_SCALAR ); 338 | 339 | // UT Example: 340 | // MSEC_SCALAR = 1 341 | // SEC_SCALAR = 1,000 342 | // MIN_SCALAR = 60,000 343 | // HR_SCALAR = 3,600,000 344 | // DAY_SCALAR = 86,400,000 345 | // 346 | // 7:14:03, 32 msec 347 | // UT = 7*3,600,000 + 14*60,000 + 3*1,000 + 32 = 26,043,032 348 | // 349 | // 26,043,032 / 3,600,000 = 7 26,043,032 - (7 * 3,600,000) = 843,032 350 | // 843,032 / 60,000 = 14 843,032 - (14 * 60,000) = 3,032 351 | // 3,032 / 1,000 = 3 3,032 - (3 * 1,000) = 32 352 | // 32 / 1 = 32 353 | } 354 | 355 | void Time::GetTime (int& s, int& ms, int& ns ) 356 | { 357 | int hr, min, m, d, y; 358 | GetTime ( m_CurrTime, hr, min, m, d, y, s, ms, ns ); 359 | } 360 | 361 | 362 | void Time::GetTime (int& hr, int& min, int& m, int& d, int& y) 363 | { 364 | GetTime ( m_CurrTime, hr, min, m, d, y); 365 | } 366 | 367 | void Time::GetTime (int& hr, int& min, int& m, int& d, int& y, int& s, int& ms, int& ns) 368 | { 369 | GetTime ( m_CurrTime, hr, min, m, d, y, s, ms, ns); 370 | } 371 | 372 | bool Time::SetTime ( int sec ) 373 | { 374 | int hr, min, m, d, y; 375 | GetTime ( m_CurrTime, hr, min, m, d, y ); 376 | m_CurrTime = GetScaledJulianTime ( hr, min, m, d, y, sec, 0, 0 ); 377 | return true; 378 | } 379 | 380 | bool Time::SetTime ( int sec, int msec ) 381 | { 382 | int hr, min, m, d, y; 383 | GetTime ( m_CurrTime, hr, min, m, d, y ); 384 | m_CurrTime = GetScaledJulianTime ( hr, min, m, d, y, sec, msec, 0 ); 385 | return true; 386 | } 387 | 388 | bool Time::SetTime (int hr, int min, int m, int d, int y) 389 | { 390 | int s, ms, ns; 391 | GetTime ( s, ms, ns ); 392 | m_CurrTime = GetScaledJulianTime ( hr, min, m, d, y, s, ms, ns ); 393 | if (m_CurrTime == -1.0) return false; 394 | return true; 395 | } 396 | 397 | bool Time::SetTime (int hr, int min, int m, int d, int y, int s, int ms, int ns) 398 | { 399 | m_CurrTime = GetScaledJulianTime ( hr, min, m, d, y, s, ms, ns ); 400 | if (m_CurrTime == -1.0) return false; 401 | return true; 402 | } 403 | 404 | bool Time::SetTime ( std::string line ) 405 | { 406 | int hr, min, m, d, y; 407 | std::string dat; 408 | if ( line.substr ( 0, 1 ) == " " ) 409 | dat = line.substr ( 1, line.length()-1 ).c_str(); 410 | else 411 | dat = line; 412 | 413 | hr = atoi ( dat.substr ( 0, 2).c_str() ); 414 | min = atoi ( dat.substr ( 3, 2).c_str() ); 415 | m = atoi ( dat.substr ( 6, 2).c_str () ); 416 | d = atoi ( dat.substr ( 9, 2).c_str () ); 417 | y = atoi ( dat.substr ( 12, 4).c_str () ); 418 | return SetTime ( hr, min, m, d, y); 419 | } 420 | 421 | bool Time::SetDate ( std::string line ) 422 | { 423 | int hr, min, m, d, y; 424 | std::string dat; 425 | if ( line.substr ( 0, 1 ) == " " ) 426 | dat = line.substr ( 1, line.length()-1 ).c_str(); 427 | else 428 | dat = line; 429 | 430 | hr = 0; 431 | min = 0; 432 | m = atoi ( dat.substr ( 0, 2).c_str () ); 433 | d = atoi ( dat.substr ( 3, 2).c_str () ); 434 | y = atoi ( dat.substr ( 6, 4).c_str () ); 435 | return SetTime ( hr, min, m, d, y); 436 | } 437 | 438 | std::string Time::GetDayOfWeekName () 439 | { 440 | switch (GetDayOfWeek()) { 441 | case 1: return "Sunday"; break; 442 | case 2: return "Monday"; break; 443 | case 3: return "Tuesday"; break; 444 | case 4: return "Wednesday"; break; 445 | case 5: return "Thursday"; break; 446 | case 6: return "Friday"; break; 447 | case 7: return "Saturday"; break; 448 | } 449 | return "day error"; 450 | } 451 | 452 | int Time::GetDayOfWeek () 453 | { 454 | // Compute Modified Julian Date 455 | double MJD = (double) m_CurrTime / sjtime( DAY_SCALAR ); 456 | 457 | // Compute Julian Date 458 | double JD = floor ( MJD + 1 + 2400000.5 ); 459 | int dow = (int(JD - 0.5) % 7) + 4; 460 | if (dow > 7) dow -= 7; 461 | 462 | // day of week (1 = sunday, 7 = saturday) 463 | return dow ; 464 | } 465 | 466 | int Time::GetWeekOfYear () 467 | { 468 | int hr, min, m, d, y; 469 | GetTime ( hr, min, m, d, y ); 470 | double mjd_start = (double) GetScaledJulianTime ( 0, 0, 1, 1, y ) / DAY_SCALAR; // mjt for jan 1st of year 471 | double mjd_curr = (double) GetScaledJulianTime ( 0, 0, m, d, y ) / DAY_SCALAR; // mjt for specified day in year 472 | double JD = floor ( mjd_start + 1 + 2400000.5 ); 473 | int dow = (int ( JD - 0.5 ) % 7) + 4; // day of week for jan 1st of year. 474 | if (dow > 7) dow -= 7; 475 | 476 | // week of year (first week in january = week 0) 477 | return int((mjd_curr - mjd_start + dow -1 ) / 7 ); 478 | } 479 | 480 | int Time::GetElapsedDays ( Time& base ) 481 | { 482 | return int( sjtime(m_CurrTime - base.GetSJT() ) / sjtime( DAY_SCALAR ) ); 483 | } 484 | 485 | int Time::GetElapsedWeeks ( Time& base ) 486 | { 487 | return GetElapsedDays(base) / 7; 488 | } 489 | 490 | int Time::GetElapsedMonths ( Time& base) 491 | { 492 | return int ( double(GetElapsedDays(base)) / 30.416 ); 493 | } 494 | 495 | int Time::GetElapsedYears ( Time& base ) 496 | { 497 | // It is much easier to compute this in m/d/y format rather 498 | // than using julian dates. 499 | int bhr, bmin, bm, bd, by; 500 | int ehr, emin, em, ed, ey; 501 | GetTime ( base.GetSJT(), bhr, bmin, bm, bd, by ); 502 | GetTime ( m_CurrTime, ehr, emin, em, ed, ey ); 503 | if ( em < bm) { 504 | // earlier month 505 | return ey - by - 1; 506 | } else if ( em > bm) { 507 | // later month 508 | return ey - by; 509 | } else { 510 | // same month 511 | if ( ed < bd ) { 512 | // earlier day 513 | return ey - by - 1; 514 | } else if ( ed >= bd ) { 515 | // later or same day 516 | return ey - by; 517 | } 518 | } 519 | return -1; 520 | } 521 | 522 | int Time::GetFracDay ( Time& base ) 523 | { 524 | // Resolution = 5-mins 525 | return int( sjtime(m_CurrTime - base.GetSJT() ) % sjtime(DAY_SCALAR) ) / (MIN_SCALAR*5); 526 | } 527 | 528 | int Time::GetFracWeek ( Time& base ) 529 | { 530 | // Resolution = 1 hr 531 | int day = GetElapsedDays(base) % 7; // day in week 532 | int hrs = int( sjtime(m_CurrTime - base.GetSJT() ) % sjtime(DAY_SCALAR) ) / (HR_SCALAR); 533 | return day * 24 + hrs; 534 | } 535 | 536 | int Time::GetFracMonth ( Time& base ) 537 | { 538 | // Resolution = 4 hrs 539 | int day = (int) fmod ( double(GetElapsedDays(base)), 30.416 ); // day in month 540 | int hrs = int( sjtime(m_CurrTime - base.GetSJT() ) % sjtime(DAY_SCALAR) ) / (HR_SCALAR*4); 541 | return day * (24 / 4) + hrs; 542 | } 543 | 544 | int Time::GetFracYear ( Time& base ) 545 | { 546 | // It is much easier to compute this in m/d/y format rather 547 | // than using julian dates. 548 | int bhr, bmin, bm, bd, by; 549 | int ehr, emin, em, ed, ey; 550 | sjtime LastFullYear; 551 | GetTime ( base.GetSJT() , bhr, bmin, bm, bd, by ); 552 | GetTime ( m_CurrTime, ehr, emin, em, ed, ey ); 553 | if ( em < bm) { 554 | // earlier month 555 | LastFullYear = GetScaledJulianTime ( ehr, emin, bm, bd, ey - 1); 556 | return int( sjtime(m_CurrTime - LastFullYear) / sjtime(DAY_SCALAR) ); 557 | } else if ( em > bm) { 558 | // later month 559 | LastFullYear = GetScaledJulianTime ( ehr, emin, bm, bd, ey); 560 | return int( sjtime(m_CurrTime - LastFullYear) / sjtime(DAY_SCALAR) ); 561 | } else { 562 | // same month 563 | if ( ed < bd ) { 564 | // earlier day 565 | LastFullYear = GetScaledJulianTime ( ehr, emin, bm, bd, ey - 1); 566 | return int( sjtime(m_CurrTime - LastFullYear) / sjtime(DAY_SCALAR) ); 567 | } else if ( ed > bd ) { 568 | // later day 569 | LastFullYear = GetScaledJulianTime ( ehr, emin, bm, bd, ey); 570 | return int( sjtime(m_CurrTime - LastFullYear) / sjtime(DAY_SCALAR) ); 571 | } else { 572 | return 0; // same day 573 | } 574 | } 575 | } 576 | 577 | std::string Time::GetReadableDate () 578 | { 579 | char buf[200]; 580 | std::string line; 581 | int hr, min, m, d, y; 582 | 583 | GetTime ( hr, min, m, d, y ); 584 | sprintf ( buf, "%02d:%02d %02d-%02d-%04d", hr, min, m, d, y); 585 | return std::string ( buf ); 586 | } 587 | 588 | std::string Time::GetReadableTime () 589 | { 590 | char buf[200]; 591 | std::string line; 592 | int hr, min, m, d, y, s, ms, ns; 593 | 594 | GetTime ( hr, min, m, d, y, s, ms, ns ); 595 | sprintf ( buf, "%02d:%02d,%03d.%06d", min, s, ms, ns); 596 | //sprintf ( buf, "%02d:%02d:%02d %03d.%06d %02d-%02d-%04d", hr, min, s, ms, ns, m, d, y); 597 | return std::string ( buf ); 598 | } 599 | 600 | std::string Time::GetReadableSJT () 601 | { 602 | char buf[200]; 603 | sprintf ( buf, "%I64d", m_CurrTime ); 604 | return std::string ( buf ); 605 | } 606 | 607 | std::string Time::GetReadableTime ( int fmt ) 608 | { 609 | char buf[200]; 610 | int hr, min, m, d, y, s, ms, ns; 611 | GetTime ( hr, min, m, d, y, s, ms, ns ); 612 | 613 | switch (fmt) { 614 | case 0: sprintf ( buf, "%02d %03d.%06d", s, ms, ns); 615 | } 616 | return std::string ( buf ); 617 | } 618 | 619 | void Time::SetSystemTime () 620 | { 621 | int hr, mn, sec, m, d, y; 622 | char timebuf[100]; 623 | char datebuf[100]; 624 | std::string line; 625 | 626 | #ifdef _MSC_VER 627 | #ifdef VS2005 628 | _strtime_s ( timebuf, 100 ); 629 | _strdate_s ( datebuf, 100 ); 630 | #else 631 | _strtime ( timebuf ); 632 | _strdate ( datebuf ); 633 | #endif 634 | #endif 635 | #if (defined(__linux__) || defined(__CYGWIN__)) 636 | time_t tt; 637 | struct tm tim; 638 | tt = time(NULL); 639 | localtime_r(&tt, &tim); 640 | sprintf( timebuf, "%02i:%02i:%02i", tim.tm_hour, tim.tm_min, tim.tm_sec); 641 | sprintf( datebuf, "%02i:%02i:%02i", tim.tm_mon, tim.tm_mday, tim.tm_year % 100); 642 | #endif 643 | 644 | line = timebuf; 645 | hr = atoi ( line.substr ( 0, 2).c_str() ); 646 | mn = atoi ( line.substr ( 3, 2).c_str() ); 647 | sec = atoi ( line.substr ( 6, 2).c_str() ); 648 | line = datebuf; 649 | m = atoi ( line.substr ( 0, 2).c_str() ); 650 | d = atoi ( line.substr ( 3, 2).c_str() ); 651 | y = atoi ( line.substr ( 6, 2).c_str() ); 652 | 653 | // NOTE: This only works from 1930 to 2030 654 | if ( y > 30) y += 1900; 655 | else y += 2000; 656 | 657 | SetTime ( hr, mn, m, d, y, sec, 0, 0); 658 | } 659 | 660 | 661 | double Time::GetSec () 662 | { 663 | return ((double) m_CurrTime / (double) SEC_SCALAR ); 664 | } 665 | 666 | double Time::GetMSec () 667 | { 668 | return ((double) m_CurrTime / (double) MSEC_SCALAR ); 669 | 670 | /*int s, ms, ns; 671 | GetTime ( s, ms, ns ); 672 | return ms;*/ 673 | } 674 | 675 | void Time::Advance ( Time& t ) 676 | { 677 | m_CurrTime += t.GetSJT (); 678 | } 679 | 680 | void Time::AdvanceMinutes ( int n) 681 | { 682 | m_CurrTime += (sjtime) MIN_SCALAR * n; 683 | } 684 | 685 | void Time::AdvanceHours ( int n ) 686 | { 687 | m_CurrTime += (sjtime) HR_SCALAR * n; 688 | } 689 | 690 | void Time::AdvanceDays ( int n ) 691 | { 692 | m_CurrTime += (sjtime) DAY_SCALAR * n; 693 | } 694 | 695 | void Time::AdvanceSec ( int n ) 696 | { 697 | m_CurrTime += (sjtime) SEC_SCALAR * n; 698 | } 699 | 700 | void Time::AdvanceMins ( int n) 701 | { 702 | m_CurrTime += (sjtime) MIN_SCALAR * n; 703 | } 704 | 705 | void Time::AdvanceMSec ( int n ) 706 | { 707 | m_CurrTime += (sjtime) MSEC_SCALAR * n; 708 | } 709 | 710 | Time& Time::operator= ( const Time& op ) { m_CurrTime = op.m_CurrTime; return *this; } 711 | Time& Time::operator= ( Time& op ) { m_CurrTime = op.m_CurrTime; return *this; } 712 | bool Time::operator< ( const Time& op ) { return (m_CurrTime < op.m_CurrTime); } 713 | bool Time::operator> ( const Time& op ) { return (m_CurrTime > op.m_CurrTime); } 714 | bool Time::operator< ( Time& op ) { return (m_CurrTime < op.m_CurrTime); } 715 | bool Time::operator> ( Time& op ) { return (m_CurrTime > op.m_CurrTime); } 716 | 717 | bool Time::operator<= ( const Time& op ) { return (m_CurrTime <= op.m_CurrTime); } 718 | bool Time::operator>= ( const Time& op ) { return (m_CurrTime >= op.m_CurrTime); } 719 | bool Time::operator<= ( Time& op ) { return (m_CurrTime <= op.m_CurrTime); } 720 | bool Time::operator>= ( Time& op ) { return (m_CurrTime >= op.m_CurrTime); } 721 | 722 | Time Time::operator- ( Time& op ) 723 | { 724 | return Time( m_CurrTime - op.GetSJT() ); 725 | } 726 | Time Time::operator+ ( Time& op ) 727 | { 728 | return Time( m_CurrTime + op.GetSJT() ); 729 | } 730 | 731 | bool Time::operator== ( const Time& op ) 732 | { 733 | return (m_CurrTime == op.m_CurrTime); 734 | } 735 | bool Time::operator!= ( Time& op ) 736 | { 737 | return (m_CurrTime != op.m_CurrTime); 738 | } 739 | 740 | void Time::RegressionTest () 741 | { 742 | // This code verifies the Julian Date calculations are correct for all 743 | // minutes over a range of years. Useful to debug type issues when 744 | // compiling on different platforms. 745 | // 746 | int m, d, y, hr, min; 747 | int cm, cd, cy, chr, cmin; 748 | 749 | for (y=2000; y < 2080; y++) { 750 | for (m=1; m <= 12; m++) { 751 | for (d=1; d <= 31; d++) { 752 | for (hr=0; hr<=23; hr++) { 753 | for (min=0; min<=59; min++) { 754 | if ( SetTime ( hr, min, m, d, y, 0, 0, 0 ) ) { 755 | GetTime ( chr, cmin, cm, cd, cy ); 756 | if ( hr!=chr || min!=cmin || m!=cm || d!=cd || y!=cy) { 757 | // debug.Printf (" time", "Error: %d, %d, %d, %d, %d = %I64d\n", hr, min, m, d, y, GetSJT()); 758 | // debug.Printf (" time", "-----: %d, %d, %d, %d, %d\n", chr, cmin, cm, cd, cy); 759 | } 760 | } 761 | } 762 | } 763 | } 764 | } 765 | // debug.Printf (" time", "Verified: %d\n", y); 766 | } 767 | } 768 | 769 | 770 | -------------------------------------------------------------------------------- /app_perf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/app_perf.h -------------------------------------------------------------------------------- /arial_12.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/arial_12.bin -------------------------------------------------------------------------------- /arial_12.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/arial_12.tga -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | 2 | // State Viewer 3 | // NVIDIA 4 | // Rama Hoetzlein, 2013 5 | // 6 | 7 | // THIS PROGRAM USES A MINIMAL HEADER TO ALLOW 8 | // SAMPLE APPS WITH EITHER DIRECTX OR OPENGL 9 | #ifdef USE_DX 10 | #include "app_directx.h" 11 | #else 12 | #include "app_opengl.h" 13 | #endif 14 | #include "app_perf.h" 15 | #include "app_util.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | Camera3D cam; 24 | int mMode; 25 | int frame = 0; 26 | int mMaxSize = 1; 27 | int mMaxPrim = 1; 28 | int mSelectID = 0; 29 | int mSelectBin = 0; 30 | 31 | int startFrame = 0; 32 | int maxDraw = 0; 33 | std::string fileName; 34 | 35 | bool bShow[10]; 36 | 37 | Vector3DF glide; 38 | 39 | #define NUM_BIN 25 40 | 41 | #define BIN_DRAW 25 42 | #define BIN_SIZE 26 43 | #define MAX_BIN 27 44 | 45 | #define BIN_NOTUSED 0 46 | #define BIN_CREATE 1 47 | #define BIN_CHANGE 2 48 | #define BIN_SWITCH 3 49 | #define BIN_REUSE 4 50 | 51 | struct Event { 52 | std::string name; 53 | int name_id; 54 | int bin_id[MAX_BIN]; 55 | int bin_change[MAX_BIN]; 56 | int bin_size[MAX_BIN]; 57 | int size; 58 | int count; 59 | int frame; 60 | unsigned long call_start; 61 | int call_num; 62 | }; 63 | struct Call { 64 | std::string name; 65 | int name_id; 66 | int bin_id; 67 | int size; 68 | unsigned long long obj_id; 69 | unsigned long long val_id; 70 | }; 71 | struct Frame { 72 | Frame() { clear (); } 73 | void clear () { totalDraw = 0; totalTransfer = 0; totalPrim = 0; for (int n=0; n mEvents; 84 | std::vector mCalls; 85 | std::vector mFrames; 86 | 87 | std::string binNames[MAX_BIN]; 88 | std::string callNames[200]; 89 | 90 | Vector3DF getClr ( unsigned long id ) 91 | { 92 | srand ( id ); 93 | for (int n=0; n < 256; n++ ) { 94 | if ( n % 64 == 0 ) srand( rand() ); 95 | rand(); 96 | } 97 | return Vector3DF(float(rand())/RAND_MAX, float(rand())/RAND_MAX, float(rand())/RAND_MAX ); 98 | } 99 | 100 | void setup_bins () 101 | { 102 | binNames[0] = "Shader"; 103 | binNames[1] = "Render Target"; 104 | binNames[2] = "Viewport"; 105 | binNames[3] = "Raster State"; 106 | binNames[4] = "Depth State"; 107 | binNames[5] = "Blend State"; 108 | binNames[6] = "Sampler State"; 109 | binNames[7] = "Input Assembler"; 110 | binNames[8] = "Texture"; 111 | binNames[9] = "Vertex 0"; 112 | binNames[10] = "Vertex 1"; 113 | binNames[11] = "Vertex 2"; 114 | binNames[12] = "Vertex 3"; 115 | binNames[13] = "Vertex 4"; 116 | binNames[14] = "VS Const 0"; 117 | binNames[15] = "VS Const 1"; 118 | binNames[16] = "VS Const 2"; 119 | binNames[17] = "VS Const 3"; 120 | binNames[18] = "VS Const 4"; 121 | binNames[19] = "PS Const 0"; 122 | binNames[20] = "PS Const 1"; 123 | binNames[21] = "PS Const 2"; 124 | binNames[22] = "PS Const 3"; 125 | binNames[23] = "PS Const 4"; 126 | binNames[24] = "Index Buffer"; 127 | 128 | binNames[25] = "Draw Prims"; 129 | binNames[26] = "Draw Bytes"; 130 | 131 | // DirectX names 132 | callNames[0] = "Present"; // 0 133 | callNames[1] = "DrawIdx"; 134 | callNames[2] = "DrawIst"; 135 | callNames[3] = "Draw"; 136 | callNames[4] = "CreateBuffer"; 137 | callNames[5] = "CreateRenderTargetView"; // 5 138 | callNames[6] = "OMSetRenderTargets"; 139 | callNames[7] = "CreateRasterizerState"; 140 | callNames[8] = "RSSetState"; 141 | callNames[9] = "CreateVertexShader (DX10)"; 142 | callNames[10] = "CreateVertexShader (DX11)"; // 10 143 | callNames[11] = "CreatePixelShader (DX10)"; 144 | callNames[12] = "CreatePixelShader (DX11)"; 145 | callNames[13] = "VSSetShader"; 146 | callNames[14] = "PSSetShader"; 147 | callNames[15] = "Map"; // 15 148 | callNames[16] = "UpdateSubresource"; 149 | callNames[17] = "IASetVertexBuffers"; 150 | callNames[18] = "IASetIndexBuffer"; 151 | callNames[19] = "VSSetConstantBuffers"; 152 | callNames[20] = "PSSetConstantBuffers"; // 20 153 | callNames[21] = "memcpy"; 154 | 155 | // OpenGL names 156 | callNames[100] = "SwapBuffers"; 157 | callNames[101] = "DrawArrays"; 158 | callNames[102] = "DrawElem"; 159 | callNames[103] = "DrawInst"; 160 | callNames[104] = "GenBuffers"; 161 | callNames[105] = "BindBuffer"; 162 | callNames[106] = "BufferData"; 163 | callNames[107] = "CreateShader"; 164 | callNames[108] = "CreateProgram"; 165 | callNames[109] = "UseProgram"; 166 | callNames[110] = "GenTextures"; 167 | callNames[111] = "BindTexture"; 168 | callNames[112] = "TexSubImage2D"; 169 | callNames[113] = "glGetUniformLoc"; 170 | callNames[114] = "glUniform1f"; 171 | callNames[115] = "glUniform3f"; 172 | callNames[116] = "glUniform4f"; 173 | callNames[117] = "glUniformMatrix4fv"; 174 | callNames[118] = "ShaderSource"; 175 | callNames[119] = "glLoadMatrixd"; 176 | callNames[120] = "glLoadMatrixf"; 177 | } 178 | 179 | std::string getName ( char id ) 180 | { 181 | return callNames[id]; 182 | } 183 | 184 | 185 | void drawMatrix () 186 | { 187 | Vector3DF id_clr; 188 | float ypos, yposl; 189 | int b, num = (int) mEvents.size(); 190 | 191 | Matrix4F proj, view, model; 192 | proj.Scale ( 2.0/window_width, -2.0/window_height, 1 ); 193 | model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 ); 194 | view.Scale ( cam.getToPos().z, 1, 1 ); 195 | view *= model; 196 | model.Identity (); 197 | 198 | //----- 2D Drawing (visualizer space) 199 | setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() ); 200 | setorder2D ( false, 1 ); 201 | 202 | // Event ID bars 203 | static2D (); 204 | int fl = -1; 205 | char msg[100]; 206 | for (int n=0; n < num; n++ ) { 207 | if ( mEvents[n].frame != fl ) { 208 | sprintf ( msg, "frame %d", mEvents[n].frame ); drawText ( n*10, -2, msg, 1,1,1,1 ); 209 | } 210 | for (b=0; b < NUM_BIN; b++) { 211 | if ( mEvents[n].bin_id[b] == -1 ) { 212 | id_clr.Set ( 1, 1, 1 ); 213 | } else if ( mEvents[n].bin_change[b] == 0 ) { 214 | id_clr.Set ( .2, .2, .2 ); 215 | } else { 216 | id_clr = getClr ( mEvents[n].bin_id[b] + b*16384 ); 217 | } 218 | drawFill ( n*10.0, b*25, n*10+10.0, b*25+24, id_clr.x, id_clr.y, id_clr.z, 1 ); 219 | } 220 | fl = mEvents[n].frame; 221 | } 222 | end2D (); 223 | 224 | // Change State bars 225 | static2D (); 226 | for (int n=0; n < num; n++ ) { 227 | for (b=0; b < NUM_BIN; b++) { 228 | if ( mEvents[n].bin_id[b] != -1 ) { 229 | switch ( mEvents[n].bin_change[b] ) { 230 | case BIN_NOTUSED: id_clr.Set ( .2, .2, .2 ); break; 231 | case BIN_CREATE: id_clr.Set ( 1, 0, 0 ); break; 232 | case BIN_CHANGE: id_clr.Set ( 1, 0, 0 ); break; 233 | case BIN_SWITCH: id_clr.Set ( 1, .5, 0 ); break; 234 | case BIN_REUSE: id_clr.Set ( 0, 1, 0 ); break; 235 | }; 236 | drawTri ( n*10, b*25, n*10+10, b*25, n*10, b*25+10, id_clr.x, id_clr.y, id_clr.z, 1 ); 237 | } 238 | } 239 | } 240 | end2D (); 241 | 242 | int ys = NUM_BIN*25; 243 | 244 | // Prim count bars 245 | static2D(); 246 | b = BIN_DRAW; 247 | for (int n=0; n < num; n++ ) { 248 | id_clr = getClr ( mEvents[n].bin_id[9] + 9*16384 ); 249 | ypos = mEvents[n].bin_id[ b ] * 400 / mMaxPrim; // prim count 250 | if ( ypos > 100 ) ypos = 100; 251 | drawFill ( n*10, ys+(125-ypos), n*10+10, ys+125, id_clr.x, id_clr.y, id_clr.z, 1 ); 252 | } 253 | end2D (); 254 | 255 | // Mem transfer line 256 | static2D(); 257 | yposl = 0; 258 | b = BIN_SIZE; 259 | for (int n=0; n < num; n++ ) { 260 | id_clr.Set(1,1,1); 261 | ypos = mEvents[n].bin_size[ b ] * 100 / mMaxSize; // size (bytes) 262 | if ( ypos > 100 ) ypos = 100; 263 | drawLine ( n*10+5, ys+(250-ypos), n*10-5, ys+(250-yposl), 1, 1, 1, 1 ); 264 | yposl = ypos; 265 | } 266 | drawLine ( 5, ys+250, num*10-5, ys+250, .5, .5, .5, 1 ); 267 | end2D (); 268 | } 269 | 270 | 271 | void parseHeader ( char* buf, char& typ, char& nameID, unsigned long long& tstart, unsigned long long& tstop ) 272 | { 273 | typ = *(char*) &buf[0]; 274 | nameID = *(char*) &buf[1]; 275 | tstart = *(unsigned long long*) &buf[2]; 276 | tstop = *(unsigned long long*) &buf[10]; 277 | } 278 | 279 | void parseTrace ( char* buf, char nameID, Call& cl ) 280 | { 281 | cl.bin_id = *(int*) &buf[0]; 282 | cl.size = *(int*) &buf[4]; 283 | cl.val_id = *(int*) &buf[8]; 284 | cl.obj_id = *(int*) &buf[12]; 285 | cl.name_id = nameID; 286 | cl.name = getName ( nameID ); 287 | } 288 | void parseTrace ( char* buf, char nameID, Event& e ) 289 | { 290 | int n; 291 | for (n=0; n < NUM_BIN; n++) { 292 | e.bin_id[n] = * (int*) &buf[n*9 + 0]; 293 | e.bin_change[n] = * (char*) &buf[n*9 + 4]; 294 | e.bin_size[n] = * (int*) &buf[n*9 + 5]; 295 | } 296 | n = BIN_DRAW; 297 | e.bin_id[n] = * (int*) &buf[n*9 + 0]; 298 | e.bin_change[n] = * (char*) &buf[n*9 + 4]; 299 | e.bin_size[n] = * (int*) &buf[n*9 + 5]; 300 | n = BIN_SIZE; 301 | e.bin_id[n] = e.bin_id[BIN_DRAW]; 302 | e.bin_change[n] = e.bin_change[BIN_DRAW]; 303 | e.bin_size[n] = e.bin_size[BIN_DRAW]; 304 | 305 | e.name_id = nameID; 306 | e.name = getName ( nameID ); 307 | } 308 | void parseTrace ( char* buf, int& frame, int& size ) 309 | { 310 | frame = * (int* ) &buf [ 0 ]; 311 | size = * (int* ) &buf [ 4 ]; 312 | } 313 | 314 | int fpos = 0; 315 | int fnum = 0; 316 | char fdata[524288]; 317 | 318 | void readbytes ( char* buf, int siz, int cnt, FILE* fp ) 319 | { 320 | if ( fpos + siz >= fnum ) { 321 | int delta = fnum-fpos; 322 | memcpy ( buf, &fdata[fpos], delta ); 323 | fread ( fdata, 524288, 1, fp ); 324 | fnum = 524288; 325 | fpos = 0; 326 | memcpy ( buf+delta, &fdata[fpos], siz-delta); 327 | fpos += siz-delta; 328 | return; 329 | } 330 | memcpy ( buf, &fdata[fpos], siz ); 331 | fpos += siz; 332 | } 333 | 334 | void load_trace_raw ( char* fname ) 335 | { 336 | unsigned long totalBytes = getFileSize ( fname ); 337 | unsigned long currBytes = 0; 338 | 339 | FILE* fp = fopen ( fname, "rb" ); 340 | char header[2048]; 341 | char buf[2048]; 342 | 343 | Call cl; 344 | Event e; 345 | char typ, nameID; 346 | unsigned long long tstart, tstop; 347 | int fnum, size = 0; 348 | int cstart = 0, cnum = 0; 349 | mMaxSize = 1; 350 | 351 | int num_frame = 0; 352 | int num_draw = 0; 353 | 354 | Frame f; 355 | f.clear (); 356 | frame = 0; 357 | 358 | while ( !feof(fp) && (num_draw < maxDraw || maxDraw==0)) { 359 | 360 | readbytes ( header, 18, 1, fp ); // 18 byte header 361 | parseHeader ( header, typ, nameID, tstart, tstop ); 362 | switch ( typ ) { 363 | case 'C': { 364 | readbytes ( buf, 20, 1, fp ); 365 | if ( num_frame >= startFrame ) { 366 | parseTrace ( buf, nameID, cl ); 367 | mCalls.push_back ( cl ); 368 | cnum++; 369 | } 370 | } break; 371 | case 'D': { 372 | 373 | currBytes = getFilePos ( fp ); 374 | if ( f.totalDraw % 100 == 0 ) { 375 | if ( maxDraw == 0 ) { 376 | app_printf ( "%dk read, %.2f%% of file, %.2f%% done\n", currBytes/1024, currBytes*100.0f/totalBytes, currBytes*100.0f/totalBytes ); 377 | } else { 378 | app_printf ( "%dk read, %.2f%% of file, %.2f%% done\n", currBytes/1024, currBytes*100.0f/totalBytes, num_draw*100.0f/maxDraw ); 379 | } 380 | } 381 | readbytes ( buf, NUM_BIN*9 + 9, 1, fp ); 382 | 383 | if ( num_frame >= startFrame ) { 384 | parseTrace ( buf, nameID, e ); 385 | 386 | e.frame = frame; 387 | e.call_num = cnum; 388 | e.call_start = cstart; 389 | mEvents.push_back ( e ); 390 | 391 | cstart += cnum; 392 | cnum = 0; 393 | if ( e.bin_size[BIN_DRAW] > mMaxSize ) mMaxSize = e.bin_size[BIN_DRAW]; 394 | if ( e.bin_id[BIN_DRAW] > mMaxPrim ) mMaxPrim = e.bin_id[BIN_DRAW]; 395 | num_draw++; 396 | 397 | for (int n=0; n < NUM_BIN; n++) { 398 | f.binChange[n] += (e.bin_change[n]==BIN_CREATE || e.bin_change[n]==BIN_CHANGE) ? 1 : 0; 399 | f.binSwitch[n] += (e.bin_change[n]==BIN_SWITCH ) ? 1 : 0; 400 | f.binReuse[n] += (e.bin_change[n]==BIN_REUSE ) ? 1 : 0; 401 | f.binUnique[n] = (e.bin_id[n] > f.binUnique[n] ) ? e.bin_id[n] : f.binUnique[n]; 402 | } 403 | f.totalDraw++; 404 | f.totalTransfer += e.bin_size[BIN_DRAW]; 405 | f.totalPrim += e.bin_id[BIN_DRAW]; 406 | } 407 | } break; 408 | case 'F': { 409 | 410 | readbytes ( buf, 8, 1, fp ); 411 | 412 | if ( num_frame >= startFrame ) { 413 | mFrames.push_back ( f ); // record frame data 414 | f.clear (); 415 | frame++; 416 | parseTrace ( buf, fnum, size ); 417 | e.name_id = nameID; 418 | e.name = "Present"; 419 | e.call_num = cnum; 420 | e.call_start = cstart; 421 | e.count = 1; 422 | for (int n=0; n < NUM_BIN; n++ ) { 423 | e.bin_id[n] = -1; 424 | e.bin_change[n] = -1; 425 | } 426 | mEvents.push_back ( e ); 427 | cstart += cnum; 428 | cnum = 0; 429 | } 430 | num_frame++; 431 | 432 | } break; 433 | }; 434 | } 435 | // read may not have gotten to end of frame 436 | mFrames.push_back ( f ); 437 | 438 | if ( mFrames.size() == 0 || mEvents.size() == 0 ) { 439 | app_printf ( "Error: No frames or events detected.\n" ); 440 | app_printf ( "Try running trace again. \n" ); 441 | _getch(); 442 | exit(-1); 443 | } 444 | 445 | fclose ( fp ); 446 | 447 | } 448 | 449 | void load_trace_txt ( char* fname ) 450 | { 451 | std::string str, word; 452 | char buf[1024]; 453 | 454 | unsigned long totalBytes = getFileSize ( fname ); 455 | unsigned long currBytes = 0; 456 | 457 | FILE* fp = fopen ( fname, "rt" ); 458 | int c; 459 | std::vector changestates; 460 | changestates.push_back ( "x" ); // 0 = BIN_NOTUSED 461 | changestates.push_back ( "c" ); // 1 = BIN_CREATE 462 | changestates.push_back ( "u" ); // 2 = BIN_CHANGE 463 | changestates.push_back ( "s" ); // 3 = BIN_SWITCH 464 | changestates.push_back ( "-" ); // 4 = BIN_REUSE 465 | changestates.push_back ( "D" ); 466 | 467 | Call cl; 468 | Event e; 469 | int lin = 0; 470 | int max_lin = 5000; 471 | std::string szstr; 472 | int sz; 473 | unsigned long cstart = 0; 474 | int cnum = 0; 475 | 476 | while (!feof(fp) && lin < max_lin) { 477 | 478 | currBytes = getFilePos ( fp ); 479 | printf ( "%d (%.2f%%)\n", currBytes, currBytes*100.0f/totalBytes ); 480 | 481 | fgets ( buf, 1024, fp ); 482 | str = buf; 483 | int bin = 0; 484 | str = strTrim ( str ); 485 | 486 | e.name = word; 487 | 488 | if ( str.compare (0, 2, "C:") == 0 ) { 489 | /*word = strSplit ( str, " " ); 490 | word = strSplit ( str, " " ); cl.bin_id = strToI(word); 491 | word = strSplit ( str, " " ); cl.size = strToI(word); 492 | word = strSplit ( str, " " ); cl.obj_id = strToLI(word); 493 | word = strSplit ( str, " " ); cl.val_id = strToLI(word); 494 | word = strSplit ( str, " " ); cl.name = word; 495 | mCalls.push_back ( cl );*/ 496 | cnum++; 497 | } else if ( str.compare ( 0, 2, "FR" ) == 0 ) { 498 | e.count = 1; 499 | for (int n=0; n < NUM_BIN; n++ ) { 500 | e.bin_id[n] = -1; 501 | e.bin_change[n] = -1; 502 | } 503 | mEvents.push_back ( e ); 504 | } else if ( str.compare ( 0, 2, "Dr" ) == 0 ) { 505 | e.count = 1; 506 | int bin = 0; 507 | word = strLeft ( str, 8 ); 508 | str = strTrim ( str ); 509 | while ( str.length() > 0 ) { 510 | word = strSplit ( str, " " ); 511 | c = strExtract ( word, changestates ); 512 | szstr = strParse ( word, "[", "]" ); 513 | e.bin_id[bin] = strToI ( word ); 514 | e.bin_change[bin] = c; 515 | e.bin_size[bin] = strToI ( szstr ); 516 | bin++; 517 | } 518 | e.call_start = cstart; 519 | e.call_num = cnum; 520 | if ( e.bin_size[BIN_DRAW] > mMaxSize ) mMaxSize = e.bin_size[BIN_DRAW]; 521 | mEvents.push_back ( e ); 522 | cstart += cnum; 523 | } 524 | 525 | lin++; 526 | } 527 | 528 | fclose ( fp ); 529 | } 530 | 531 | void drawOverlay () 532 | { 533 | Vector4DF clr; 534 | 535 | Matrix4F proj, view, model; 536 | proj.Scale ( 2.0/window_width, -2.0/window_height, 1 ); 537 | model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 ); 538 | view.Scale ( cam.getToPos().z, 1, 1 ); 539 | view *= model; 540 | model.Identity (); 541 | 542 | //----- 2D Drawing (visualizer space) 543 | setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() ); 544 | setorder2D ( false, 1 ); 545 | updatestatic2D ( 0 ); // update model/view/proj matrices of each static draw layer 546 | updatestatic2D ( 1 ); 547 | updatestatic2D ( 2 ); 548 | updatestatic2D ( 3 ); 549 | 550 | // Selector Bar 551 | start2D (); 552 | drawRect ( mSelectID*10, 0, mSelectID*10+10, NUM_BIN*25, 1,1,1,1 ); 553 | 554 | // Same-State Highlights (yellow) 555 | int minE = (((0-window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10; 556 | int maxE = (((window_width - window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10; 557 | minE = ( minE < 0 ) ? 0 : minE; 558 | maxE = ( maxE >= mEvents.size() ) ? mEvents.size() : maxE; 559 | for (int n=0; n < mEvents.size(); n++ ) { 560 | if ( mEvents[n].bin_id[mSelectBin] == mEvents[mSelectID].bin_id[mSelectBin] && n > minE && n < maxE ) { 561 | drawRect ( n*10, mSelectBin*25, n*10+10, mSelectBin*25+24, 1,1,0,1 ); 562 | drawRect ( n*10+1, mSelectBin*25+1, n*10+9, mSelectBin*25+23, 1,1,0,1 ); 563 | } 564 | } 565 | end2D (); 566 | 567 | //----- 2D Drawing (screen space) 568 | setview2D ( window_width, window_height ); // change to screen space 569 | setorder2D ( true, -0.00001 ); 570 | 571 | start2D (); // dynamic draw 572 | int panel_width = 200; 573 | float xoff = window_width - panel_width; 574 | float yoff = cam.getToPos().y + (window_height/2); 575 | 576 | // Left panel - Bin Text 577 | char name[128]; 578 | char msg[1024]; 579 | 580 | int frame = mEvents[mSelectID].frame; 581 | frame = (frame < 0 || frame >= mFrames.size() ) ? 0 : frame; 582 | Frame& f = mFrames[ frame ]; 583 | 584 | drawFill ( 0, yoff, +panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 ); 585 | 586 | drawText ( 10, yoff-85, "Frame #:", 1,1,1,1 ); 587 | drawText ( 10, yoff-70, "Frame Draws:", 1,1,1,1 ); 588 | drawText ( 10, yoff-55, "Frame Prims:", 1,1,1,1 ); 589 | drawText ( 10, yoff-40, "Frame Transfer:", 1,1,1,1 ); 590 | drawText ( 10, yoff-20, "Frame States:", 1,1,1,1 ); 591 | sprintf ( msg, "%d", frame ); drawText ( 100, yoff - 85, msg, 1,1,1,1 ); 592 | sprintf ( msg, "%d", f.totalDraw ); drawText ( 100, yoff - 70, msg, 1,1,1,1 ); 593 | sprintf ( msg, "%d", f.totalPrim ); drawText ( 100, yoff - 55, msg, 1,1,1,1 ); 594 | sprintf ( msg, "%d bytes", f.totalTransfer ); drawText ( 100, yoff - 40, msg, 1,1,1,1 ); 595 | 596 | setText ( 0.8, 0 ); 597 | drawText ( 100, yoff - 20, "Modify", 1,0,0,1 ); 598 | drawText ( 125, yoff - 10, "Switch", 1,0.5,0,1 ); 599 | drawText ( 150, yoff - 20, "Reuse", 0,1,0,1 ); 600 | drawText ( 175, yoff - 10, "Unique", 1,1,1,1 ); 601 | drawTri ( 100, yoff-10, 100+10, yoff-10, 100, yoff, 1, 0,0, 1); 602 | drawTri ( 125, yoff-10, 125+10, yoff-10, 125, yoff, 1,.5,0, 1); 603 | drawTri ( 150, yoff-10, 150+10, yoff-10, 150, yoff, 0, 1,0, 1); 604 | setText ( 1.0, -0.5 ); 605 | 606 | for (int b=0; b < NUM_BIN; b++ ) { 607 | strncpy ( name, binNames[b].c_str(), 128 ); 608 | drawText ( 8, yoff + b*25+12, name, 1,1,1,1 ); 609 | 610 | clr.x = float(f.binChange[b]) / f.totalDraw; if ( clr.x > 1 ) clr.x = 1; 611 | sprintf ( msg, "%d", f.binChange[b] ); drawText ( 100, yoff + b*25+12-2, msg, clr.x*0.7+0.3, 0,0,1 ); 612 | 613 | clr.x = float(f.binSwitch[b]) / f.totalDraw; if ( clr.x > 1 ) clr.x= 1; 614 | sprintf ( msg, "%d", f.binSwitch[b] ); drawText ( 125, yoff + b*25+12+2, msg, clr.x*0.7+0.3,clr.x*.4+0.2,0,1 ); 615 | 616 | clr.x = float(f.binReuse[b]) / f.totalDraw; if ( clr.x > 1 ) clr.x= 1; 617 | sprintf ( msg, "%d", f.binReuse[b] ); drawText ( 150, yoff + b*25+12-2, msg, 0, clr.x*0.7+0.3, 0,1 ); 618 | 619 | sprintf ( msg, "%d", f.binUnique[b] ); drawText ( 175, yoff + b*25+12+2, msg, .7, .7, .7,1 ); 620 | } 621 | 622 | int ys = NUM_BIN*25; 623 | float ypos; 624 | sprintf ( msg, "%d", mMaxPrim/4 ); 625 | drawLine ( 0, yoff + ys+25, 200, yoff+ys+25, .6, .6, .6, 1); 626 | drawText ( 10, yoff+ys+25+15, msg, .8,.8,.8,1 ); 627 | drawText ( 10, yoff + ys+80, "# Prims", 1, 1, 1, 1 ); 628 | drawText ( 10, yoff+ys+125, "0", .8,.8,.8,1 ); 629 | drawLine ( 0, yoff + ys+125, 200, yoff+ys+125, .6, .6, .6, 1); 630 | ypos = mEvents[ mSelectID ].bin_id[ BIN_DRAW ] * 400 / mMaxPrim; // prim count 631 | clr = getClr ( mEvents[ mSelectID ].bin_id[9] + 9*16384 ); 632 | if ( ypos > 100 ) ypos = 100; 633 | sprintf ( msg, "%d", mEvents[ mSelectID ].bin_id[BIN_DRAW] ); 634 | drawLine ( 150, yoff+ys+(125-ypos), 200, yoff+ys+(125-ypos), clr.x,clr.y,clr.z,1 ); 635 | drawText ( 150, yoff+ys+(125-ypos), msg, clr.x,clr.y,clr.z,1 ); 636 | 637 | sprintf ( msg, "%d", mMaxSize ); 638 | drawLine ( 0, yoff + ys+150, 200, yoff+ys+150, .6, .6, .6, 1); 639 | drawText ( 10, yoff+ys+150+15, msg, .8,.8,.8,1 ); 640 | drawText ( 10, yoff + ys+200, "Transfer (bytes)" , 1, 1, 1, 1); 641 | drawText ( 10, yoff+ys+250, "0", .8,.8,.8,1 ); 642 | drawLine ( 0, yoff + ys+250, 200, yoff+ys+250, .6, .6, .6, 1); 643 | ypos = mEvents[ mSelectID ].bin_size [ BIN_SIZE ] * 100 / mMaxSize; // prim count 644 | if ( ypos > 100 ) ypos = 100; 645 | sprintf ( msg, "%d", mEvents[ mSelectID ].bin_size [BIN_SIZE] ); 646 | drawLine ( 150, yoff+ys+(250-ypos), 200, yoff+ys+(250-ypos), 1,1,1,1 ); 647 | drawText ( 150, yoff+ys+(250-ypos), msg, 1,1,1,1 ); 648 | 649 | // Right panel - Call Text 650 | drawFill ( xoff, yoff, xoff + panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 ); 651 | int cid; 652 | glColor3f ( 1, 1, 1); 653 | 654 | for (int c = 0; c < mEvents[ mSelectID ].call_num; c++ ) { 655 | cid = mEvents[ mSelectID ].call_start + c; 656 | clr = getClr ( mCalls[cid].val_id + mCalls[cid].bin_id*16384 ); 657 | clr.w = 1; 658 | drawFill ( xoff+100, yoff + c*15, xoff+125, yoff+c*15+13, clr.x, clr.y, clr.z, clr.w ); 659 | 660 | sprintf ( msg, "%s", mCalls[cid].name.c_str() ); 661 | drawText ( xoff+5, yoff + c*15+15, msg, 1,1,1,1 ); 662 | 663 | sprintf ( msg, "%02d %d %d", mCalls[cid].bin_id, mCalls[cid].size, mCalls[cid].val_id ); 664 | drawText ( xoff+130, yoff + c*15+15, msg, 1,1,1,1 ); 665 | } 666 | end2D (); 667 | 668 | 669 | 670 | #ifdef USE_DX 671 | g_pContext->OMSetDepthStencilState( g_pDepthStencilState, 1 ); 672 | #endif 673 | } 674 | 675 | // Main display loop 676 | void display () 677 | { 678 | cam.moveToPos ( glide.x, 0, 0 ); 679 | glide.x *= 0.8; 680 | 681 | PERF_PUSH ( "frame" ); 682 | 683 | // Clear framebuffers. OpenGL 684 | glClearColor( 0.1, 0.1, 0.1, 0.0 ); 685 | glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 686 | 687 | drawOverlay (); 688 | 689 | drawGui (); 690 | 691 | draw2D (); 692 | 693 | #ifdef USE_DX 694 | // DirectX - Swap buffers 695 | checkHR ( g_pSwapChain->Present ( 0, 0 ) ); 696 | #else 697 | // OpenGL - Swap buffers 698 | SwapBuffers ( g_hDC ); 699 | #endif 700 | 701 | PERF_POP (); 702 | 703 | frame++; 704 | } 705 | 706 | void reshape ( int width, int height ) 707 | { 708 | // set window height and width 709 | window_width = (float) width; 710 | window_height = (float) height; 711 | glViewport( 0, 0, width, height ); 712 | setview2D ( window_width, window_height ); 713 | } 714 | 715 | // This function called by both OpenGL (GLUT) and DirectX 716 | void keyboard_func ( unsigned char key, int x, int y ) 717 | { 718 | switch ( key ) { 719 | case 27: 720 | exit ( 0 ); 721 | break; 722 | case 'v': bShow[0] = !bShow[0]; break; 723 | case 'c': bShow[1] = !bShow[1]; break; 724 | }; 725 | } 726 | 727 | 728 | Vector3DF cangs; 729 | Vector3DF ctp; 730 | float cdist; 731 | int dragging; 732 | #define DRAG_OFF 0 733 | #define DRAG_LEFT 1 734 | #define DRAG_RIGHT 2 735 | float last_x, last_y; 736 | 737 | // This function called by both OpenGL (GLUT) and DirectX 738 | void mouse_click_func ( int button, int state, int x, int y ) 739 | { 740 | cangs = cam.getAng(); 741 | ctp = cam.getToPos(); 742 | cdist = cam.getOrbitDist(); 743 | 744 | if ( state==GLUT_DOWN && guiMouseDown ( x, y ) ) return; // event handling for nv2D GUIs 745 | 746 | if( state == GLUT_DOWN ) { 747 | if ( button == GLUT_LEFT_BUTTON ) dragging = DRAG_LEFT; 748 | else if ( button == GLUT_RIGHT_BUTTON ) dragging = DRAG_RIGHT; 749 | last_x = x; 750 | last_y = y; 751 | } else if ( state==GLUT_UP ) { 752 | dragging = DRAG_OFF; 753 | } 754 | } 755 | 756 | // This function called by both OpenGL (GLUT) and DirectX 757 | void mouse_move_func ( int x, int y ) 758 | { 759 | mSelectID = (((x-window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10; 760 | if ( mSelectID < 0 ) mSelectID = 0; 761 | if ( mSelectID > mEvents.size()-1 ) mSelectID = mEvents.size() -1; 762 | 763 | mSelectBin = ((y-window_height/2.0) - cam.getToPos().y) / 25; 764 | if ( mSelectBin < 0 ) mSelectBin = 0; 765 | if ( mSelectBin >= NUM_BIN ) mSelectBin = NUM_BIN-1; 766 | } 767 | 768 | // This function called by both OpenGL (GLUT) and DirectX 769 | void mouse_drag_func ( int x, int y ) 770 | { 771 | if ( guiMouseDrag ( x, y ) ) return; // event handling for nv2D GUIs 772 | 773 | int dx = x - last_x; 774 | int dy = y - last_y; 775 | 776 | float deltx = window_width / cam.getToPos().z; 777 | float delty = window_height / cam.getToPos().z; 778 | 779 | // Camera interaction 780 | int mode = 0; 781 | switch ( mode ) { 782 | case 0: 783 | if ( dragging == DRAG_LEFT ) { 784 | glide += Vector3DF( dx / cam.getToPos().z, 0, 0); 785 | cam.moveToPos ( 0, dy, 0 ); 786 | } else if ( dragging == DRAG_RIGHT ) { 787 | cam.moveToPos ( 0, 0, -dy*0.001 ); 788 | if ( cam.to_pos.z < 0.001 ) cam.to_pos.z = 0.001; 789 | } 790 | break; 791 | } 792 | last_x = x; 793 | last_y = y; 794 | } 795 | 796 | 797 | void idle_func () 798 | { 799 | } 800 | 801 | char* initialize ( char* cmdline ) 802 | { 803 | // Get comnmand line 804 | std::string str = cmdline; 805 | std::vector args; 806 | while ( str.length() > 0) { 807 | args.push_back ( strSplit ( str, " " ) ); 808 | } 809 | fileName = ""; 810 | for (int n=0; n < args.size(); n++ ) { 811 | if ( args[n].compare ( "-f" ) == 0 ) { 812 | startFrame = strToI ( args[n+1] ); 813 | } 814 | if ( args[n].compare ( "-d" ) == 0 ) { // max_draw 815 | maxDraw = strToI ( args[n+1] ); 816 | } 817 | if ( args[n].find_first_of ( "." ) != std::string::npos ) { 818 | fileName = args[n]; 819 | } 820 | } 821 | if ( fileName.length()== 0 || args.size()==0 ) { 822 | app_printf ( "USAGE: state_view [-f #] [-d #] filename.raw\n\n" ); 823 | app_printf ( " -f # Start at frame \n" ); 824 | app_printf ( " -d # Maximum number of draw calls to read \n" ); 825 | _getch(); 826 | exit(-1); 827 | } 828 | 829 | for (int n=0; n < 10; n++ ) bShow[n] = true; 830 | 831 | // Initialize camera 832 | cam.setPos ( 0, 0, 1 ); 833 | cam.setToPos ( -window_width*3/8, -window_height*3/8, 1 ); 834 | cam.updateMatricies (); 835 | 836 | // Initialize bin and call names 837 | setup_bins (); 838 | 839 | // Load trace file 840 | char fname[256]; 841 | strcpy ( fname, fileName.c_str() ); 842 | load_trace_raw ( fname ); 843 | 844 | // required init functions 845 | init2D ( "arial_12" ); // specify font file (.bin/tga) 846 | setText ( 1.0, -0.5 ); // scale by 0.5, kerning adjust -0.5 pixels 847 | setview2D ( window_width, window_height ); 848 | 849 | // draw visualization layer 850 | drawMatrix (); 851 | 852 | PERF_INIT ( false ); // Enable CPU perf (do not require nv-perfmarker DLL) 853 | PERF_SET ( false, 2, false, "" ); // Perf CPU?, CPU level, NV Perfmarkers, Log filename 854 | 855 | return "NVIDIA State Viewer, by Rama Hoetzlein"; // Return Window title 856 | } 857 | 858 | 859 | void shutdown () 860 | { 861 | } 862 | -------------------------------------------------------------------------------- /nvToolsExt32_1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/nvToolsExt32_1.dll -------------------------------------------------------------------------------- /nvToolsExt64_1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/nvToolsExt64_1.dll -------------------------------------------------------------------------------- /state_view.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 27 | 30 | 33 | 36 | 39 | 42 | 55 | 58 | 61 | 64 | 78 | 81 | 84 | 87 | 90 | 93 | 96 | 99 | 100 | 108 | 111 | 114 | 117 | 120 | 123 | 133 | 136 | 139 | 142 | 156 | 159 | 162 | 165 | 168 | 171 | 174 | 177 | 178 | 186 | 189 | 192 | 195 | 198 | 201 | 214 | 217 | 220 | 223 | 237 | 240 | 243 | 246 | 249 | 252 | 255 | 258 | 259 | 265 | 268 | 271 | 274 | 277 | 280 | 285 | 288 | 291 | 294 | 298 | 301 | 304 | 307 | 310 | 313 | 316 | 319 | 320 | 328 | 331 | 334 | 337 | 340 | 343 | 356 | 359 | 362 | 365 | 379 | 382 | 385 | 388 | 391 | 394 | 397 | 400 | 401 | 409 | 412 | 415 | 418 | 421 | 424 | 434 | 437 | 440 | 443 | 457 | 460 | 463 | 466 | 469 | 472 | 475 | 478 | 479 | 480 | 481 | 482 | 483 | 486 | 487 | 490 | 491 | 494 | 495 | 498 | 499 | 502 | 503 | 506 | 507 | 510 | 511 | 514 | 515 | 518 | 519 | 522 | 523 | 526 | 527 | 530 | 531 | 534 | 535 | 538 | 539 | 542 | 543 | 544 | 545 | 546 | 547 | -------------------------------------------------------------------------------- /state_view.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug (DirectX) 6 | Win32 7 | 8 | 9 | Debug (DirectX) 10 | x64 11 | 12 | 13 | Debug (OpenGL) 14 | Win32 15 | 16 | 17 | Debug (OpenGL) 18 | x64 19 | 20 | 21 | Debug 22 | Win32 23 | 24 | 25 | Debug 26 | x64 27 | 28 | 29 | Release (DirectX) 30 | Win32 31 | 32 | 33 | Release (DirectX) 34 | x64 35 | 36 | 37 | Release (OpenGL) 38 | Win32 39 | 40 | 41 | Release (OpenGL) 42 | x64 43 | 44 | 45 | Release 46 | Win32 47 | 48 | 49 | Release 50 | x64 51 | 52 | 53 | 54 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9} 55 | spheres 56 | Win32Proj 57 | 58 | 59 | 60 | Application 61 | MultiByte 62 | 63 | 64 | Application 65 | MultiByte 66 | 67 | 68 | Application 69 | MultiByte 70 | 71 | 72 | Application 73 | MultiByte 74 | 75 | 76 | Application 77 | 78 | 79 | Application 80 | 81 | 82 | Application 83 | MultiByte 84 | 85 | 86 | Application 87 | MultiByte 88 | 89 | 90 | Application 91 | MultiByte 92 | 93 | 94 | Application 95 | MultiByte 96 | 97 | 98 | Application 99 | MultiByte 100 | 101 | 102 | Application 103 | MultiByte 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | <_ProjectFileVersion>10.0.30319.1 157 | Debug\ 158 | Debug\ 159 | Debug\ 160 | Debug\ 161 | false 162 | false 163 | Release\ 164 | Release\ 165 | Release\ 166 | Release\ 167 | false 168 | false 169 | $(Configuration)\ 170 | $(Configuration)\ 171 | $(Configuration)\ 172 | $(Configuration)\ 173 | true 174 | false 175 | $(SolutionDir)$(Configuration)\ 176 | $(SolutionDir)$(Configuration)\ 177 | $(Configuration)\ 178 | $(Configuration)\ 179 | $(Configuration)\ 180 | $(Configuration)\ 181 | $(Configuration)\ 182 | $(Configuration)\ 183 | true 184 | false 185 | $(Configuration)\ 186 | $(Configuration)\ 187 | $(Configuration)\ 188 | $(Configuration)\ 189 | false 190 | false 191 | .;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include;$(IncludePath) 192 | .;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64;$(LibraryPath) 193 | 194 | 195 | 196 | Disabled 197 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 198 | WIN32;_DEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 199 | true 200 | EnableFastChecks 201 | MultiThreadedDebug 202 | 203 | 204 | Level3 205 | EditAndContinue 206 | 207 | 208 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 209 | $(OutDir)$(ProjectName).exe 210 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 211 | %(IgnoreSpecificDefaultLibraries) 212 | true 213 | $(OutDir)instanced_tessellation.pdb 214 | Windows 215 | false 216 | 217 | 218 | MachineX86 219 | 220 | 221 | 222 | 223 | Disabled 224 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 225 | WIN32;_DEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 226 | EnableFastChecks 227 | MultiThreadedDebug 228 | 229 | 230 | Level3 231 | ProgramDatabase 232 | 233 | 234 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 235 | $(OutDir)$(ProjectName).exe 236 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 237 | %(IgnoreSpecificDefaultLibraries) 238 | true 239 | $(OutDir)instanced_tessellation.pdb 240 | Windows 241 | false 242 | 243 | 244 | 245 | 246 | 247 | 248 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 249 | WIN32;NDEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 250 | MultiThreaded 251 | 252 | 253 | Level3 254 | ProgramDatabase 255 | 256 | 257 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 258 | $(OutDir)$(ProjectName).exe 259 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 260 | true 261 | Windows 262 | true 263 | true 264 | false 265 | 266 | 267 | MachineX86 268 | 269 | 270 | 271 | 272 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 273 | WIN32;NDEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 274 | MultiThreaded 275 | 276 | 277 | Level3 278 | ProgramDatabase 279 | 280 | 281 | d3d11.lib;d3dcompiler.lib;%(AdditionalDependencies) 282 | $(OutDir)$(ProjectName).exe 283 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 284 | true 285 | Windows 286 | true 287 | true 288 | false 289 | 290 | 291 | 292 | 293 | 294 | 295 | Disabled 296 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 297 | GLEW_STATIC;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 298 | true 299 | EnableFastChecks 300 | MultiThreadedDebug 301 | 302 | 303 | Level3 304 | EditAndContinue 305 | 306 | 307 | $(OutDir)$(ProjectName).exe 308 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 309 | %(IgnoreSpecificDefaultLibraries) 310 | true 311 | $(OutDir)instanced_tessellation.pdb 312 | Windows 313 | false 314 | 315 | 316 | MachineX86 317 | opengl32.lib;glu32.lib;%(AdditionalDependencies) 318 | 319 | 320 | 321 | 322 | Disabled 323 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 324 | GLEW_STATIC;_WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 325 | EnableFastChecks 326 | MultiThreadedDebug 327 | 328 | 329 | Level3 330 | ProgramDatabase 331 | 332 | 333 | $(OutDir)$(ProjectName).exe 334 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 335 | %(IgnoreSpecificDefaultLibraries) 336 | true 337 | $(OutDir)instanced_tessellation.pdb 338 | Windows 339 | false 340 | 341 | 342 | opengl32.lib;glu32.lib;%(AdditionalDependencies) 343 | 344 | 345 | 346 | 347 | GLEW_STATIC;_WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 348 | 349 | 350 | Windows 351 | opengl32.lib;glu32.lib;%(AdditionalDependencies) 352 | 353 | 354 | 355 | 356 | GLEW_STATIC;_WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 357 | 358 | 359 | Windows 360 | opengl32.lib;glu32.lib;%(AdditionalDependencies) 361 | 362 | 363 | 364 | 365 | Disabled 366 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 367 | WIN32;_DEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 368 | true 369 | EnableFastChecks 370 | MultiThreadedDebug 371 | 372 | 373 | Level3 374 | EditAndContinue 375 | 376 | 377 | d3d11.lib;d3dcompiler.lib;dxerr.lib;%(AdditionalDependencies) 378 | $(OutDir)$(ProjectName).exe 379 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 380 | %(IgnoreSpecificDefaultLibraries) 381 | true 382 | $(OutDir)instanced_tessellation.pdb 383 | Windows 384 | false 385 | 386 | 387 | MachineX86 388 | 389 | 390 | 391 | 392 | Disabled 393 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 394 | WIN64;_DEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 395 | EnableFastChecks 396 | MultiThreadedDebug 397 | 398 | 399 | Level3 400 | ProgramDatabase 401 | 402 | 403 | d3d11.lib;d3dcompiler.lib;dxerr.lib;%(AdditionalDependencies) 404 | $(OutDir)$(ProjectName).exe 405 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 406 | %(IgnoreSpecificDefaultLibraries) 407 | true 408 | $(OutDir)instanced_tessellation.pdb 409 | Windows 410 | false 411 | 412 | 413 | 414 | 415 | 416 | 417 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 418 | WIN32;NDEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 419 | MultiThreaded 420 | 421 | 422 | Level3 423 | ProgramDatabase 424 | 425 | 426 | d3d11.lib;d3dcompiler.lib;dxerr.lib;%(AdditionalDependencies) 427 | $(OutDir)$(ProjectName).exe 428 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 429 | true 430 | Windows 431 | true 432 | true 433 | false 434 | 435 | 436 | MachineX86 437 | 438 | 439 | 440 | 441 | ../../external/include;../../common/GLEW/include;../../common/include;../../common/nvWidgets/include;../../common/nvModel/include;%(AdditionalIncludeDirectories) 442 | WIN32;NDEBUG;WINDOWS;USE_DX;%(PreprocessorDefinitions) 443 | MultiThreaded 444 | 445 | 446 | Level3 447 | ProgramDatabase 448 | 449 | 450 | d3d11.lib;d3dcompiler.lib;dxerr.lib;%(AdditionalDependencies) 451 | $(OutDir)$(ProjectName).exe 452 | ../../external/lib;../../common/GLEW/lib;../../common/nvWidgets/lib;%(AdditionalLibraryDirectories) 453 | true 454 | Windows 455 | true 456 | true 457 | false 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | -------------------------------------------------------------------------------- /state_view.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | revit.raw 5 | WindowsLocalDebugger 6 | 7 | 8 | -d 2000 city.raw 9 | WindowsLocalDebugger 10 | 11 | 12 | -f 30 c:\codes\stateview\dawn.raw 13 | WindowsLocalDebugger 14 | 15 | 16 | -f 1 -d 2000 c:\codes\stateview\dawn.raw 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /state_view_VS2008.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spheres", "spheres.vcproj", "{7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug (DirectX)|Win32 = Debug (DirectX)|Win32 8 | Debug (OpenGL)|Win32 = Debug (OpenGL)|Win32 9 | Debug|Win32 = Debug|Win32 10 | Release (DirectX)|Win32 = Release (DirectX)|Win32 11 | Release (OpenGL)|Win32 = Release (OpenGL)|Win32 12 | Release|Win32 = Release|Win32 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|Win32.ActiveCfg = Debug (DirectX)|Win32 16 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|Win32.Build.0 = Debug (DirectX)|Win32 17 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|Win32.ActiveCfg = Debug (OpenGL)|Win32 18 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|Win32.Build.0 = Debug (OpenGL)|Win32 19 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|Win32.Build.0 = Debug|Win32 21 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|Win32.ActiveCfg = Release (DirectX)|Win32 22 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|Win32.Build.0 = Release (DirectX)|Win32 23 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|Win32.ActiveCfg = Release (OpenGL)|Win32 24 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|Win32.Build.0 = Release (OpenGL)|Win32 25 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|Win32.ActiveCfg = Release|Win32 26 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|Win32.Build.0 = Release|Win32 27 | EndGlobalSection 28 | GlobalSection(SolutionProperties) = preSolution 29 | HideSolutionNode = FALSE 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /state_view_VS2010.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "state_view", "state_view.vcxproj", "{7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug (DirectX)|Win32 = Debug (DirectX)|Win32 8 | Debug (DirectX)|x64 = Debug (DirectX)|x64 9 | Debug (OpenGL)|Win32 = Debug (OpenGL)|Win32 10 | Debug (OpenGL)|x64 = Debug (OpenGL)|x64 11 | Debug|Win32 = Debug|Win32 12 | Debug|x64 = Debug|x64 13 | Release (DirectX)|Win32 = Release (DirectX)|Win32 14 | Release (DirectX)|x64 = Release (DirectX)|x64 15 | Release (OpenGL)|Win32 = Release (OpenGL)|Win32 16 | Release (OpenGL)|x64 = Release (OpenGL)|x64 17 | Release|Win32 = Release|Win32 18 | Release|x64 = Release|x64 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|Win32.ActiveCfg = Debug (DirectX)|Win32 22 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|Win32.Build.0 = Debug (DirectX)|Win32 23 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|x64.ActiveCfg = Debug (DirectX)|x64 24 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (DirectX)|x64.Build.0 = Debug (DirectX)|x64 25 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|Win32.ActiveCfg = Debug (OpenGL)|Win32 26 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|Win32.Build.0 = Debug (OpenGL)|Win32 27 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|x64.ActiveCfg = Debug (OpenGL)|x64 28 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug (OpenGL)|x64.Build.0 = Debug (OpenGL)|x64 29 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|Win32.ActiveCfg = Debug|Win32 30 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|Win32.Build.0 = Debug|Win32 31 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|x64.ActiveCfg = Debug|x64 32 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Debug|x64.Build.0 = Debug|x64 33 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|Win32.ActiveCfg = Release (DirectX)|Win32 34 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|Win32.Build.0 = Release (DirectX)|Win32 35 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|x64.ActiveCfg = Release (DirectX)|x64 36 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (DirectX)|x64.Build.0 = Release (DirectX)|x64 37 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|Win32.ActiveCfg = Release (OpenGL)|Win32 38 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|Win32.Build.0 = Release (OpenGL)|Win32 39 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|x64.ActiveCfg = Release (OpenGL)|x64 40 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release (OpenGL)|x64.Build.0 = Release (OpenGL)|x64 41 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|Win32.ActiveCfg = Release|Win32 42 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|Win32.Build.0 = Release|Win32 43 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|x64.ActiveCfg = Release|x64 44 | {7A62A0B4-5E7C-46CE-80BA-D2A4F89489D9}.Release|x64.Build.0 = Release|x64 45 | EndGlobalSection 46 | GlobalSection(SolutionProperties) = preSolution 47 | HideSolutionNode = FALSE 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /stateview.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/stateview.exe -------------------------------------------------------------------------------- /stateview_slides.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ramakarl/stateviewer/a9028a03ec3b357b9ec982dabb0229d68a6c474a/stateview_slides.ppt -------------------------------------------------------------------------------- /stdint.h: -------------------------------------------------------------------------------- 1 | // ISO C9x compliant stdint.h for Microsoft Visual Studio 2 | // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 3 | // 4 | // Copyright (c) 2006-2008 Alexander Chemeris 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in the 14 | // documentation and/or other materials provided with the distribution. 15 | // 16 | // 3. The name of the author may be used to endorse or promote products 17 | // derived from this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 20 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 22 | // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 | // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _MSC_VER // [ 33 | #error "Use this header only with Microsoft Visual C++ compilers!" 34 | #endif // _MSC_VER ] 35 | 36 | #ifndef _MSC_STDINT_H_ // [ 37 | #define _MSC_STDINT_H_ 38 | 39 | #if _MSC_VER > 1000 40 | #pragma once 41 | #endif 42 | 43 | #include 44 | 45 | // For Visual Studio 6 in C++ mode and for many Visual Studio versions when 46 | // compiling for ARM we should wrap include with 'extern "C++" {}' 47 | // or compiler give many errors like this: 48 | // error C2733: second C linkage of overloaded function 'wmemchr' not allowed 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | # include 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | // Define _W64 macros to mark types changing their size, like intptr_t. 58 | #ifndef _W64 59 | # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 60 | # define _W64 __w64 61 | # else 62 | # define _W64 63 | # endif 64 | #endif 65 | 66 | 67 | // 7.18.1 Integer types 68 | 69 | // 7.18.1.1 Exact-width integer types 70 | 71 | // Visual Studio 6 and Embedded Visual C++ 4 doesn't 72 | // realize that, e.g. char has the same size as __int8 73 | // so we give up on __intX for them. 74 | #if (_MSC_VER < 1300) 75 | typedef signed char int8_t; 76 | typedef signed short int16_t; 77 | typedef signed int int32_t; 78 | typedef unsigned char uint8_t; 79 | typedef unsigned short uint16_t; 80 | typedef unsigned int uint32_t; 81 | #else 82 | typedef signed __int8 int8_t; 83 | typedef signed __int16 int16_t; 84 | typedef signed __int32 int32_t; 85 | typedef unsigned __int8 uint8_t; 86 | typedef unsigned __int16 uint16_t; 87 | typedef unsigned __int32 uint32_t; 88 | #endif 89 | typedef signed __int64 int64_t; 90 | typedef unsigned __int64 uint64_t; 91 | 92 | 93 | // 7.18.1.2 Minimum-width integer types 94 | typedef int8_t int_least8_t; 95 | typedef int16_t int_least16_t; 96 | typedef int32_t int_least32_t; 97 | typedef int64_t int_least64_t; 98 | typedef uint8_t uint_least8_t; 99 | typedef uint16_t uint_least16_t; 100 | typedef uint32_t uint_least32_t; 101 | typedef uint64_t uint_least64_t; 102 | 103 | // 7.18.1.3 Fastest minimum-width integer types 104 | typedef int8_t int_fast8_t; 105 | typedef int16_t int_fast16_t; 106 | typedef int32_t int_fast32_t; 107 | typedef int64_t int_fast64_t; 108 | typedef uint8_t uint_fast8_t; 109 | typedef uint16_t uint_fast16_t; 110 | typedef uint32_t uint_fast32_t; 111 | typedef uint64_t uint_fast64_t; 112 | 113 | // 7.18.1.4 Integer types capable of holding object pointers 114 | #ifdef _WIN64 // [ 115 | typedef signed __int64 intptr_t; 116 | typedef unsigned __int64 uintptr_t; 117 | #else // _WIN64 ][ 118 | typedef _W64 signed int intptr_t; 119 | typedef _W64 unsigned int uintptr_t; 120 | #endif // _WIN64 ] 121 | 122 | // 7.18.1.5 Greatest-width integer types 123 | typedef int64_t intmax_t; 124 | typedef uint64_t uintmax_t; 125 | 126 | 127 | // 7.18.2 Limits of specified-width integer types 128 | 129 | #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 130 | 131 | // 7.18.2.1 Limits of exact-width integer types 132 | #define INT8_MIN ((int8_t)_I8_MIN) 133 | #define INT8_MAX _I8_MAX 134 | #define INT16_MIN ((int16_t)_I16_MIN) 135 | #define INT16_MAX _I16_MAX 136 | #define INT32_MIN ((int32_t)_I32_MIN) 137 | #define INT32_MAX _I32_MAX 138 | #define INT64_MIN ((int64_t)_I64_MIN) 139 | #define INT64_MAX _I64_MAX 140 | #define UINT8_MAX _UI8_MAX 141 | #define UINT16_MAX _UI16_MAX 142 | #define UINT32_MAX _UI32_MAX 143 | #define UINT64_MAX _UI64_MAX 144 | 145 | // 7.18.2.2 Limits of minimum-width integer types 146 | #define INT_LEAST8_MIN INT8_MIN 147 | #define INT_LEAST8_MAX INT8_MAX 148 | #define INT_LEAST16_MIN INT16_MIN 149 | #define INT_LEAST16_MAX INT16_MAX 150 | #define INT_LEAST32_MIN INT32_MIN 151 | #define INT_LEAST32_MAX INT32_MAX 152 | #define INT_LEAST64_MIN INT64_MIN 153 | #define INT_LEAST64_MAX INT64_MAX 154 | #define UINT_LEAST8_MAX UINT8_MAX 155 | #define UINT_LEAST16_MAX UINT16_MAX 156 | #define UINT_LEAST32_MAX UINT32_MAX 157 | #define UINT_LEAST64_MAX UINT64_MAX 158 | 159 | // 7.18.2.3 Limits of fastest minimum-width integer types 160 | #define INT_FAST8_MIN INT8_MIN 161 | #define INT_FAST8_MAX INT8_MAX 162 | #define INT_FAST16_MIN INT16_MIN 163 | #define INT_FAST16_MAX INT16_MAX 164 | #define INT_FAST32_MIN INT32_MIN 165 | #define INT_FAST32_MAX INT32_MAX 166 | #define INT_FAST64_MIN INT64_MIN 167 | #define INT_FAST64_MAX INT64_MAX 168 | #define UINT_FAST8_MAX UINT8_MAX 169 | #define UINT_FAST16_MAX UINT16_MAX 170 | #define UINT_FAST32_MAX UINT32_MAX 171 | #define UINT_FAST64_MAX UINT64_MAX 172 | 173 | // 7.18.2.4 Limits of integer types capable of holding object pointers 174 | #ifdef _WIN64 // [ 175 | # define INTPTR_MIN INT64_MIN 176 | # define INTPTR_MAX INT64_MAX 177 | # define UINTPTR_MAX UINT64_MAX 178 | #else // _WIN64 ][ 179 | # define INTPTR_MIN INT32_MIN 180 | # define INTPTR_MAX INT32_MAX 181 | # define UINTPTR_MAX UINT32_MAX 182 | #endif // _WIN64 ] 183 | 184 | // 7.18.2.5 Limits of greatest-width integer types 185 | #define INTMAX_MIN INT64_MIN 186 | #define INTMAX_MAX INT64_MAX 187 | #define UINTMAX_MAX UINT64_MAX 188 | 189 | // 7.18.3 Limits of other integer types 190 | 191 | #ifdef _WIN64 // [ 192 | # define PTRDIFF_MIN _I64_MIN 193 | # define PTRDIFF_MAX _I64_MAX 194 | #else // _WIN64 ][ 195 | # define PTRDIFF_MIN _I32_MIN 196 | # define PTRDIFF_MAX _I32_MAX 197 | #endif // _WIN64 ] 198 | 199 | #define SIG_ATOMIC_MIN INT_MIN 200 | #define SIG_ATOMIC_MAX INT_MAX 201 | 202 | #ifndef SIZE_MAX // [ 203 | # ifdef _WIN64 // [ 204 | # define SIZE_MAX _UI64_MAX 205 | # else // _WIN64 ][ 206 | # define SIZE_MAX _UI32_MAX 207 | # endif // _WIN64 ] 208 | #endif // SIZE_MAX ] 209 | 210 | // WCHAR_MIN and WCHAR_MAX are also defined in 211 | #ifndef WCHAR_MIN // [ 212 | # define WCHAR_MIN 0 213 | #endif // WCHAR_MIN ] 214 | #ifndef WCHAR_MAX // [ 215 | # define WCHAR_MAX _UI16_MAX 216 | #endif // WCHAR_MAX ] 217 | 218 | #define WINT_MIN 0 219 | #define WINT_MAX _UI16_MAX 220 | 221 | #endif // __STDC_LIMIT_MACROS ] 222 | 223 | 224 | // 7.18.4 Limits of other integer types 225 | 226 | #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 227 | 228 | // 7.18.4.1 Macros for minimum-width integer constants 229 | 230 | #define INT8_C(val) val##i8 231 | #define INT16_C(val) val##i16 232 | #define INT32_C(val) val##i32 233 | #define INT64_C(val) val##i64 234 | 235 | #define UINT8_C(val) val##ui8 236 | #define UINT16_C(val) val##ui16 237 | #define UINT32_C(val) val##ui32 238 | #define UINT64_C(val) val##ui64 239 | 240 | // 7.18.4.2 Macros for greatest-width integer constants 241 | #define INTMAX_C INT64_C 242 | #define UINTMAX_C UINT64_C 243 | 244 | #endif // __STDC_CONSTANT_MACROS ] 245 | 246 | 247 | #endif // _MSC_STDINT_H_ ] 248 | -------------------------------------------------------------------------------- /wglew.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** The OpenGL Extension Wrangler Library 3 | ** Copyright (C) 2002-2008, Milan Ikits 4 | ** Copyright (C) 2002-2008, Marcelo E. Magallon 5 | ** Copyright (C) 2002, Lev Povalahev 6 | ** All rights reserved. 7 | ** 8 | ** Redistribution and use in source and binary forms, with or without 9 | ** modification, are permitted provided that the following conditions are met: 10 | ** 11 | ** * Redistributions of source code must retain the above copyright notice, 12 | ** this list of conditions and the following disclaimer. 13 | ** * Redistributions in binary form must reproduce the above copyright notice, 14 | ** this list of conditions and the following disclaimer in the documentation 15 | ** and/or other materials provided with the distribution. 16 | ** * The name of the author may be used to endorse or promote products 17 | ** derived from this software without specific prior written permission. 18 | ** 19 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 23 | ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 | ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29 | ** THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /* 33 | ** Copyright (c) 2007 The Khronos Group Inc. 34 | ** 35 | ** Permission is hereby granted, free of charge, to any person obtaining a 36 | ** copy of this software and/or associated documentation files (the 37 | ** "Materials"), to deal in the Materials without restriction, including 38 | ** without limitation the rights to use, copy, modify, merge, publish, 39 | ** distribute, sublicense, and/or sell copies of the Materials, and to 40 | ** permit persons to whom the Materials are furnished to do so, subject to 41 | ** the following conditions: 42 | ** 43 | ** The above copyright notice and this permission notice shall be included 44 | ** in all copies or substantial portions of the Materials. 45 | ** 46 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 47 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 48 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 49 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 50 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 51 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 52 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 53 | */ 54 | 55 | #ifndef __wglew_h__ 56 | #define __wglew_h__ 57 | #define __WGLEW_H__ 58 | 59 | #ifdef __wglext_h_ 60 | #error wglext.h included before wglew.h 61 | #endif 62 | 63 | #define __wglext_h_ 64 | 65 | #if !defined(WINAPI) 66 | # ifndef WIN32_LEAN_AND_MEAN 67 | # define WIN32_LEAN_AND_MEAN 1 68 | # endif 69 | #include 70 | # undef WIN32_LEAN_AND_MEAN 71 | #endif 72 | 73 | /* 74 | * GLEW_STATIC needs to be set when using the static version. 75 | * GLEW_BUILD is set when building the DLL version. 76 | */ 77 | #ifdef GLEW_STATIC 78 | # define GLEWAPI extern 79 | #else 80 | # ifdef GLEW_BUILD 81 | # define GLEWAPI extern __declspec(dllexport) 82 | # else 83 | # define GLEWAPI extern __declspec(dllimport) 84 | # endif 85 | #endif 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | /* -------------------------- WGL_3DFX_multisample ------------------------- */ 92 | 93 | #ifndef WGL_3DFX_multisample 94 | #define WGL_3DFX_multisample 1 95 | 96 | #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 97 | #define WGL_SAMPLES_3DFX 0x2061 98 | 99 | #define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) 100 | 101 | #endif /* WGL_3DFX_multisample */ 102 | 103 | /* ------------------------- WGL_3DL_stereo_control ------------------------ */ 104 | 105 | #ifndef WGL_3DL_stereo_control 106 | #define WGL_3DL_stereo_control 1 107 | 108 | #define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 109 | #define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 110 | #define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 111 | #define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 112 | 113 | typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); 114 | 115 | #define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) 116 | 117 | #define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) 118 | 119 | #endif /* WGL_3DL_stereo_control */ 120 | 121 | /* ------------------------ WGL_AMD_gpu_association ------------------------ */ 122 | 123 | #ifndef WGL_AMD_gpu_association 124 | #define WGL_AMD_gpu_association 1 125 | 126 | #define WGL_GPU_VENDOR_AMD 0x1F00 127 | #define WGL_GPU_RENDERER_STRING_AMD 0x1F01 128 | #define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 129 | #define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 130 | #define WGL_GPU_RAM_AMD 0x21A3 131 | #define WGL_GPU_CLOCK_AMD 0x21A4 132 | #define WGL_GPU_NUM_PIPES_AMD 0x21A5 133 | #define WGL_GPU_NUM_SIMD_AMD 0x21A6 134 | #define WGL_GPU_NUM_RB_AMD 0x21A7 135 | #define WGL_GPU_NUM_SPI_AMD 0x21A8 136 | 137 | typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 138 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); 139 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); 140 | typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); 141 | typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); 142 | typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); 143 | typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); 144 | typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); 145 | typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); 146 | 147 | #define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) 148 | #define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) 149 | #define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) 150 | #define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) 151 | #define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) 152 | #define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) 153 | #define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) 154 | #define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) 155 | #define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) 156 | 157 | #define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) 158 | 159 | #endif /* WGL_AMD_gpu_association */ 160 | 161 | /* ------------------------- WGL_ARB_buffer_region ------------------------- */ 162 | 163 | #ifndef WGL_ARB_buffer_region 164 | #define WGL_ARB_buffer_region 1 165 | 166 | #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 167 | #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 168 | #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 169 | #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 170 | 171 | typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); 172 | typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); 173 | typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 174 | typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); 175 | 176 | #define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) 177 | #define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) 178 | #define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) 179 | #define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) 180 | 181 | #define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) 182 | 183 | #endif /* WGL_ARB_buffer_region */ 184 | 185 | /* ------------------------- WGL_ARB_create_context ------------------------ */ 186 | 187 | #ifndef WGL_ARB_create_context 188 | #define WGL_ARB_create_context 1 189 | 190 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 191 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 192 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 193 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 194 | #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 195 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 196 | #define ERROR_INVALID_VERSION_ARB 0x2095 197 | #define ERROR_INVALID_PROFILE_ARB 0x2096 198 | 199 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); 200 | 201 | #define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) 202 | 203 | #define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) 204 | 205 | #endif /* WGL_ARB_create_context */ 206 | 207 | /* --------------------- WGL_ARB_create_context_profile -------------------- */ 208 | 209 | #ifndef WGL_ARB_create_context_profile 210 | #define WGL_ARB_create_context_profile 1 211 | 212 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 213 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 214 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 215 | 216 | #define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) 217 | 218 | #endif /* WGL_ARB_create_context_profile */ 219 | 220 | /* ------------------- WGL_ARB_create_context_robustness ------------------- */ 221 | 222 | #ifndef WGL_ARB_create_context_robustness 223 | #define WGL_ARB_create_context_robustness 1 224 | 225 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 226 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 227 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 228 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 229 | 230 | #define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) 231 | 232 | #endif /* WGL_ARB_create_context_robustness */ 233 | 234 | /* ----------------------- WGL_ARB_extensions_string ----------------------- */ 235 | 236 | #ifndef WGL_ARB_extensions_string 237 | #define WGL_ARB_extensions_string 1 238 | 239 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); 240 | 241 | #define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) 242 | 243 | #define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) 244 | 245 | #endif /* WGL_ARB_extensions_string */ 246 | 247 | /* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ 248 | 249 | #ifndef WGL_ARB_framebuffer_sRGB 250 | #define WGL_ARB_framebuffer_sRGB 1 251 | 252 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 253 | 254 | #define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) 255 | 256 | #endif /* WGL_ARB_framebuffer_sRGB */ 257 | 258 | /* ----------------------- WGL_ARB_make_current_read ----------------------- */ 259 | 260 | #ifndef WGL_ARB_make_current_read 261 | #define WGL_ARB_make_current_read 1 262 | 263 | #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 264 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 265 | 266 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); 267 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 268 | 269 | #define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) 270 | #define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) 271 | 272 | #define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) 273 | 274 | #endif /* WGL_ARB_make_current_read */ 275 | 276 | /* -------------------------- WGL_ARB_multisample -------------------------- */ 277 | 278 | #ifndef WGL_ARB_multisample 279 | #define WGL_ARB_multisample 1 280 | 281 | #define WGL_SAMPLE_BUFFERS_ARB 0x2041 282 | #define WGL_SAMPLES_ARB 0x2042 283 | 284 | #define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) 285 | 286 | #endif /* WGL_ARB_multisample */ 287 | 288 | /* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ 289 | 290 | #ifndef WGL_ARB_pbuffer 291 | #define WGL_ARB_pbuffer 1 292 | 293 | #define WGL_DRAW_TO_PBUFFER_ARB 0x202D 294 | #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E 295 | #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F 296 | #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 297 | #define WGL_PBUFFER_LARGEST_ARB 0x2033 298 | #define WGL_PBUFFER_WIDTH_ARB 0x2034 299 | #define WGL_PBUFFER_HEIGHT_ARB 0x2035 300 | #define WGL_PBUFFER_LOST_ARB 0x2036 301 | 302 | DECLARE_HANDLE(HPBUFFERARB); 303 | 304 | typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); 305 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); 306 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); 307 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); 308 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); 309 | 310 | #define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) 311 | #define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) 312 | #define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) 313 | #define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) 314 | #define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) 315 | 316 | #define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) 317 | 318 | #endif /* WGL_ARB_pbuffer */ 319 | 320 | /* -------------------------- WGL_ARB_pixel_format ------------------------- */ 321 | 322 | #ifndef WGL_ARB_pixel_format 323 | #define WGL_ARB_pixel_format 1 324 | 325 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 326 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 327 | #define WGL_DRAW_TO_BITMAP_ARB 0x2002 328 | #define WGL_ACCELERATION_ARB 0x2003 329 | #define WGL_NEED_PALETTE_ARB 0x2004 330 | #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 331 | #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 332 | #define WGL_SWAP_METHOD_ARB 0x2007 333 | #define WGL_NUMBER_OVERLAYS_ARB 0x2008 334 | #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 335 | #define WGL_TRANSPARENT_ARB 0x200A 336 | #define WGL_SHARE_DEPTH_ARB 0x200C 337 | #define WGL_SHARE_STENCIL_ARB 0x200D 338 | #define WGL_SHARE_ACCUM_ARB 0x200E 339 | #define WGL_SUPPORT_GDI_ARB 0x200F 340 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 341 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 342 | #define WGL_STEREO_ARB 0x2012 343 | #define WGL_PIXEL_TYPE_ARB 0x2013 344 | #define WGL_COLOR_BITS_ARB 0x2014 345 | #define WGL_RED_BITS_ARB 0x2015 346 | #define WGL_RED_SHIFT_ARB 0x2016 347 | #define WGL_GREEN_BITS_ARB 0x2017 348 | #define WGL_GREEN_SHIFT_ARB 0x2018 349 | #define WGL_BLUE_BITS_ARB 0x2019 350 | #define WGL_BLUE_SHIFT_ARB 0x201A 351 | #define WGL_ALPHA_BITS_ARB 0x201B 352 | #define WGL_ALPHA_SHIFT_ARB 0x201C 353 | #define WGL_ACCUM_BITS_ARB 0x201D 354 | #define WGL_ACCUM_RED_BITS_ARB 0x201E 355 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201F 356 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 357 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 358 | #define WGL_DEPTH_BITS_ARB 0x2022 359 | #define WGL_STENCIL_BITS_ARB 0x2023 360 | #define WGL_AUX_BUFFERS_ARB 0x2024 361 | #define WGL_NO_ACCELERATION_ARB 0x2025 362 | #define WGL_GENERIC_ACCELERATION_ARB 0x2026 363 | #define WGL_FULL_ACCELERATION_ARB 0x2027 364 | #define WGL_SWAP_EXCHANGE_ARB 0x2028 365 | #define WGL_SWAP_COPY_ARB 0x2029 366 | #define WGL_SWAP_UNDEFINED_ARB 0x202A 367 | #define WGL_TYPE_RGBA_ARB 0x202B 368 | #define WGL_TYPE_COLORINDEX_ARB 0x202C 369 | #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 370 | #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 371 | #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 372 | #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A 373 | #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B 374 | 375 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 376 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); 377 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); 378 | 379 | #define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) 380 | #define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) 381 | #define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) 382 | 383 | #define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) 384 | 385 | #endif /* WGL_ARB_pixel_format */ 386 | 387 | /* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ 388 | 389 | #ifndef WGL_ARB_pixel_format_float 390 | #define WGL_ARB_pixel_format_float 1 391 | 392 | #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 393 | 394 | #define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) 395 | 396 | #endif /* WGL_ARB_pixel_format_float */ 397 | 398 | /* ------------------------- WGL_ARB_render_texture ------------------------ */ 399 | 400 | #ifndef WGL_ARB_render_texture 401 | #define WGL_ARB_render_texture 1 402 | 403 | #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 404 | #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 405 | #define WGL_TEXTURE_FORMAT_ARB 0x2072 406 | #define WGL_TEXTURE_TARGET_ARB 0x2073 407 | #define WGL_MIPMAP_TEXTURE_ARB 0x2074 408 | #define WGL_TEXTURE_RGB_ARB 0x2075 409 | #define WGL_TEXTURE_RGBA_ARB 0x2076 410 | #define WGL_NO_TEXTURE_ARB 0x2077 411 | #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 412 | #define WGL_TEXTURE_1D_ARB 0x2079 413 | #define WGL_TEXTURE_2D_ARB 0x207A 414 | #define WGL_MIPMAP_LEVEL_ARB 0x207B 415 | #define WGL_CUBE_MAP_FACE_ARB 0x207C 416 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D 417 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E 418 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F 419 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 420 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 421 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 422 | #define WGL_FRONT_LEFT_ARB 0x2083 423 | #define WGL_FRONT_RIGHT_ARB 0x2084 424 | #define WGL_BACK_LEFT_ARB 0x2085 425 | #define WGL_BACK_RIGHT_ARB 0x2086 426 | #define WGL_AUX0_ARB 0x2087 427 | #define WGL_AUX1_ARB 0x2088 428 | #define WGL_AUX2_ARB 0x2089 429 | #define WGL_AUX3_ARB 0x208A 430 | #define WGL_AUX4_ARB 0x208B 431 | #define WGL_AUX5_ARB 0x208C 432 | #define WGL_AUX6_ARB 0x208D 433 | #define WGL_AUX7_ARB 0x208E 434 | #define WGL_AUX8_ARB 0x208F 435 | #define WGL_AUX9_ARB 0x2090 436 | 437 | typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 438 | typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 439 | typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); 440 | 441 | #define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) 442 | #define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) 443 | #define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) 444 | 445 | #define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) 446 | 447 | #endif /* WGL_ARB_render_texture */ 448 | 449 | /* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ 450 | 451 | #ifndef WGL_ATI_pixel_format_float 452 | #define WGL_ATI_pixel_format_float 1 453 | 454 | #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 455 | #define GL_RGBA_FLOAT_MODE_ATI 0x8820 456 | #define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 457 | 458 | #define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) 459 | 460 | #endif /* WGL_ATI_pixel_format_float */ 461 | 462 | /* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ 463 | 464 | #ifndef WGL_ATI_render_texture_rectangle 465 | #define WGL_ATI_render_texture_rectangle 1 466 | 467 | #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 468 | 469 | #define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) 470 | 471 | #endif /* WGL_ATI_render_texture_rectangle */ 472 | 473 | /* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ 474 | 475 | #ifndef WGL_EXT_create_context_es2_profile 476 | #define WGL_EXT_create_context_es2_profile 1 477 | 478 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 479 | 480 | #define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) 481 | 482 | #endif /* WGL_EXT_create_context_es2_profile */ 483 | 484 | /* ------------------- WGL_EXT_create_context_es_profile ------------------- */ 485 | 486 | #ifndef WGL_EXT_create_context_es_profile 487 | #define WGL_EXT_create_context_es_profile 1 488 | 489 | #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 490 | 491 | #define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile) 492 | 493 | #endif /* WGL_EXT_create_context_es_profile */ 494 | 495 | /* -------------------------- WGL_EXT_depth_float -------------------------- */ 496 | 497 | #ifndef WGL_EXT_depth_float 498 | #define WGL_EXT_depth_float 1 499 | 500 | #define WGL_DEPTH_FLOAT_EXT 0x2040 501 | 502 | #define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) 503 | 504 | #endif /* WGL_EXT_depth_float */ 505 | 506 | /* ---------------------- WGL_EXT_display_color_table ---------------------- */ 507 | 508 | #ifndef WGL_EXT_display_color_table 509 | #define WGL_EXT_display_color_table 1 510 | 511 | typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); 512 | typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); 513 | typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); 514 | typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); 515 | 516 | #define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) 517 | #define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) 518 | #define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) 519 | #define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) 520 | 521 | #define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) 522 | 523 | #endif /* WGL_EXT_display_color_table */ 524 | 525 | /* ----------------------- WGL_EXT_extensions_string ----------------------- */ 526 | 527 | #ifndef WGL_EXT_extensions_string 528 | #define WGL_EXT_extensions_string 1 529 | 530 | typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); 531 | 532 | #define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) 533 | 534 | #define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) 535 | 536 | #endif /* WGL_EXT_extensions_string */ 537 | 538 | /* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ 539 | 540 | #ifndef WGL_EXT_framebuffer_sRGB 541 | #define WGL_EXT_framebuffer_sRGB 1 542 | 543 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 544 | 545 | #define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) 546 | 547 | #endif /* WGL_EXT_framebuffer_sRGB */ 548 | 549 | /* ----------------------- WGL_EXT_make_current_read ----------------------- */ 550 | 551 | #ifndef WGL_EXT_make_current_read 552 | #define WGL_EXT_make_current_read 1 553 | 554 | #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 555 | 556 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); 557 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 558 | 559 | #define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) 560 | #define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) 561 | 562 | #define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) 563 | 564 | #endif /* WGL_EXT_make_current_read */ 565 | 566 | /* -------------------------- WGL_EXT_multisample -------------------------- */ 567 | 568 | #ifndef WGL_EXT_multisample 569 | #define WGL_EXT_multisample 1 570 | 571 | #define WGL_SAMPLE_BUFFERS_EXT 0x2041 572 | #define WGL_SAMPLES_EXT 0x2042 573 | 574 | #define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) 575 | 576 | #endif /* WGL_EXT_multisample */ 577 | 578 | /* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ 579 | 580 | #ifndef WGL_EXT_pbuffer 581 | #define WGL_EXT_pbuffer 1 582 | 583 | #define WGL_DRAW_TO_PBUFFER_EXT 0x202D 584 | #define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E 585 | #define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F 586 | #define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 587 | #define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 588 | #define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 589 | #define WGL_PBUFFER_LARGEST_EXT 0x2033 590 | #define WGL_PBUFFER_WIDTH_EXT 0x2034 591 | #define WGL_PBUFFER_HEIGHT_EXT 0x2035 592 | 593 | DECLARE_HANDLE(HPBUFFEREXT); 594 | 595 | typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); 596 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); 597 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); 598 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); 599 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); 600 | 601 | #define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) 602 | #define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) 603 | #define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) 604 | #define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) 605 | #define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) 606 | 607 | #define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) 608 | 609 | #endif /* WGL_EXT_pbuffer */ 610 | 611 | /* -------------------------- WGL_EXT_pixel_format ------------------------- */ 612 | 613 | #ifndef WGL_EXT_pixel_format 614 | #define WGL_EXT_pixel_format 1 615 | 616 | #define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 617 | #define WGL_DRAW_TO_WINDOW_EXT 0x2001 618 | #define WGL_DRAW_TO_BITMAP_EXT 0x2002 619 | #define WGL_ACCELERATION_EXT 0x2003 620 | #define WGL_NEED_PALETTE_EXT 0x2004 621 | #define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 622 | #define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 623 | #define WGL_SWAP_METHOD_EXT 0x2007 624 | #define WGL_NUMBER_OVERLAYS_EXT 0x2008 625 | #define WGL_NUMBER_UNDERLAYS_EXT 0x2009 626 | #define WGL_TRANSPARENT_EXT 0x200A 627 | #define WGL_TRANSPARENT_VALUE_EXT 0x200B 628 | #define WGL_SHARE_DEPTH_EXT 0x200C 629 | #define WGL_SHARE_STENCIL_EXT 0x200D 630 | #define WGL_SHARE_ACCUM_EXT 0x200E 631 | #define WGL_SUPPORT_GDI_EXT 0x200F 632 | #define WGL_SUPPORT_OPENGL_EXT 0x2010 633 | #define WGL_DOUBLE_BUFFER_EXT 0x2011 634 | #define WGL_STEREO_EXT 0x2012 635 | #define WGL_PIXEL_TYPE_EXT 0x2013 636 | #define WGL_COLOR_BITS_EXT 0x2014 637 | #define WGL_RED_BITS_EXT 0x2015 638 | #define WGL_RED_SHIFT_EXT 0x2016 639 | #define WGL_GREEN_BITS_EXT 0x2017 640 | #define WGL_GREEN_SHIFT_EXT 0x2018 641 | #define WGL_BLUE_BITS_EXT 0x2019 642 | #define WGL_BLUE_SHIFT_EXT 0x201A 643 | #define WGL_ALPHA_BITS_EXT 0x201B 644 | #define WGL_ALPHA_SHIFT_EXT 0x201C 645 | #define WGL_ACCUM_BITS_EXT 0x201D 646 | #define WGL_ACCUM_RED_BITS_EXT 0x201E 647 | #define WGL_ACCUM_GREEN_BITS_EXT 0x201F 648 | #define WGL_ACCUM_BLUE_BITS_EXT 0x2020 649 | #define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 650 | #define WGL_DEPTH_BITS_EXT 0x2022 651 | #define WGL_STENCIL_BITS_EXT 0x2023 652 | #define WGL_AUX_BUFFERS_EXT 0x2024 653 | #define WGL_NO_ACCELERATION_EXT 0x2025 654 | #define WGL_GENERIC_ACCELERATION_EXT 0x2026 655 | #define WGL_FULL_ACCELERATION_EXT 0x2027 656 | #define WGL_SWAP_EXCHANGE_EXT 0x2028 657 | #define WGL_SWAP_COPY_EXT 0x2029 658 | #define WGL_SWAP_UNDEFINED_EXT 0x202A 659 | #define WGL_TYPE_RGBA_EXT 0x202B 660 | #define WGL_TYPE_COLORINDEX_EXT 0x202C 661 | 662 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 663 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); 664 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); 665 | 666 | #define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) 667 | #define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) 668 | #define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) 669 | 670 | #define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) 671 | 672 | #endif /* WGL_EXT_pixel_format */ 673 | 674 | /* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ 675 | 676 | #ifndef WGL_EXT_pixel_format_packed_float 677 | #define WGL_EXT_pixel_format_packed_float 1 678 | 679 | #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 680 | 681 | #define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) 682 | 683 | #endif /* WGL_EXT_pixel_format_packed_float */ 684 | 685 | /* -------------------------- WGL_EXT_swap_control ------------------------- */ 686 | 687 | #ifndef WGL_EXT_swap_control 688 | #define WGL_EXT_swap_control 1 689 | 690 | typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); 691 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); 692 | 693 | #define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) 694 | #define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) 695 | 696 | #define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) 697 | 698 | #endif /* WGL_EXT_swap_control */ 699 | 700 | /* ----------------------- WGL_EXT_swap_control_tear ----------------------- */ 701 | 702 | #ifndef WGL_EXT_swap_control_tear 703 | #define WGL_EXT_swap_control_tear 1 704 | 705 | #define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear) 706 | 707 | #endif /* WGL_EXT_swap_control_tear */ 708 | 709 | /* --------------------- WGL_I3D_digital_video_control --------------------- */ 710 | 711 | #ifndef WGL_I3D_digital_video_control 712 | #define WGL_I3D_digital_video_control 1 713 | 714 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 715 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 716 | #define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 717 | #define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 718 | 719 | typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); 720 | typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); 721 | 722 | #define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) 723 | #define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) 724 | 725 | #define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) 726 | 727 | #endif /* WGL_I3D_digital_video_control */ 728 | 729 | /* ----------------------------- WGL_I3D_gamma ----------------------------- */ 730 | 731 | #ifndef WGL_I3D_gamma 732 | #define WGL_I3D_gamma 1 733 | 734 | #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E 735 | #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F 736 | 737 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); 738 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); 739 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); 740 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); 741 | 742 | #define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) 743 | #define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) 744 | #define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) 745 | #define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) 746 | 747 | #define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) 748 | 749 | #endif /* WGL_I3D_gamma */ 750 | 751 | /* ---------------------------- WGL_I3D_genlock ---------------------------- */ 752 | 753 | #ifndef WGL_I3D_genlock 754 | #define WGL_I3D_genlock 1 755 | 756 | #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 757 | #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 758 | #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 759 | #define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 760 | #define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 761 | #define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 762 | #define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A 763 | #define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B 764 | #define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C 765 | 766 | typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); 767 | typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); 768 | typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); 769 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); 770 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); 771 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); 772 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); 773 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); 774 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); 775 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); 776 | typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); 777 | typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); 778 | 779 | #define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) 780 | #define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) 781 | #define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) 782 | #define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) 783 | #define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) 784 | #define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) 785 | #define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) 786 | #define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) 787 | #define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) 788 | #define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) 789 | #define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) 790 | #define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) 791 | 792 | #define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) 793 | 794 | #endif /* WGL_I3D_genlock */ 795 | 796 | /* -------------------------- WGL_I3D_image_buffer ------------------------- */ 797 | 798 | #ifndef WGL_I3D_image_buffer 799 | #define WGL_I3D_image_buffer 1 800 | 801 | #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 802 | #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 803 | 804 | typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); 805 | typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); 806 | typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); 807 | typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); 808 | 809 | #define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) 810 | #define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) 811 | #define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) 812 | #define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) 813 | 814 | #define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) 815 | 816 | #endif /* WGL_I3D_image_buffer */ 817 | 818 | /* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ 819 | 820 | #ifndef WGL_I3D_swap_frame_lock 821 | #define WGL_I3D_swap_frame_lock 1 822 | 823 | typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); 824 | typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); 825 | typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); 826 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); 827 | 828 | #define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) 829 | #define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) 830 | #define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) 831 | #define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) 832 | 833 | #define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) 834 | 835 | #endif /* WGL_I3D_swap_frame_lock */ 836 | 837 | /* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ 838 | 839 | #ifndef WGL_I3D_swap_frame_usage 840 | #define WGL_I3D_swap_frame_usage 1 841 | 842 | typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); 843 | typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); 844 | typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); 845 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 846 | 847 | #define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) 848 | #define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) 849 | #define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) 850 | #define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) 851 | 852 | #define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) 853 | 854 | #endif /* WGL_I3D_swap_frame_usage */ 855 | 856 | /* --------------------------- WGL_NV_DX_interop --------------------------- */ 857 | 858 | #ifndef WGL_NV_DX_interop 859 | #define WGL_NV_DX_interop 1 860 | 861 | #define WGL_ACCESS_READ_ONLY_NV 0x0000 862 | #define WGL_ACCESS_READ_WRITE_NV 0x0001 863 | #define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 864 | 865 | typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); 866 | typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); 867 | typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); 868 | typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); 869 | typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); 870 | typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); 871 | typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); 872 | typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); 873 | 874 | #define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) 875 | #define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) 876 | #define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) 877 | #define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) 878 | #define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) 879 | #define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) 880 | #define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) 881 | #define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) 882 | 883 | #define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) 884 | 885 | #endif /* WGL_NV_DX_interop */ 886 | 887 | /* --------------------------- WGL_NV_DX_interop2 -------------------------- */ 888 | 889 | #ifndef WGL_NV_DX_interop2 890 | #define WGL_NV_DX_interop2 1 891 | 892 | #define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2) 893 | 894 | #endif /* WGL_NV_DX_interop2 */ 895 | 896 | /* --------------------------- WGL_NV_copy_image --------------------------- */ 897 | 898 | #ifndef WGL_NV_copy_image 899 | #define WGL_NV_copy_image 1 900 | 901 | typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 902 | 903 | #define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) 904 | 905 | #define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) 906 | 907 | #endif /* WGL_NV_copy_image */ 908 | 909 | /* -------------------------- WGL_NV_float_buffer -------------------------- */ 910 | 911 | #ifndef WGL_NV_float_buffer 912 | #define WGL_NV_float_buffer 1 913 | 914 | #define WGL_FLOAT_COMPONENTS_NV 0x20B0 915 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 916 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 917 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 918 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 919 | #define WGL_TEXTURE_FLOAT_R_NV 0x20B5 920 | #define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 921 | #define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 922 | #define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 923 | 924 | #define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) 925 | 926 | #endif /* WGL_NV_float_buffer */ 927 | 928 | /* -------------------------- WGL_NV_gpu_affinity -------------------------- */ 929 | 930 | #ifndef WGL_NV_gpu_affinity 931 | #define WGL_NV_gpu_affinity 1 932 | 933 | #define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 934 | #define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 935 | 936 | DECLARE_HANDLE(HGPUNV); 937 | typedef struct _GPU_DEVICE { 938 | DWORD cb; 939 | CHAR DeviceName[32]; 940 | CHAR DeviceString[128]; 941 | DWORD Flags; 942 | RECT rcVirtualScreen; 943 | } GPU_DEVICE, *PGPU_DEVICE; 944 | 945 | typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); 946 | typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); 947 | typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 948 | typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 949 | typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); 950 | 951 | #define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) 952 | #define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) 953 | #define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) 954 | #define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) 955 | #define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) 956 | 957 | #define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) 958 | 959 | #endif /* WGL_NV_gpu_affinity */ 960 | 961 | /* ---------------------- WGL_NV_multisample_coverage ---------------------- */ 962 | 963 | #ifndef WGL_NV_multisample_coverage 964 | #define WGL_NV_multisample_coverage 1 965 | 966 | #define WGL_COVERAGE_SAMPLES_NV 0x2042 967 | #define WGL_COLOR_SAMPLES_NV 0x20B9 968 | 969 | #define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) 970 | 971 | #endif /* WGL_NV_multisample_coverage */ 972 | 973 | /* -------------------------- WGL_NV_present_video ------------------------- */ 974 | 975 | #ifndef WGL_NV_present_video 976 | #define WGL_NV_present_video 1 977 | 978 | #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 979 | 980 | DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); 981 | 982 | typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); 983 | typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); 984 | typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); 985 | 986 | #define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) 987 | #define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) 988 | #define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) 989 | 990 | #define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) 991 | 992 | #endif /* WGL_NV_present_video */ 993 | 994 | /* ---------------------- WGL_NV_render_depth_texture ---------------------- */ 995 | 996 | #ifndef WGL_NV_render_depth_texture 997 | #define WGL_NV_render_depth_texture 1 998 | 999 | #define WGL_NO_TEXTURE_ARB 0x2077 1000 | #define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 1001 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 1002 | #define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 1003 | #define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 1004 | #define WGL_DEPTH_COMPONENT_NV 0x20A7 1005 | 1006 | #define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) 1007 | 1008 | #endif /* WGL_NV_render_depth_texture */ 1009 | 1010 | /* -------------------- WGL_NV_render_texture_rectangle -------------------- */ 1011 | 1012 | #ifndef WGL_NV_render_texture_rectangle 1013 | #define WGL_NV_render_texture_rectangle 1 1014 | 1015 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 1016 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 1017 | #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 1018 | 1019 | #define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) 1020 | 1021 | #endif /* WGL_NV_render_texture_rectangle */ 1022 | 1023 | /* --------------------------- WGL_NV_swap_group --------------------------- */ 1024 | 1025 | #ifndef WGL_NV_swap_group 1026 | #define WGL_NV_swap_group 1 1027 | 1028 | typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); 1029 | typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); 1030 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); 1031 | typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); 1032 | typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); 1033 | typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); 1034 | 1035 | #define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) 1036 | #define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) 1037 | #define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) 1038 | #define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) 1039 | #define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) 1040 | #define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) 1041 | 1042 | #define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) 1043 | 1044 | #endif /* WGL_NV_swap_group */ 1045 | 1046 | /* ----------------------- WGL_NV_vertex_array_range ----------------------- */ 1047 | 1048 | #ifndef WGL_NV_vertex_array_range 1049 | #define WGL_NV_vertex_array_range 1 1050 | 1051 | typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); 1052 | typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); 1053 | 1054 | #define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) 1055 | #define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) 1056 | 1057 | #define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) 1058 | 1059 | #endif /* WGL_NV_vertex_array_range */ 1060 | 1061 | /* -------------------------- WGL_NV_video_capture ------------------------- */ 1062 | 1063 | #ifndef WGL_NV_video_capture 1064 | #define WGL_NV_video_capture 1 1065 | 1066 | #define WGL_UNIQUE_ID_NV 0x20CE 1067 | #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF 1068 | 1069 | DECLARE_HANDLE(HVIDEOINPUTDEVICENV); 1070 | 1071 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 1072 | typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList); 1073 | typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 1074 | typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue); 1075 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 1076 | 1077 | #define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) 1078 | #define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) 1079 | #define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) 1080 | #define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) 1081 | #define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) 1082 | 1083 | #define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) 1084 | 1085 | #endif /* WGL_NV_video_capture */ 1086 | 1087 | /* -------------------------- WGL_NV_video_output -------------------------- */ 1088 | 1089 | #ifndef WGL_NV_video_output 1090 | #define WGL_NV_video_output 1 1091 | 1092 | #define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 1093 | #define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 1094 | #define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 1095 | #define WGL_VIDEO_OUT_COLOR_NV 0x20C3 1096 | #define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 1097 | #define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 1098 | #define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 1099 | #define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 1100 | #define WGL_VIDEO_OUT_FRAME 0x20C8 1101 | #define WGL_VIDEO_OUT_FIELD_1 0x20C9 1102 | #define WGL_VIDEO_OUT_FIELD_2 0x20CA 1103 | #define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB 1104 | #define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC 1105 | 1106 | DECLARE_HANDLE(HPVIDEODEV); 1107 | 1108 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 1109 | typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); 1110 | typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 1111 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); 1112 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); 1113 | typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); 1114 | 1115 | #define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) 1116 | #define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) 1117 | #define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) 1118 | #define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) 1119 | #define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) 1120 | #define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) 1121 | 1122 | #define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) 1123 | 1124 | #endif /* WGL_NV_video_output */ 1125 | 1126 | /* -------------------------- WGL_OML_sync_control ------------------------- */ 1127 | 1128 | #ifndef WGL_OML_sync_control 1129 | #define WGL_OML_sync_control 1 1130 | 1131 | typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); 1132 | typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); 1133 | typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 1134 | typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 1135 | typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); 1136 | typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); 1137 | 1138 | #define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) 1139 | #define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) 1140 | #define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) 1141 | #define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) 1142 | #define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) 1143 | #define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) 1144 | 1145 | #define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) 1146 | 1147 | #endif /* WGL_OML_sync_control */ 1148 | 1149 | /* ------------------------------------------------------------------------- */ 1150 | 1151 | #ifdef GLEW_MX 1152 | #define WGLEW_FUN_EXPORT 1153 | #define WGLEW_VAR_EXPORT 1154 | #else 1155 | #define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT 1156 | #define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT 1157 | #endif /* GLEW_MX */ 1158 | 1159 | #ifdef GLEW_MX 1160 | struct WGLEWContextStruct 1161 | { 1162 | #endif /* GLEW_MX */ 1163 | 1164 | WGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; 1165 | 1166 | WGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; 1167 | WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; 1168 | WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; 1169 | WGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; 1170 | WGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; 1171 | WGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; 1172 | WGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; 1173 | WGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; 1174 | WGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; 1175 | 1176 | WGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; 1177 | WGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; 1178 | WGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; 1179 | WGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; 1180 | 1181 | WGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; 1182 | 1183 | WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; 1184 | 1185 | WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; 1186 | WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; 1187 | 1188 | WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; 1189 | WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; 1190 | WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; 1191 | WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; 1192 | WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; 1193 | 1194 | WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; 1195 | WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; 1196 | WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; 1197 | 1198 | WGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; 1199 | WGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; 1200 | WGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; 1201 | 1202 | WGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; 1203 | WGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; 1204 | WGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; 1205 | WGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; 1206 | 1207 | WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; 1208 | 1209 | WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; 1210 | WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; 1211 | 1212 | WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; 1213 | WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; 1214 | WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; 1215 | WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; 1216 | WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; 1217 | 1218 | WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; 1219 | WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; 1220 | WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; 1221 | 1222 | WGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; 1223 | WGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; 1224 | 1225 | WGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; 1226 | WGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; 1227 | 1228 | WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; 1229 | WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; 1230 | WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; 1231 | WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; 1232 | 1233 | WGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; 1234 | WGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; 1235 | WGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; 1236 | WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; 1237 | WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; 1238 | WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; 1239 | WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; 1240 | WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; 1241 | WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; 1242 | WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; 1243 | WGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; 1244 | WGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; 1245 | 1246 | WGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; 1247 | WGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; 1248 | WGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; 1249 | WGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; 1250 | 1251 | WGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; 1252 | WGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; 1253 | WGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; 1254 | WGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; 1255 | 1256 | WGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; 1257 | WGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; 1258 | WGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; 1259 | WGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; 1260 | 1261 | WGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; 1262 | WGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; 1263 | WGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; 1264 | WGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; 1265 | WGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; 1266 | WGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; 1267 | WGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; 1268 | WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; 1269 | 1270 | WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; 1271 | 1272 | WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; 1273 | WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; 1274 | WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; 1275 | WGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; 1276 | WGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; 1277 | 1278 | WGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; 1279 | WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; 1280 | WGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; 1281 | 1282 | WGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; 1283 | WGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; 1284 | WGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; 1285 | WGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; 1286 | WGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; 1287 | WGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; 1288 | 1289 | WGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; 1290 | WGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; 1291 | 1292 | WGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; 1293 | WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; 1294 | WGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; 1295 | WGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; 1296 | WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; 1297 | 1298 | WGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; 1299 | WGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; 1300 | WGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; 1301 | WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; 1302 | WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; 1303 | WGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; 1304 | 1305 | WGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; 1306 | WGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; 1307 | WGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; 1308 | WGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; 1309 | WGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; 1310 | WGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; 1311 | WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample; 1312 | WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control; 1313 | WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association; 1314 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region; 1315 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context; 1316 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile; 1317 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; 1318 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string; 1319 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; 1320 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read; 1321 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample; 1322 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer; 1323 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format; 1324 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; 1325 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture; 1326 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; 1327 | WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; 1328 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; 1329 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile; 1330 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float; 1331 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table; 1332 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string; 1333 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; 1334 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read; 1335 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample; 1336 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer; 1337 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format; 1338 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; 1339 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control; 1340 | WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear; 1341 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control; 1342 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma; 1343 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock; 1344 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer; 1345 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; 1346 | WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; 1347 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop; 1348 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2; 1349 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image; 1350 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer; 1351 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity; 1352 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage; 1353 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video; 1354 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture; 1355 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; 1356 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group; 1357 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range; 1358 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture; 1359 | WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output; 1360 | WGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control; 1361 | 1362 | #ifdef GLEW_MX 1363 | }; /* WGLEWContextStruct */ 1364 | #endif /* GLEW_MX */ 1365 | 1366 | /* ------------------------------------------------------------------------- */ 1367 | 1368 | #ifdef GLEW_MX 1369 | 1370 | typedef struct WGLEWContextStruct WGLEWContext; 1371 | GLEWAPI GLenum GLEWAPIENTRY wglewContextInit (WGLEWContext *ctx); 1372 | GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, const char *name); 1373 | 1374 | #define wglewInit() wglewContextInit(wglewGetContext()) 1375 | #define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) 1376 | 1377 | #define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) 1378 | #define WGLEW_GET_FUN(x) wglewGetContext()->x 1379 | 1380 | #else /* GLEW_MX */ 1381 | 1382 | #define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) 1383 | #define WGLEW_GET_FUN(x) x 1384 | 1385 | GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name); 1386 | 1387 | #endif /* GLEW_MX */ 1388 | 1389 | GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name); 1390 | 1391 | #ifdef __cplusplus 1392 | } 1393 | #endif 1394 | 1395 | #undef GLEWAPI 1396 | 1397 | #endif /* __wglew_h__ */ 1398 | --------------------------------------------------------------------------------