PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core_WindowEvents/Win32D3D9/WindowData_DIRECTX9.cpp

http://github.com/Akranar/daguerreo
C++ | 103 lines | 35 code | 9 blank | 59 comment | 4 complexity | 346ce2579a49ddc1c52ad0fb9bba7a1d MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
  1
  2#include "WindowData_DIRECTX9.h"
  3#include <iostream>
  4
  5/*
  6#include <GL/gl.h>
  7#define GL_GLEXT_PROTOTYPES 1
  8#include <GL/glext.h>
  9#define WGL_WGLEXT_PROTOTYPES 1
 10#include "wglext.h" //downloaded from http://www.opengl.org/registry/api/wglext.h
 11*/
 12
 13std::map<HWND, WindowEvents *> * WindowData::handle_map_window = 0;
 14int WindowData::vsync = 1;
 15
 16WindowData::WindowData()
 17:
 18mouse_position_must_update(true)
 19{
 20	if (!handle_map_window)
 21	{
 22		handle_map_window = new std::map<HWND, WindowEvents *>;
 23	}
 24
 25}
 26
 27WindowData::~WindowData()
 28{
 29	handle_map_window->erase(handle_window);
 30	if (handle_map_window->empty())
 31	{
 32		delete handle_map_window;
 33		handle_map_window = 0;
 34	}
 35}
 36
 37WindowEvents * WindowData::FindWindowEvents(HWND & hWnd)
 38{
 39	std::map<HWND, WindowEvents *>::iterator it = handle_map_window->find(hWnd);
 40	if (it == handle_map_window->end())
 41	{
 42		return 0;
 43	}
 44	return it->second;
 45}
 46
 47static bool IsExtensionSupported(const char * extension_list, const char * extension)
 48{
 49	/*
 50	const char *start;
 51	const char *location, *terminator;
 52
 53	//Extension names should not have spaces.
 54	location = strchr(extension, ' ');
 55	if (location || *extension == '\0') return false;
 56
 57	//It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc.
 58	for (start = extension_list; ;)
 59	{
 60		location = strstr(start, extension);
 61		if (!location) break;
 62		terminator = location + strlen(extension);
 63		if (location == start || *(location - 1) == ' ')
 64		{
 65			if (*terminator == ' ' || *terminator == '\0') return true;
 66		}
 67		start = terminator;
 68	}
 69
 70	*/
 71	return false;
 72}
 73
 74/*
 75	VSync:
 76		-> http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=271567
 77			-> With GLX (X11), uses extension GLX_SGI_video_sync
 78			-> With Mac (CGL, Carbon and Cocoa), set swap internal to a none zero value:
 79				-> http://developer.apple.com/mac/library/d...1987-CH216-SW12
 80			-> With WGL (Windows), use extension WGL_EXT_swap_control
 81*/
 82/*
 83void WindowData::SetVSync(bool sync)
 84{
 85	
 86	typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
 87
 88	PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
 89
 90	PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
 91	if (wglGetExtensionsStringARB)
 92	{
 93		const char * extension_string = wglGetExtensionsStringARB(this->GetDeviceContext());
 94
 95		if (IsExtensionSupported(extension_string, "WGL_EXT_swap_control"))
 96		{
 97			wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
 98			wglSwapIntervalEXT(sync);
 99		}
100	}
101	
102}
103*/