osx fixes.
svn path=/trunk/tao/; revision=76426
This commit is contained in:
Родитель
b9ff9c3190
Коммит
dc8e8c62e0
|
@ -49,91 +49,91 @@ using System;
|
|||
using System.Threading;
|
||||
using Tao.Sdl;
|
||||
|
||||
namespace SdlExamples
|
||||
namespace SdlExamples
|
||||
{
|
||||
#region Class Documentation
|
||||
/// <summary>
|
||||
/// Simple Tao.Sdl Example
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Just draws a bunch of rectangles to the screen.
|
||||
/// To quit, you can close the window,
|
||||
/// press the Escape key or press the 'q' key
|
||||
/// <p>Written by David Hudson (jendave@yahoo.com)</p>
|
||||
/// <p>This is a reimplementation of an example
|
||||
/// written by Will Weisser (ogl@9mm.com)</p>
|
||||
/// </remarks>
|
||||
#endregion Class Documentation
|
||||
public class GfxPrimitives
|
||||
{
|
||||
#region Run()
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
#region Class Documentation
|
||||
/// <summary>
|
||||
/// Simple Tao.Sdl Example
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Just draws a bunch of rectangles to the screen.
|
||||
/// To quit, you can close the window,
|
||||
/// press the Escape key or press the 'q' key
|
||||
/// <p>Written by David Hudson (jendave@yahoo.com)</p>
|
||||
/// <p>This is a reimplementation of an example
|
||||
/// written by Will Weisser (ogl@9mm.com)</p>
|
||||
/// </remarks>
|
||||
#endregion Class Documentation
|
||||
public class GfxPrimitives
|
||||
{
|
||||
#region Run()
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
public static void Run()
|
||||
{
|
||||
int flags = (Sdl.SDL_HWSURFACE|Sdl.SDL_DOUBLEBUF|Sdl.SDL_ANYFORMAT);
|
||||
int bpp = 16;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
bool quitFlag = false;
|
||||
public static void Run()
|
||||
{
|
||||
int flags = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT);
|
||||
int bpp = 16;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
bool quitFlag = false;
|
||||
|
||||
Random rand = new Random();
|
||||
|
||||
//string musicFile = "Data/SdlExamples.Reactangles.sound.ogg";
|
||||
Random rand = new Random();
|
||||
|
||||
Sdl.SDL_Event evt;
|
||||
//string musicFile = "Data/SdlExamples.Reactangles.sound.ogg";
|
||||
|
||||
try
|
||||
{
|
||||
Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
|
||||
Sdl.SDL_WM_SetCaption("Tao.Sdl Example - GfxPrimitives", "");
|
||||
IntPtr surfacePtr = Sdl.SDL_SetVideoMode(
|
||||
width,
|
||||
height,
|
||||
bpp,
|
||||
flags);
|
||||
Sdl.SDL_Event evt;
|
||||
|
||||
Sdl.SDL_Rect rect2 =
|
||||
new Sdl.SDL_Rect(0,0, (short) width, (short) height);
|
||||
Sdl.SDL_SetClipRect(surfacePtr, ref rect2);
|
||||
while (quitFlag == false)
|
||||
{
|
||||
Sdl.SDL_PollEvent(out evt);
|
||||
try
|
||||
{
|
||||
Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
|
||||
Sdl.SDL_WM_SetCaption("Tao.Sdl Example - GfxPrimitives", "");
|
||||
IntPtr surfacePtr = Sdl.SDL_SetVideoMode(
|
||||
width,
|
||||
height,
|
||||
bpp,
|
||||
flags);
|
||||
|
||||
if (evt.type == Sdl.SDL_QUIT)
|
||||
{
|
||||
quitFlag = true;
|
||||
}
|
||||
else if (evt.type == Sdl.SDL_KEYDOWN)
|
||||
{
|
||||
if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE) ||
|
||||
(evt.key.keysym.sym == (int)Sdl.SDLK_q))
|
||||
{
|
||||
quitFlag = true;
|
||||
}
|
||||
}
|
||||
Sdl.SDL_Rect rect2 =
|
||||
new Sdl.SDL_Rect(0, 0, (short)width, (short)height);
|
||||
Sdl.SDL_SetClipRect(surfacePtr, ref rect2);
|
||||
while (quitFlag == false)
|
||||
{
|
||||
Sdl.SDL_PollEvent(out evt);
|
||||
|
||||
try
|
||||
{
|
||||
SdlGfx.filledCircleRGBA(surfacePtr, (short)rand.Next(10,width - 100),(short)rand.Next(10, height - 100), (short)rand.Next(10,100),(byte)rand.Next(255), (byte)rand.Next(255),(byte)rand.Next(255), (byte)rand.Next(255));
|
||||
Sdl.SDL_Flip(surfacePtr);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Sdl.SDL_Quit();
|
||||
throw;
|
||||
}
|
||||
if (evt.type == Sdl.SDL_QUIT)
|
||||
{
|
||||
quitFlag = true;
|
||||
}
|
||||
else if (evt.type == Sdl.SDL_KEYDOWN)
|
||||
{
|
||||
if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE) ||
|
||||
(evt.key.keysym.sym == (int)Sdl.SDLK_q))
|
||||
{
|
||||
quitFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SdlGfx.filledCircleRGBA(surfacePtr, (short)rand.Next(10, width - 100), (short)rand.Next(10, height - 100), (short)rand.Next(10, 100), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255), (byte)rand.Next(255));
|
||||
Sdl.SDL_Flip(surfacePtr);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Sdl.SDL_Quit();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Sdl.SDL_Quit();
|
||||
}
|
||||
}
|
||||
#endregion Run()
|
||||
}
|
||||
}
|
||||
#endregion Run()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace SdlExamples
|
|||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(283, 224);
|
||||
this.ClientSize = new System.Drawing.Size(287, 228);
|
||||
this.Controls.Add(this.btnRun);
|
||||
this.Controls.Add(this.lstExamples);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
|
|
|
@ -26,6 +26,7 @@ SOFTWARE.
|
|||
#endregion License
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -83,13 +84,29 @@ namespace Tao.Sdl
|
|||
[DllImport("/System/Library/Frameworks/Cocoa.framework/Cocoa", EntryPoint = "NSApplicationLoad")]
|
||||
private static extern void NSApplicationLoad();
|
||||
|
||||
[DllImport("libobjc.dylib", EntryPoint="objc_getClass")]
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("libobjc.dylib", EntryPoint = "objc_getClass")]
|
||||
public static extern int objc_getClass(string name);
|
||||
|
||||
[DllImport("libobjc.dylib", EntryPoint="sel_registerName")]
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("libobjc.dylib", EntryPoint = "sel_registerName")]
|
||||
public static extern int sel_registerName(string name);
|
||||
|
||||
[DllImport("libobjc.dylib", EntryPoint="objc_msgSend")]
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="cmd"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("libobjc.dylib", EntryPoint = "objc_msgSend")]
|
||||
public static extern int objc_msgSend(int self, int cmd);
|
||||
|
||||
#endregion Private Methods
|
||||
|
@ -5434,9 +5451,12 @@ namespace Tao.Sdl
|
|||
try
|
||||
{
|
||||
////Mac OSX code
|
||||
int NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
|
||||
objc_msgSend(NSAutoreleasePool, sel_registerName("new"));
|
||||
NSApplicationLoad();
|
||||
if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa"))
|
||||
{
|
||||
int NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
|
||||
objc_msgSend(NSAutoreleasePool, sel_registerName("new"));
|
||||
NSApplicationLoad();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -5518,10 +5538,13 @@ namespace Tao.Sdl
|
|||
{
|
||||
try
|
||||
{
|
||||
////Mac OSX code
|
||||
int NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
|
||||
objc_msgSend(NSAutoreleasePool, sel_registerName("new"));
|
||||
NSApplicationLoad();
|
||||
if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa"))
|
||||
{
|
||||
////Mac OSX code
|
||||
int NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
|
||||
objc_msgSend(NSAutoreleasePool, sel_registerName("new"));
|
||||
NSApplicationLoad();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче