Merge remote-tracking branch 'origin/master' into no-reflect

This commit is contained in:
Stefanos A 2013-12-05 14:53:37 +01:00
commit 0bdb871e90
14 changed files with 140 additions and 68 deletions

2
.gitignore vendored
View file

@ -6,6 +6,8 @@ Version.txt
Source/OpenTK/OpenTK.xml
Source/GLControl/OpenTK.GLControl.xml
Documentation/Source
opentk*.exe
opentk*.zip
# OpenTK Resource files that seem like they should be ignored:
Source/Compatibility/Properties/Resources.resources

View file

@ -52,7 +52,7 @@
<ReadLinesFromFile File="../../Version.txt">
<Output TaskParameter="Lines" ItemName="Version" />
</ReadLinesFromFile>
<Copy SourceFiles=".\opentk.exe" DestinationFiles="@(Version-&gt;'../../opentk-%(Identity).exe')" />
<Move SourceFiles=".\opentk.exe" DestinationFiles="@(Version-&gt;'../../opentk-%(Identity).exe')" />
</Target>
<Target Name="Clean">
<CreateItem Include=".\opentk.exe;..\..\opentk-*.exe">

View file

@ -10,9 +10,7 @@ SetCompressor /SOLID lzma
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "OpenTK"
!define PRODUCT_VERSION "1.0" ; To be replaced by Build.exe
;!define PRODUCT_VERSION_REVISION "{{revision}}" ; To be replaced by Build.exe
;!define PRODUCT_VERSION_EXTRA "{{extra}}" ; To be replaced by Build.exe
!define PRODUCT_VERSION "1.1" ; To be replaced by Build.exe
!define PRODUCT_PUBLISHER "The Open Toolkit team"
!define PRODUCT_WEB_SITE "http://www.opentk.com"
!define PRODUCT_UNINST_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
@ -177,40 +175,16 @@ Section "Source code" SEC02
File /r /x .svn /x obj /x opentk /x opentk-actual.* /x *.exe /x *.msi /x *.deb /x *.rpm /x *.zip ..\..\Installers
SectionEnd
Section "OpenAL drivers" SEC03
SetOutPath $INSTDIR\Installers\Dependencies
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/oalinst.exe oalinst.exe
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/oalinst-license.txt oalinst-license.txt
ExecShell "open" '"$INSTDIR\Installers\Dependencies\oalinst.exe"' /S
SectionEnd
Section "NShader plugin (VS2010)" SEC04
SetOutPath $INSTDIR\Installers\Dependencies
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/NShaderVS2010.vsix NShaderVS2010.vsix
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/nshader-license.txt nshader-license.txt
ExecShell "open" '"$INSTDIR\Installers\Dependencies\NShaderVS2010.vsix"'
SectionEnd
Section "NShader plugin (VS2008)" SEC05
SetOutPath $INSTDIR\Installers\Dependencies
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/NShaderVS2008.msi NShaderVS2008.msi
NSISdl::download /TIMEOUT=5000 http://www.opentk.net/files/dependencies/win32/nshader-license.txt nshader-license.txt
ExecShell "open" '"$INSTDIR\Installers\Dependencies\NShaderVS2008.msi"'
SectionEnd
Section -AdditionalIcons
SetOutPath $INSTDIR
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\OpenTK"
SetOutPath "$INSTDIR\Binaries\OpenTK\Release" ; Make sure the working directory is correct
CreateShortCut "$SMPROGRAMS\OpenTK\OpenTK Example Browser.lnk" "$INSTDIR\Binaries\OpenTK\Release\Examples.exe"
SetOutPath $INSTDIR
CreateShortCut "$SMPROGRAMS\OpenTK\Function Reference (PDF).lnk" "$INSTDIR\Documentation\Reference.pdf"
CreateShortCut "$SMPROGRAMS\OpenTK\Project Manual (PDF).lnk" "$INSTDIR\Documentation\Manual.pdf"
;CreateShortCut "$SMPROGRAMS\OpenTK\Release Notes.lnk" "$INSTDIR\Documentation\Release.txt"
;CreateShortCut "$SMPROGRAMS\OpenTK\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\OpenTK\OpenGL Reference.lnk" "$INSTDIR\Documentation\OpenGL 4.4 API Reference.pdf"
CreateShortCut "$SMPROGRAMS\OpenTK\Documentation.lnk" "$INSTDIR\Documentation\"
SectionEnd
Section -Post
@ -229,16 +203,10 @@ SectionEnd
LangString DESC_Section1 ${LANG_ENGLISH} "Installs the Open Toolkit library, documentation and samples."
LangString DESC_Section2 ${LANG_ENGLISH} "Installs the source code for the Open Toolkit library."
LangString DESC_Section3 ${LANG_ENGLISH} "Installs OpenAL sound drivers from Creative Inc. Required for OpenAL support."
LangString DESC_Section4 ${LANG_ENGLISH} "Adds support for GLSL syntax highlighting to Visual Studio 2010. Requires Professional edition or higher."
LangString DESC_Section5 ${LANG_ENGLISH} "Adds support for GLSL syntax highlighting to Visual Studio 2008. Requires Professional edition or higher."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(DESC_Section3)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $(DESC_Section4)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $(DESC_Section5)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function un.onUninstSuccess

View file

@ -15,7 +15,6 @@
<PropertyGroup>
<ProjectGuid>{ADC34399-7613-44D2-90B2-19250F06FE7B}</ProjectGuid>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<InputPath>..\..\</InputPath>
<OutputPath>.\opentk\</OutputPath>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -50,12 +49,12 @@
</PropertyGroup>
<Target Name="Build">
<!-- Zip the copy of the source tree -->
<Exec Command="7z a -tzip opentk.zip ../../* '-xr!opentk*.zip' '-xr!opentk*.exe' '-xr!.*' '-xr!obj' '-xr!Documentation/Source' '-xr!Automation' '-xr!*.suo' '-xr!*.pidb' '-xr!*.userprefs' '-xr!vshost*.exe'" />
<Exec Command="7z a -tzip opentk.zip ../../* -xr!opentk*.zip -xr!opentk*.exe -xr!.* -xr!obj -xr!bin -xr!Documentation/Source -xr!Automation -xr!*.suo -xr!*.pidb -xr!*.userprefs -xr!*vshost.exe* -xr!*.log" />
<!-- Copy the zip file to the root directory and add a date stamp -->
<ReadLinesFromFile File="../../Version.txt">
<Output TaskParameter="Lines" ItemName="Version" />
</ReadLinesFromFile>
<Copy SourceFiles=".\opentk.zip" DestinationFiles="@(Version-&gt;'..\..\opentk-%(Identity).zip')" />
<Move SourceFiles=".\opentk.zip" DestinationFiles="@(Version-&gt;'..\..\opentk-%(Identity).zip')" />
</Target>
<Target Name="Clean">
<CreateItem Include=".\opentk.zip;..\..\opentk-*.zip">

View file

@ -21,6 +21,7 @@ namespace Examples.Tests
{
static readonly Font TextFont = new Font(FontFamily.GenericSansSerif, 11);
Bitmap TextBitmap = new Bitmap(1024, 1024);
StringBuilder TypedText = new StringBuilder();
int texture;
bool mouse_in_window = false;
bool viewport_changed = true;
@ -33,7 +34,8 @@ namespace Examples.Tests
{
VSync = VSyncMode.On;
Keyboard.KeyRepeat = true;
Keyboard.KeyDown += KeyDownHandler;
KeyDown += KeyDownHandler;
KeyPress += KeyPressHandler;
MouseEnter += delegate { mouse_in_window = true; };
MouseLeave += delegate { mouse_in_window = false; };
@ -54,6 +56,14 @@ namespace Examples.Tests
}
}
private void KeyPressHandler(object sender, KeyPressEventArgs e)
{
if (TypedText.Length > 32)
TypedText.Remove(0, 1);
TypedText.Append(e.KeyChar);
}
void KeyDownHandler(object sender, KeyboardKeyEventArgs e)
{
switch (e.Key)
@ -222,10 +232,10 @@ namespace Examples.Tests
DrawString(gfx, String.Format("Window.Location: {0}, Size: {1}", Location, Size), line++);
DrawString(gfx, String.Format("Window: {{X={0},Y={1},Width={2},Height={3}}}", X, Y, Width, Height), line++);
DrawString(gfx, String.Format("Window.ClientRectangle: {0}", ClientRectangle), line++);
DrawString(gfx, TypedText.ToString(), line++);
DrawKeyboard(gfx, keyboard, line++);
DrawMouse(gfx, mouse, line++);
DrawJoysticks(gfx, Joysticks, line++);
}
}

View file

@ -165,15 +165,12 @@ namespace OpenTK
const int CS_VREDRAW = 0x1;
const int CS_HREDRAW = 0x2;
const int CS_OWNDC = 0x20;
const int WS_CLIPCHILDREN = 0x02000000;
const int WS_CLIPSIBLINGS = 0x04000000;
CreateParams cp = base.CreateParams;
if (Configuration.RunningOnWindows)
{
// Setup necessary class style for OpenGL on windows
cp.ClassStyle |= CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
cp.Style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
}
return cp;
}

View file

@ -999,12 +999,24 @@ namespace OpenTK
#endregion
#region OnKeyDownInternal
private void OnKeyDownInternal(object sender, KeyboardKeyEventArgs e) { OnKeyDown(e); }
#endregion
#region OnKeyPressInternal
private void OnKeyPressInternal(object sender, KeyPressEventArgs e) { OnKeyPress(e); }
#endregion
#region OnKeyUpInternal
private void OnKeyUpInternal(object sender, KeyboardKeyEventArgs e) { OnKeyUp(e); }
#endregion
#region OnMouseEnterInternal
private void OnMouseEnterInternal(object sender, EventArgs e) { OnMouseEnter(e); }
@ -1074,7 +1086,9 @@ namespace OpenTK
implementation.Disposed += OnDisposedInternal;
implementation.FocusedChanged += OnFocusedChangedInternal;
implementation.IconChanged += OnIconChangedInternal;
implementation.KeyDown += OnKeyDownInternal;
implementation.KeyPress += OnKeyPressInternal;
implementation.KeyUp += OnKeyUpInternal;
implementation.MouseEnter += OnMouseEnterInternal;
implementation.MouseLeave += OnMouseLeaveInternal;
implementation.Move += OnMoveInternal;
@ -1092,7 +1106,9 @@ namespace OpenTK
implementation.Disposed -= OnDisposedInternal;
implementation.FocusedChanged -= OnFocusedChangedInternal;
implementation.IconChanged -= OnIconChangedInternal;
implementation.KeyDown -= OnKeyDownInternal;
implementation.KeyPress -= OnKeyPressInternal;
implementation.KeyUp -= OnKeyUpInternal;
implementation.MouseEnter -= OnMouseEnterInternal;
implementation.MouseLeave -= OnMouseLeaveInternal;
implementation.Move -= OnMoveInternal;

View file

@ -37,6 +37,7 @@ using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using OpenTK;
using OpenTK.Input;
using System.Text;
namespace OpenTK.Platform.SDL2
{
@ -78,7 +79,10 @@ namespace OpenTK.Platform.SDL2
flags |= WindowFlags.OPENGL;
flags |= WindowFlags.RESIZABLE;
flags |= WindowFlags.HIDDEN;
if (Toolkit.Options.EnableHighResolution)
{
flags |= WindowFlags.ALLOW_HIGHDPI;
}
if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 ||
(flags & WindowFlags.FULLSCREEN) != 0)
@ -150,6 +154,14 @@ namespace OpenTK.Platform.SDL2
}
break;
case EventType.TEXTINPUT:
if (windows.TryGetValue(ev.Text.WindowID, out window))
{
ProcessTextInputEvent(window, ev.Text);
processed = true;
}
break;
case EventType.KEYDOWN:
case EventType.KEYUP:
if (windows.TryGetValue(ev.Key.WindowID, out window))
@ -214,9 +226,42 @@ namespace OpenTK.Platform.SDL2
{
bool key_pressed = ev.Key.State == State.Pressed;
var key = ev.Key.Keysym;
var args = new KeyboardKeyEventArgs()
{
Key = TranslateKey(key.Scancode),
ScanCode = (uint)key.Scancode
};
if (key_pressed)
window.KeyDown(window, args);
else
window.KeyUp(window, args);
//window.keyboard.SetKey(TranslateKey(key.scancode), (uint)key.scancode, key_pressed);
}
static unsafe void ProcessTextInputEvent(Sdl2NativeWindow window, TextInputEvent ev)
{
var keyPress = window.KeyPress;
if (keyPress != null)
{
var length = 0;
byte* pText = ev.Text;
while (*pText != 0)
{
length++;
pText++;
}
using (var stream = new System.IO.UnmanagedMemoryStream(ev.Text, length))
using (var reader = new System.IO.StreamReader(stream, Encoding.UTF8))
{
var text = reader.ReadToEnd();
foreach (var c in text)
{
keyPress(window, new KeyPressEventArgs(c));
}
}
}
}
static void ProcessMotionEvent(Sdl2NativeWindow window, Event ev)
{
float scale = window.ClientSize.Width / (float)window.Size.Width;

View file

@ -1623,6 +1623,7 @@ namespace OpenTK.Platform.Windows
internal const byte PFD_UNDERLAY_PLANE = unchecked((byte)-1);
// Device mode types (found in wingdi.h)
internal const int DM_LOGPIXELS = 0x00020000;
internal const int DM_BITSPERPEL = 0x00040000;
internal const int DM_PELSWIDTH = 0x00080000;
internal const int DM_PELSHEIGHT = 0x00100000;

View file

@ -124,10 +124,12 @@ namespace OpenTK.Platform.Windows
{
VerifyMode(dev1, monitor_mode);
float scale = GetScale(ref monitor_mode);
opentk_dev_current_res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
(int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
(int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
opentk_dev_primary =
(dev1.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None;
}
@ -138,9 +140,10 @@ namespace OpenTK.Platform.Windows
{
VerifyMode(dev1, monitor_mode);
float scale = GetScale(ref monitor_mode);
DisplayResolution res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
(int)(monitor_mode.Position.X / scale), (int)(monitor_mode.Position.Y / scale),
(int)(monitor_mode.PelsWidth / scale), (int)(monitor_mode.PelsHeight / scale),
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
opentk_dev_available_res.Add(res);
@ -167,6 +170,15 @@ namespace OpenTK.Platform.Windows
}
}
private float GetScale(ref DeviceMode monitor_mode)
{
float scale = 1.0f;
if ((monitor_mode.Fields & Constants.DM_LOGPIXELS) != 0)
{
scale = monitor_mode.LogPixels / 96.0f;
}
return scale;
}
static void VerifyMode(WindowsDisplayDevice device, DeviceMode mode)
{

View file

@ -49,6 +49,8 @@ namespace OpenTK.Platform.Windows
}
if (System.Environment.OSVersion.Version.Major >= 6)
{
if (Toolkit.Options.EnableHighResolution)
{
// Enable high-dpi support
// Only available on Windows Vista and higher
@ -56,6 +58,7 @@ namespace OpenTK.Platform.Windows
Debug.Print("SetProcessDPIAware() returned {0}", result);
}
}
}
#region IPlatformFactory Members

View file

@ -124,6 +124,12 @@ namespace OpenTK.Platform.Windows
// Move(this, EventArgs.Empty);
//};
int scale_width = width;
int scale_height = height;
int scale_x = x;
int scale_y = y;
if (Toolkit.Options.EnableHighResolution)
{
// CreateWindow takes values in pixels.
// According to the high-dpi guidelines,
// we need to scale these values by the
@ -131,16 +137,11 @@ namespace OpenTK.Platform.Windows
// Search MSDN for "How to Ensure That
// Your Application Displays Properly on
// High-DPI Displays"
int scale_width = ScaleX(width);
int scale_height = ScaleY(height);
int scale_x = x;
int scale_y = y;
// If width or height were scaled, re-calculate
// the x and y coordinates to compensate
if (width != scale_width)
scale_x = x - UnscaleX(scale_width - width);
if (height != scale_height)
scale_y = y - UnscaleY(scale_height - height);
scale_width = ScaleX(width);
scale_height = ScaleY(height);
scale_x = ScaleX(x);
scale_y = ScaleY(y);
}
// To avoid issues with Ati drivers on Windows 6+ with compositing enabled, the context will not be
// bound to the top-level window, but rather to a child window docked in the parent.

View file

@ -134,6 +134,7 @@ namespace OpenTK
{
initialized = true;
Configuration.Init(options);
Options = options;
// The actual initialization takes place in the
// platform-specific factory constructors.
@ -145,6 +146,12 @@ namespace OpenTK
#endregion
#region Internal Members
internal static ToolkitOptions Options { get; private set; }
#endregion
#region IDisposable Members
/// <summary>

View file

@ -68,6 +68,7 @@ namespace OpenTK
static ToolkitOptions()
{
Default = new ToolkitOptions();
Default.EnableHighResolution = true;
}
/// <summary>
@ -76,6 +77,16 @@ namespace OpenTK
/// </summary>
public PlatformBackend Backend { get; set; }
/// <summary>
/// Gets or sets a value indicating whether high
/// resolution modes are supported on high-DPI
/// ("Retina") displays. Enabled by default.
/// Set to false for applications that are not
/// DPI-aware (e.g. WinForms.)
/// </summary>
/// <seealso cref="http://msdn.microsoft.com/en-us/library/windows/desktop/ee308410(v=vs.85).aspx"/>
public bool EnableHighResolution { get; set; }
/// <summary>
/// Gets a <c>ToolkitOptions</c> instance with
/// default values.