[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
(import (rnrs) (ironscheme clr)) (clr-reference PresentationFramework) (clr-reference PresentationCore) (clr-reference System.Xaml) (clr-reference WindowsBase) (clr-using System.Windows) ;[System.STAThread] might be needed. (define app (clr-new Application)) (clr-call Application Run app (clr-new Window))
Unhandled CLR exception during evaluation: CLR Exception: System.InvalidOperationException System.InvalidOperationException: The calling thread must be STA, because many U I components require this. at System.Windows.Input.InputManager..ctor() at System.Windows.Input.InputManager.GetCurrentInputManagerImpl() at System.Windows.Input.KeyboardNavigation..ctor() at System.Windows.FrameworkElement.EnsureFrameworkServices() at System.Windows.FrameworkElement..ctor() at System.Windows.Controls.Control..ctor() at System.Windows.Window..ctor() at eval-core(003).$2() at #.psyntax.expander::compile-r6rs-top-level#anon#1#2$2505(CodeContext $cont ext) at #.ironscheme.exceptions::dynamic-wind(Object in, Object proc, Object out) at #.psyntax.main::load-port#1$2552(CodeContext $context) at #.ironscheme.exceptions::dynamic-wind(Object in, Object proc, Object out) at IronScheme.Runtime.Builtins.CallWithCurrentContinuation(Object fc1) at IronScheme.Runtime.R6RS.Exceptions.WithClrExceptionHandler(Object handler, Object thunk)
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine (+ 1 1)) (clr-static-call System.Console ReadLine)
2です。
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine "(- 6 2) = {0}" (- 6 2)) (clr-static-call System.Console WriteLine "(* 6 2) = {0}" (* 6 2)) (clr-static-call System.Console WriteLine "(/ 6 2) = {0}" (/ 6 2)) (clr-static-call System.Console ReadLine)
(- 6 2) = 4 (* 6 2) = 12 (/ 6 2) = 3
(import (rnrs) (ironscheme clr)) (clr-static-call System.Console WriteLine "(/ 7 2) = {0}" (/ 7 2)) (clr-static-call System.Console ReadLine)この結果は
(/ 7 2) = 7/2
(import (rnrs r5rs (6)) (ironscheme clr)) (clr-static-call System.Console WriteLine "(quotient 7 2) = {0}" (quotient 7 2)) (clr-static-call System.Console WriteLine "(modulo 7 2) = {0}" (modulo 7 2)) (clr-static-call System.Console WriteLine "(modulo 7 -2) = {0}" (modulo 7 -2)) (clr-static-call System.Console WriteLine "(modulo -7 2) = {0}" (modulo -7 2)) (clr-static-call System.Console WriteLine "(modulo -7 -2) = {0}" (modulo -7 -2)) (clr-static-call System.Console WriteLine "(remainder 7 2) = {0}" (remainder 7 2)) (clr-static-call System.Console WriteLine "(remainder 7 -2) = {0}" (remainder 7 -2)) (clr-static-call System.Console WriteLine "(remainder -7 2) = {0}" (remainder -7 2)) (clr-static-call System.Console WriteLine "(remainder -7 -2) = {0}" (remainder -7 -2)) (clr-static-call System.Console ReadLine)
(quotient 7 2) = 3 (modulo 7 2) = 1 (modulo 7 -2) = -1 (modulo -7 2) = 1 (modulo -7 -2) = -1 (remainder 7 2) = 1 (remainder 7 -2) = 1 (remainder -7 2) = -1 (remainder -7 -2) = -1
(import (ironscheme clr)) (clr-static-call System.Console WriteLine "Hello World!")
>(compile "helloworld.scm" #t)
(import (ironscheme clr)) (clr-static-call System.Console WriteLine "Hello World!") (clr-static-call System.Console ReadLine)
class Program { static void Main(string[] args) { System.Console.WriteLine("Hello World!"); System.Console.ReadLine(); } }
(関数名 引数1 引数2...)
(import (rnrs)) (display "Hello World!") (newline)
(import (rnrs)) (display "Hello World!") (newline) (get-line (current-input-port))
<UserControl x:Class="SilverlightXna06.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="2*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <TextBlock x:Name="textBlock" Grid.RowSpan="2"></TextBlock> <DrawingSurface Draw="DrawingSurface1_Draw"/> <DrawingSurface Draw="DrawingSurface2_Draw" Grid.Row="1" /> <sdk:Label Foreground="White" Name="label1"/> <sdk:Label Foreground="White" Name="label2" Grid.Row="1"/> </Grid> </UserControl>
using System.Windows.Controls; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Windows.Graphics; namespace SilverlightXna06 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); textBlock.Text = GpuError.Message; } GraphicsDevice GraphicsDevice { get { return GraphicsDeviceManager.Current.GraphicsDevice; } } private void DrawingSurface1_Draw(object sender, DrawEventArgs e) { GraphicsDevice.Clear(new Color(1f, 0, 0)); outputLog(label1); e.InvalidateSurface(); } private void DrawingSurface2_Draw(object sender, DrawEventArgs e) { GraphicsDevice.Clear(new Color(0, 0, 1f)); outputLog(label2); e.InvalidateSurface(); } private void outputLog(Label label) { var gpu = GraphicsDevice; var threadID = System.Threading.Thread.CurrentThread.ManagedThreadId; var viewport = gpu.Viewport; Dispatcher.BeginInvoke(delegate { label.Content = string.Format( "gpu:{0}, thread:{1}, viewport.Bounds:{2}", gpu.GetHashCode(), threadID, viewport.Bounds ); }); } } }GpuError.cs
using System.Windows.Graphics; namespace SilverlightXna06 { public class GpuError { public static bool ErrorExists { get { return GraphicsDeviceManager.Current.RenderMode != RenderMode.Hardware; } } public static string Message { get { if (!ErrorExists) { return ""; } string message; switch (GraphicsDeviceManager.Current.RenderModeReason) { case RenderModeReason.Not3DCapable: message = "あなたのグラフィックスハードウェアはこのページを表示出来ません"; break; case RenderModeReason.GPUAccelerationDisabled: message = "ハードウェアグラフィックスアクセラレーションがこのwebページでは有効にされていません。\n\n" + "webサイトのオーナーに通知してください"; break; case RenderModeReason.TemporarilyUnavailable: message = "あなたのグラフィックスハードウェアは一時的に使用不可能になっています。\n\n" + "webページをリロードするかブラウザを再起動してください。"; break; case RenderModeReason.SecurityBlocked: message = "webサイトが3Dグラフィックスを表示できるようにするには、システム構成を変える必要があります。\n\n" + " 1. ここを右クリックします。\n" + " 2. [Silverlight]を選択します\n" + " ([Microsoft Silverlight の構成ダイヤログ]が表示されます)\n" + " 3. [アクセス許可]タブを選択します\n" + " 4. このサイトをリストの中から見つけ、その3Dグラフィックスアクセス許可を[拒否]から[許可]に変えます\n" + " 5. [OK]をクリックします\n" + " 6. ページをリロードします"; break; default: message = "不明なエラー"; break; } return "3D表示がブロックされました!\n\n\n" + message; } } } }