約 2,851,522 件
https://w.atwiki.jp/sampleisbest/pages/526.html
開発環境 Microsoft Visual Studio Community 2017 実行環境 Microsoft Windows 10 Home (64bit) プロジェクトの種類 Visual C++ / 空のプロジェクト 参考 サウンド デバイスの列挙 コンソール版(dsenum_c) dsenum_c.cpp // マルチバイト文字セット // https //msdn.microsoft.com/ja-jp/library/cc354468.aspx #pragma comment(lib, "dsound") #include dsound.h #include stdio.h BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext) { printf("[%s][%s]\n", lpszDesc, lpszDrvName); return TRUE; } int main() { HRESULT hr = DirectSoundEnumerate(DSEnumProc, NULL); return 0; } 出力 [プライマリ サウンド ドライバー][] [EX-LD2071T (Intel SST Audio Device (WDM))][{0.0.0.00000000}.{0226a988-680d-43c9-b4e4-f71db4992a9c}] [スピーカー (Intel SST Audio Device (WDM))][{0.0.0.00000000}.{1dbfc4da-902e-4808-b91b-5381f6f64943}] ウィンドウ版(dsenum_w) dsenum_w.cpp // Unicode文字セット // https //msdn.microsoft.com/ja-jp/library/cc354468.aspx #pragma comment(lib, "dsound") #include windowsx.h #include dsound.h #include "Resource.h" INT_PTR CALLBACK MainDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); void Init(HWND hDlg); BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext); //// int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINDLG), NULL, MainDlg); return 0; } INT_PTR CALLBACK MainDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND switch (LOWORD(wParam)) { case IDCANCEL EndDialog(hDlg, IDCANCEL); break; } break; case WM_INITDIALOG Init(hDlg); break; default return FALSE; } return TRUE; } void Init(HWND hDlg) { HWND hCombo1 = GetDlgItem(hDlg, IDC_COMBO1); DirectSoundEnumerate(DSEnumProc, hCombo1); } BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext) { HWND hCombo = (HWND)lpContext; ComboBox_AddString(hCombo, lpszDesc); return TRUE; } Resource.h #define IDD_MAINDLG100 #define IDC_STATIC-1 #define IDC_COMBO11000 dsenum_w.rs // resource script #include windows.h #include "resource.h" IDD_MAINDLG DIALOGEX 100, 100, 320, 200 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "dsenum_w" FONT 9, "MS UI Gothic" BEGIN COMBOBOXIDC_COMBO1, 10, 10, 200, 100, CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP END
https://w.atwiki.jp/sampleisbest/pages/550.html
wsprintf.asm comment * MASM32 SDK ml /c /coff wsprintf.asm link /subsystem console wsprintf * includelib kernel32.lib includelib user32.lib .386 .model flat, stdcall option casemap none include windows.inc include kernel32.inc include user32.inc .const formatdb"%c %d %08X %s", 0dh, 0ah, 0 hellodb"hello", 0 .data? hConsoleOutputdd? writtendd? bufdb1024+1 dup (?) .code start invokeGetStdHandle, STD_OUTPUT_HANDLE movhConsoleOutput, eax invokewsprintfA, addr buf, addr format, * , -1, 123beefh, addr hello invokelstrlenA, addr buf invokeWriteConsoleA, hConsoleOutput, addr buf, eax, addr written, NULL invokeExitProcess, 0 end start
https://w.atwiki.jp/mybestapp/pages/15.html
test
https://w.atwiki.jp/sampleisbest/pages/64.html
開発環境 Microsoft Visual C++ 2010 Express (SP1) 実行環境 Microsoft Windows XP Home Edition (SP3) プロジェクトの種類 Win32 プロジェクト プロジェクト名 EnumFont アプリケーションの種類 Windows アプリケーション 追加のオプション 空のプロジェクト 文字セット Unicode EnumFont.c #include fcntl.h // _O_WTEXT #include io.h // _setmode #include stdio.h // _fileno #include tchar.h #include Windows.h #include "resource.h" #define LINE_HEIGHT 48 // 関数プロトタイプ宣言 LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme, DWORD FontType, LPARAM lParam); void OnCreate(HWND hWnd); void OnSize(HWND hWnd); void OnVScroll(HWND hWnd, WPARAM wParam, LPARAM lParam); void OnMouseWheel(HWND hWnd, WPARAM wParam, LPARAM lParam); int OnCommand(HWND hWnd, WPARAM wParam); void OnPaint(HWND hWnd); // グローバル変数 TCHARg_atcClassName[] = _T("EnumFont"); TCHARg_atcWindowName[] = _T("Enum Font"); SCROLLINFOg_siVert; LOGFONTg_aLogFont[512]; intg_iFontNum = 0; //============================================================================== int APIENTRY _tWinMain( HINSTANCEhInstance, HINSTANCEhPrevInstance, LPTSTRlpCmdLine, intnCmdShow) { WNDCLASSEXwcex; HWNDhWnd; MSGmsg; HACCELhAccelTable; _setmode(_fileno(stdout), _O_WTEXT); // ウィンドウクラスの登録 wcex.cbSize= sizeof wcex; wcex.style= CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc= WndProc; wcex.cbClsExtra= 0; wcex.cbWndExtra= 0; wcex.hInstance= hInstance; wcex.hIcon= LoadIcon(NULL, IDI_APPLICATION); wcex.hCursor= LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName= NULL; wcex.lpszClassName= g_atcClassName; wcex.hIconSm= LoadIcon(NULL, IDI_APPLICATION); if (RegisterClassEx( wcex) == 0) { return 0; } // ウィンドウの作成 hWnd = CreateWindow( g_atcClassName,// ClassName g_atcWindowName,// WindowName WS_OVERLAPPEDWINDOW | WS_VSCROLL,// Style CW_USEDEFAULT,// x 0,// y CW_USEDEFAULT,// Width 0,// Height NULL,// WndParent NULL,// Menu hInstance, NULL); if (hWnd == NULL) { return 0; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDR_MAINFRAME); while (GetMessage( msg, NULL, 0, 0)) { if (TranslateAccelerator(msg.hwnd, hAccelTable, msg) == 0) { TranslateMessage( msg); DispatchMessage( msg); } } return msg.wParam; } //------------------------------------------------------------------------------ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_PAINT OnPaint(hWnd); break; case WM_VSCROLL OnVScroll(hWnd, wParam, lParam); break; case WM_MOUSEWHEEL OnMouseWheel(hWnd, wParam, lParam); break; case WM_COMMAND if (OnCommand(hWnd, wParam)) { return DefWindowProc(hWnd, uMsg, wParam, lParam); } break; case WM_SIZE OnSize(hWnd); break; case WM_CREATE OnCreate(hWnd); break; case WM_DESTROY PostQuitMessage(0); break; default return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; } //------------------------------------------------------------------------------ int CALLBACK EnumFontFamExProc(const LOGFONT* lpelfe, const TEXTMETRIC* lpntme, DWORD FontType, LPARAM lParam) { _tprintf(_T("%d,%d,\t%d,%d,%d,%d,%d,%d,%d,\t%d,%d,%d,%d,\t%s\n"), lpelfe- lfHeight, lpelfe- lfWidth, lpelfe- lfEscapement, lpelfe- lfOrientation, lpelfe- lfWeight, lpelfe- lfItalic, lpelfe- lfUnderline, lpelfe- lfStrikeOut, lpelfe- lfCharSet, lpelfe- lfOutPrecision, lpelfe- lfClipPrecision, lpelfe- lfQuality, lpelfe- lfPitchAndFamily, lpelfe- lfFaceName); if (_countof(g_aLogFont) = g_iFontNum) { return 0;// 列挙停止 } if (g_iFontNum == 0 || _tcscmp(g_aLogFont[g_iFontNum - 1].lfFaceName, lpelfe- lfFaceName)) { g_aLogFont[g_iFontNum++] = *lpelfe; } return 1;// 列挙継続 } //------------------------------------------------------------------------------ void OnCreate(HWND hWnd) { HDChDC; LOGFONTlogfont; RECTrcClient; hDC = GetDC(NULL); ZeroMemory( logfont, sizeof logfont); logfont.lfCharSet = DEFAULT_CHARSET; EnumFontFamiliesEx(hDC, logfont, EnumFontFamExProc, 0, 0); ReleaseDC(NULL, hDC); GetClientRect(hWnd, rcClient); g_siVert.cbSize= sizeof g_siVert; g_siVert.fMask= SIF_RANGE | SIF_PAGE | SIF_POS | SIF_DISABLENOSCROLL; g_siVert.nMin= 0; g_siVert.nMax= LINE_HEIGHT * g_iFontNum - 1; g_siVert.nPage= rcClient.bottom; g_siVert.nPos= 0; SetScrollInfo(hWnd, SB_VERT, g_siVert, FALSE); } //------------------------------------------------------------------------------ void OnSize(HWND hWnd) { RECTrcClient; intiPosMax; GetClientRect(hWnd, rcClient); g_siVert.nPage= rcClient.bottom; iPosMax = g_siVert.nMax - g_siVert.nPage + 1; if (iPosMax 0) { iPosMax = 0; } if (iPosMax g_siVert.nPos) { g_siVert.nPos = iPosMax; } SetScrollInfo(hWnd, SB_VERT, g_siVert, TRUE); } //------------------------------------------------------------------------------ // (HWND)lParam handle to scroll bar void OnVScroll(HWND hWnd, WPARAM wParam, LPARAM lParam) { SCROLLINFOsi; intiPos; intiPosMax; iPos = g_siVert.nPos; iPosMax = g_siVert.nMax - g_siVert.nPage + 1; switch (LOWORD(wParam)) { case SB_LINEUP // 0 iPos -= LINE_HEIGHT; break; case SB_LINEDOWN // 1 iPos += LINE_HEIGHT; break; case SB_PAGEUP // 2 iPos -= g_siVert.nPage; break; case SB_PAGEDOWN // 3 iPos += g_siVert.nPage; break; case SB_THUMBTRACK // 5 si.cbSize= sizeof si; si.fMask= SIF_TRACKPOS; if (GetScrollInfo(hWnd, SB_VERT, si) != 0) { iPos = si.nTrackPos; } break; case SB_TOP // 6 iPos = 0; break; case SB_BOTTOM // 7 iPos = iPosMax; break; } iPos = min(iPos, iPosMax); iPos = max(iPos, 0); if (iPos == g_siVert.nPos) { return; } ScrollWindowEx(hWnd, 0, g_siVert.nPos - iPos, NULL, NULL, NULL, NULL, SW_INVALIDATE | SW_ERASE); g_siVert.nPos = iPos; SetScrollInfo(hWnd, SB_VERT, g_siVert, TRUE); UpdateWindow(hWnd); } //------------------------------------------------------------------------------ void OnMouseWheel(HWND hWnd, WPARAM wParam, LPARAM lParam) { intnScrollCode; shortzDelta; zDelta = HIWORD(wParam); if (0 zDelta) { nScrollCode = SB_LINEUP; } else { nScrollCode = SB_LINEDOWN; } SendMessage(hWnd, WM_VSCROLL, nScrollCode, (LPARAM)NULL); } //------------------------------------------------------------------------------ int OnCommand(HWND hWnd, WPARAM wParam) { intnScrollCode; switch (LOWORD(wParam)) { case ID_PAGEUP nScrollCode = SB_PAGEUP; break; case ID_PAGEDOWN nScrollCode = SB_PAGEDOWN; break; case ID_END nScrollCode = SB_BOTTOM; break; case ID_HOME nScrollCode = SB_TOP; break; case ID_UP nScrollCode = SB_LINEUP; break; case ID_DOWN nScrollCode = SB_LINEDOWN; break; default return 1; } SendMessage(hWnd, WM_VSCROLL, nScrollCode, (LPARAM)NULL); return 0; } //------------------------------------------------------------------------------ void OnPaint(HWND hWnd) { HDChdc; PAINTSTRUCTps; HFONThFont; HGDIOBJhFontOld; TCHARatcFaceName[32]; TCHARatcStr[] = _T("012abc日本語"); TCHAR*ptc; intiStrLen; intiY; inti; hdc = BeginPaint(hWnd, ps); iStrLen = _tcslen(atcStr); for (i = 0; i g_iFontNum; i++) { iY = i * LINE_HEIGHT - g_siVert.nPos; if (iY + LINE_HEIGHT ps.rcPaint.top || ps.rcPaint.bottom iY) { continue; } ptc = g_aLogFont[i].lfFaceName; TextOut(hdc, 0, iY, ptc, _tcslen(ptc)); hFont = CreateFontIndirect(g_aLogFont + i); hFontOld = SelectObject(hdc, hFont); GetTextFace(hdc, _countof(atcFaceName), atcFaceName); TextOut(hdc, 200, iY, atcFaceName, _tcslen(atcFaceName)); TextOut(hdc, 600, iY, atcStr, iStrLen); SelectObject(hdc, hFontOld); DeleteObject(hFont); } EndPaint(hWnd, ps); } resource.h #define IDR_MAINFRAME128 #define ID_PAGEUP129 #define ID_PAGEDOWN130 #define ID_END131 #define ID_HOME132 #define ID_UP133 #define ID_DOWN134 EnumFont.rc // リソーススクリプト #include windows.h #include "resource.h" //------------------------------------------------------------------------------ // アクセラレータ IDR_MAINFRAME ACCELERATORS BEGIN VK_PRIOR,ID_PAGEUP,VIRTKEY VK_NEXT,ID_PAGEDOWN,VIRTKEY VK_END,ID_END,VIRTKEY VK_HOME,ID_HOME,VIRTKEY VK_UP,ID_UP,VIRTKEY VK_DOWN,ID_DOWN,VIRTKEY END
https://w.atwiki.jp/sampleisbest/pages/500.html
small.asm ;small.asm ;for MASM32 .modelsmall stdoutequ1 lfequ0ah crequ0dh .data outdatadb hello, world , cr, lf outdata_lenequ$ - outdata .code start movax, @data movds, ax movdx, offset outdata movcx, outdata_len movbx, stdout movah, 40h int21h movax, 4c00h int21h endstart コマンドプロンプト path %path%;c \masm32\bin ml /c /Fl small.asm link16 /st 0xcafe small.obj; ダンプリスト _IMAGE_DOS_HEADER (winnt.h) 0000 5a4d Magic number (MZ=5a4d) 0002 0026 Bytes on last page of file 0004 0002 Pages in file (1page=512bytes) 0006 0001 Relocations 0008 0020 Size of header in paragraphs (1para=16bytes) 000a 0000 Minimum extra paragraphs needed 000c ffff Maximum extra paragraphs needed 000e 0000 Initial (relative) SS value 0010 cafe Initial SP value 0012 0000 Checksum 0014 0000 Initial IP value 0016 0000 Initial (relative) CS value 0018 001e File address of relocation table 001a 0000 Overlay number address 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 0123456789abcdef 00000000 4d 5a 26 00-02 00 01 00-20 00 00 00-ff ff 00 00 MZ ..... ....... 00000010 fe ca 00 00-00 00 00 00-1e 00 00 00-01 00 01 00 ................ 00000020 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000030 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000040 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000050 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000060 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000070 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000080 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000090 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000a0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000b0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000c0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000d0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000e0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000000f0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000100 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000110 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000120 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000130 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000140 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000150 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000160 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000170 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000180 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000190 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001a0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001b0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001c0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001d0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001e0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 000001f0 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................ 00000200 b8 01 00 8e-d8 ba 08 00-b9 0e 00 bb-01 00 b4 40 ...............@ 00000210 cd 21 b8 00-4c cd 21 00-68 65 6c 6c-6f 2c 20 77 .!..L.!.hello, w 00000220 6f 72 6c 64-0d 0a - - orld..
https://w.atwiki.jp/sampleisbest/pages/238.html
開発環境 Microsoft Visual C# 2010 Express (SP1) 実行環境 Microsoft Windows XP Home Edition (SP3) プロジェクトの種類 Windows Game (4.0) プロジェクト名 XnaTexture2D 参考 Planet Earth Texture Maps Game1.cs /* * XnaTexture2D4 正距方位図法 * * プロジェクトのプロパティ * [XNA Game Studio]タブ * Use HiDef to access the complete API */ using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace XnaTexture2D { class Game1 Game { GraphicsDeviceManager graphics; SpriteBatch sprite; SpriteFont font; VertexBuffer vertexBuffer; Effect effect; BasicEffect basicEffect; Texture2D texture; VertexPositionColor[] cross; EffectParameter fxLat; EffectParameter fxLon; EffectParameter fxAxis; float lat = 35; float lon = 135; // fps int fpsSec; int fpsDraw = 0; int fpsCount = 0; public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void LoadContent() { sprite = new SpriteBatch(GraphicsDevice); font = Content.Load SpriteFont ("SpriteFont1"); texture = Content.Load Texture2D ("earthmap1k"); effect = Content.Load Effect ("Effect1"); effect.Parameters["EarthMap"].SetValue(texture); effect.Parameters["aspect"].SetValue(GraphicsDevice.Viewport.AspectRatio); fxLat = effect.Parameters["centerLatRad"]; fxLon = effect.Parameters["centerLonRad"]; fxAxis = effect.Parameters["axis"]; fxLat.SetValue(MathHelper.ToRadians(lat)); fxLon.SetValue(MathHelper.ToRadians(lon)); SetAxis(); basicEffect = new BasicEffect(GraphicsDevice); // 地図 VertexPositionTexture[] vertices = new VertexPositionTexture[4]; vertices[0] = new VertexPositionTexture(new Vector3(-1, 1, 0), new Vector2(0, 0)); vertices[1] = new VertexPositionTexture(new Vector3(1, 1, 0), new Vector2(1, 0)); vertices[2] = new VertexPositionTexture(new Vector3(-1, -1, 0), new Vector2(0, 1)); vertices[3] = new VertexPositionTexture(new Vector3(1, -1, 0), new Vector2(1, 1)); vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), 4, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); // 照準 cross = new VertexPositionColor[4]; cross[0] = new VertexPositionColor(new Vector3(-0.05f, 0, 0), Color.White); cross[1] = new VertexPositionColor(new Vector3(0.05f, 0, 0), Color.White); cross[2] = new VertexPositionColor(new Vector3(0, -0.1f, 0), Color.White); cross[3] = new VertexPositionColor(new Vector3(0, 0.1f, 0), Color.White); base.LoadContent(); } protected override void Update(GameTime gameTime) { float deltaLat = 0; float deltaLon = 0; bool modified = false; KeyboardState kState = Keyboard.GetState(); if (kState.IsKeyDown(Keys.Escape)) Exit(); if (kState.IsKeyDown(Keys.Up)) deltaLat = 1; if (kState.IsKeyDown(Keys.Down)) deltaLat = -1; if (kState.IsKeyDown(Keys.Left)) deltaLon = -1; if (kState.IsKeyDown(Keys.Right)) deltaLon = 1; if (deltaLat != 0) { lat = MathHelper.Clamp(lat + deltaLat, -89.9f, 89.9f); fxLat.SetValue(MathHelper.ToRadians(lat)); // -pi/2 - pi/2 modified = true; } if (deltaLon != 0) { lon += deltaLon; if (lon = -180) lon += 360; if (180 lon) lon -= 360; fxLon.SetValue(MathHelper.ToRadians(lon)); // -pi - pi modified = true; } if (modified) { SetAxis(); } base.Update(gameTime); } void SetAxis() { float rad = MathHelper.ToRadians(lat); float y = (float)Math.Sin(rad); float r = (float)Math.Cos(rad); rad = MathHelper.ToRadians(lon); float z = (float)Math.Cos(rad) * r; float x = (float)Math.Sin(rad) * r; Vector3 v = new Vector3(x, y, z); v.Normalize(); fxAxis.SetValue(v); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; GraphicsDevice.SetVertexBuffer(vertexBuffer); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); } foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, cross, 0, 2); } // fps fpsDraw++; if (gameTime.TotalGameTime.Seconds != fpsSec) { fpsCount = fpsDraw; fpsDraw = 0; fpsSec = gameTime.TotalGameTime.Seconds; } sprite.Begin(); string text = string.Format("fps={0} lat={1 f1} lon={2 f1}", fpsCount, lat, lon); sprite.DrawString(font, text, new Vector2(0, 0), Color.Red); sprite.End(); base.Draw(gameTime); } } } Effect1.fx // XnaTexture2D4 正距方位図法 texture EarthMap; float centerLatRad; float centerLonRad; float aspect; float3 axis; sampler TextureSampler = sampler_state { texture = EarthMap ; minfilter = linear; magfilter = linear; }; struct VertexShaderInput { float4 Position POSITION0; float2 TexCoord TEXCOORD0; }; struct VertexShaderOutput { float4 Position POSITION0; float2 TexCoord TEXCOORD0; }; VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; output.Position = input.Position; output.TexCoord = input.TexCoord; return output; } float4 MulQ(float4 q1, float4 q2) { float4 q; q.x = (q1.w * q2.x) + (q1.x * q2.w) + (q1.y * q2.z) - (q1.z * q2.y); q.y = (q1.w * q2.y) + (q1.y * q2.w) + (q1.z * q2.x) - (q1.x * q2.z); q.z = (q1.w * q2.z) + (q1.z * q2.w) + (q1.x * q2.y) - (q1.y * q2.x); q.w = (q1.w * q2.w) - (q1.x * q2.x) - (q1.y * q2.y) - (q1.z * q2.z); return q; } float4 PixelShaderFunction(VertexShaderOutput input) COLOR0 { float x = input.TexCoord.x * 2.0f - 1.0f; // -1 - 1 float y = input.TexCoord.y * 2.0f - 1.0f; // -1 - 1 x *= aspect; // 距離(=回転軸からの角度)0 - 1 float dist = sqrt(x * x + y * y); if (1.0f dist) { discard; } if (abs(dist - 0.5f) 0.0015f) { return float4(1, 1, 0, 1); } // 方位角(=回転する角度)-pi - pi float angleRad = atan2(x, -y); // 回転する座標 float4 p; float rad = centerLatRad + radians(dist * 180.0f); p.y = sin(rad); float r = cos(rad); p.z = cos(centerLonRad) * r; p.x = sin(centerLonRad) * r; p.w = 0; // 回転 float4 rot; angleRad *= 0.5f; rot.xyz = axis * sin(angleRad); rot.w = cos(angleRad); float4 conj; conj.xyz = -rot.xyz; conj.w = rot.w; float4 q = MulQ(MulQ(conj, p), rot); float lat = 90.0f - degrees(asin(q.y)); float lon = 180.0f + degrees(atan2(q.x, q.z)); float eps = 0.2f / (0.2f + dist); if (lat % 10.0f eps || lon % 15.0f eps) { return float4(1, 1, 1, 1); } float2 t; t.x = lon / 360.0f; t.y = lat / 180.0f; return tex2D(TextureSampler, t); } technique Technique1 { pass Pass1 { VertexShader = compile vs_3_0 VertexShaderFunction(); PixelShader = compile ps_3_0 PixelShaderFunction(); } }
https://w.atwiki.jp/sampleisbest/pages/242.html
開発環境 Microsoft Visual C# 2010 Express (SP1) 実行環境 Microsoft Windows XP Home Edition (SP3) プロジェクトの種類 空のプロジェクト プロジェクト名 MdxSample プロジェクト プロジェクトの保存 [ソリューションのディレクトリを作成]はチェックを付けなくてもいい。 プロジェクトのプロパティ [アプリケーション]タブ 出力の種類:Windows アプリケーション プロジェクトにクラスを追加。 テンプレート:クラス 名前:Program.cs 名前:Form1.cs 名前:MdxSample.cs プロジェクトに新しい項目を追加。 テンプレート:アプリケーション構成ファイル 名前:App.config プロジェクトの参照設定に追加。(.NETタブ) ※Ctrlキーで複数選択可 System System.Drawing System.Windows.Forms プロジェクトの参照設定に追加。(参照タブ) ※Ctrlキーで複数選択可 C \WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0 Microsoft.DirectX.dll Microsoft.DirectX.Direct3D.dll Microsoft.DirectX.Direct3DX.dll Microsoft.DirectX.DirectInput.dll 注意 MdxSample.exeと同じディレクトリにMdxSample.exe.configがないと動作が不安定になる。 参考 Managed DirectX - ソーサリーフォース LoaderLockエラーの対処 メニューから[ツール]-[設定]-[上級者設定]を選択する。 メニューから[デバッグ]-[例外]を選択する。 Managed Debugging Assistants/LoaderLockの[スローされるとき]のチェックを外す。 App.config ?xml version="1.0" encoding="utf-8" ? configuration startup useLegacyV2RuntimeActivationPolicy="true" supportedRuntime version="v4.0"/ /startup /configuration Program.cs using System; using System.Threading; using System.Windows.Forms; namespace MdxSample { static class Program { [STAThread] static void Main() { using (Form1 form = new Form1()) using (MdxSample main = new MdxSample()) { if (!main.DXInitialize(form)) { MessageBox.Show("Direct3Dの初期化に失敗しました。", "MdxSample"); return; } form.Show(); while (form.Created) { main.Render(); Thread.Sleep(1); Application.DoEvents(); } } } } } Form1.cs using System.Drawing; using System.Windows.Forms; namespace MdxSample { class Form1 Form { public Form1() { Text = "MdxSample"; ClientSize = new Size(1280, 720); MaximizeBox = false; FormBorderStyle = FormBorderStyle.FixedSingle; } } } MdxSample.cs using System; using System.Drawing; using System.Threading; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; using Microsoft.DirectX.DirectInput; namespace MdxSample { class MdxSample IDisposable { Form1 form; PresentParameters pp; Microsoft.DirectX.Direct3D.Device dev; Microsoft.DirectX.Direct3D.Font font; Microsoft.DirectX.DirectInput.Device keyboard; VertexBuffer vertexBuffer; // fps int fpsSec; int fpsDraw = 0; int fpsCount = 0; // カメラ float camDist = 3; int camLat = 0; int camLon = 180; public bool DXInitialize(Form1 topLevelForm) { try { form = topLevelForm; // キーボードデバイスの初期化 keyboard = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard); keyboard.SetCooperativeLevel(form, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background); keyboard.Acquire(); // Direct3Dデバイス作成 pp = new PresentParameters(); pp.Windowed = true; pp.SwapEffect = SwapEffect.Discard; pp.EnableAutoDepthStencil = true; pp.AutoDepthStencilFormat = DepthFormat.D16; dev = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, pp); // フォントの作成 FontDescription fd = new FontDescription(); fd.Height = 24; fd.FaceName = "MS ゴシック"; font = new Microsoft.DirectX.Direct3D.Font(dev, fd); // 頂点バッファ CustomVertex.PositionColored[] vertices = new CustomVertex.PositionColored[3]; vertices[0] = new CustomVertex.PositionColored(0, 1, 0, Color.Red.ToArgb()); vertices[1] = new CustomVertex.PositionColored(1, -1, 0, Color.Green.ToArgb()); vertices[2] = new CustomVertex.PositionColored(-1, -1, 0, Color.Blue.ToArgb()); vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, dev, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Managed); using (GraphicsStream data = vertexBuffer.Lock(0, 0, LockFlags.None)) { data.Write(vertices); vertexBuffer.Unlock(); } dev.Transform.Projection = Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(45), (float)dev.Viewport.Width / (float)dev.Viewport.Height, 1, 100); dev.RenderState.Lighting = false; return true; } catch { return false; } } public void Render() { KeyboardState state; state = keyboard.GetCurrentKeyboardState(); if (state[Key.Escape]) { form.Close(); return; } if (state[Key.Up]) camLat = Math.Min(camLat + 1, 89); if (state[Key.Down]) camLat = Math.Max(camLat - 1, -89); if (state[Key.Left]) camLon = (camLon + 1) % 360; if (state[Key.Right]) camLon = (camLon + 359) % 360; if (state[Key.PageUp]) camDist -= 0.1f; if (state[Key.PageDown]) camDist += 0.1f; // fps fpsDraw++; int sec = DateTime.Now.Second; if (fpsSec != sec) { fpsCount = fpsDraw; fpsDraw = 0; fpsSec = sec; } // カメラ位置 Vector3 pos; float rad = Geometry.DegreeToRadian(camLat); pos.Y = (float)Math.Sin(rad) * camDist; float r = (float)Math.Cos(rad) * camDist; rad = Geometry.DegreeToRadian(camLon); pos.X = (float)Math.Sin(rad) * r; pos.Z = (float)Math.Cos(rad) * r; dev.Transform.View = Matrix.LookAtLH(pos, new Vector3(), new Vector3(0, 1, 0)); // バックバッファのクリア dev.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0); dev.BeginScene(); dev.SetStreamSource(0, vertexBuffer, 0); dev.VertexFormat = CustomVertex.PositionColored.Format; dev.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); string text = string.Format("fps={0} lat={1} lon={2} dist={3 f1}", fpsCount, camLat, camLon, camDist); font.DrawText(null, text, 0, 0, Color.White); // バックバッファを表画面に反映 dev.EndScene(); try { dev.Present(); } catch (DeviceLostException) { ResetDevice(); } } void ResetDevice() { int result; if (!dev.CheckCooperativeLevel(out result)) { switch ((ResultCode)result) { case ResultCode.DeviceLost Thread.Sleep(10); break; case ResultCode.DeviceNotReset dev.Reset(pp); break; default form.Close(); break; } } } public void Dispose() { if (font != null) { font.Dispose(); } } } }
https://w.atwiki.jp/hmiku/pages/25853.html
【検索用 しょうねんとまほうのろほっとVOCALOIDBESTNEWRECORDINGS 登録タグ 40㍍PCD 40㍍PCDソロ CD CDし たまCD 全国発売】 + 目次 目次 CD紹介 曲目 リンク コメント 前作 本作 次作 シンタイソクテイ 少年と魔法のロボット VOCALOID BEST,NEW RECORDINGS キミボシ 40㍍P たま [TEST] 発売:2013年9月18日 価格:¥2,500(税込) 流通:全国 レーベル:due CD紹介 CD名:『少年と魔法のロボット VOCALOID BEST,NEW RECORDINGS』(しょうねんとまほうのろぼっと VOCALOID BEST,NEW RECORDINGS) NHK「みんなのうた」オンエア「少年と魔法のロボット」を含む全曲フルバンドによる新レコーディング。ニコニコ動画100万再生越え5曲を含む40mPボーカロイドソングベストアルバム。 虹色オーケストラメンバーを含む総勢12名のミュージシャンがこのアルバムのために集結! ブラス、ストリングス、全曲フルバンド、生楽器によるレコーディングで「からくりピエロ」、「ドレミファロンド」、「トリノコシティ」…40mP名曲の数々が蘇る! 収録楽曲のメグッポイド(GUMI)ボーカルによる「少年と魔法のロボット」がNHK「みんなのうた」の2013年8月・9月のオンエア決定。「みんなのうた」のラインナップに人間の声以外で歌われた曲が選出されるのは番組史上初。今回収録されるのはそのフルサイズver。 レコーディング ミックスエンジニアは福山雅治、今井美樹、井上陽介、スキマスイッチ等、数々のアルバムを手がけてきた三浦瑞生。 ジャケットイラストは「少年と魔法のロボット」の動画も担当しているたま氏。 参加ミュージシャン事務員G(Piano)、[TEST](Guitar)、mao(Bass)、岩永真奈(Bass)、ショボン(Drum Percussion)、湯本淳希(Trumpet)、西村貴行(Alto Tenor Sax)、和田充弘(Trombone) String Section 玉響MIZ(1st Violin)、MariNa(2nd Violin)、あかりんご(Viora)、まゆみ(Cello) 曲目 少年と魔法のロボット(Album Edit Ver.) / 40mP feat. GUMI Melody in the sky / 40mP feat. 初音ミク Step to you / 40mP feat. 初音ミク 巨大少女 / 40mP feat. 初音ミク ジェンガ / 40mP feat. 初音ミク トリノコシティ / 40mP feat. 初音ミク 妄想スケッチ / 40mP feat. 初音ミク キリトリセン / 40mP feat. GUMI 夢地図 / 40mP feat. GUMI からくりピエロ / 40mP feat. 初音ミク シリョクケンサ / 40mP feat. GUMI ドレミファロンド / 40mP feat. 初音ミク 春に一番近い街 / 40mP feat. GUMI 東京の真ン中で寝転ぶ 40mP feat. 初音ミク 千年橋と影法師 / 40mP feat. 初音ミク コトバのうた / 40mP feat. 初音ミク・GUMI 全16曲 リンク Amazon ナタリー記事 コメント 追加おつです -- 名無しさん (2013-06-16 20 28 11) イメージ画像吹いたww欲しいな! -- 名無しさん (2013-06-16 20 51 04) まさに40㍍Pさんの集大成的なアルバムやね。全曲生演奏とか胸が熱い。 -- 竜奇 (2013-06-16 21 33 44) 最近全国アルバム出たばっかじゃね?って思ったら生演奏か、なにこれすげぇ -- 名無しさん (2013-06-16 21 57 33) 生演奏とか。40mさんも偉くなったなぁww -- 名無しさん (2013-06-17 08 38 59) 40さんホントにどんどんすごくなってくなぁ、プロ並みだよねw -- 名無しさん (2013-06-17 09 35 54) 40さんほんとすごい!おめでとう!絶対買うよ! -- ゴル (2013-06-17 19 14 09) 40さんは神より神! -- 名無しさん (2013-06-17 19 17 30) メイトは予約まだっぽい。はやく始まれ! -- 名無しさん (2013-06-17 20 34 58) 初期曲から人気曲まで、選曲が良すぎ!!絶対買います! -- 名無しさん (2013-06-17 21 04 45) 雨とアスファルト入らないのか…( _ ) -- 名無しさん (2013-06-17 23 15 34) 40㍍Pの少年と魔法のロボットが気になる^^ -- 名無しさん (2013-06-18 18 03 48) 40さんほんとすごいなぁ 奏者さんも豪華だし、アルバム楽しみ! -- 名無しさん (2013-06-18 18 29 50) 買うに決まってる -- 名無しさん (2013-06-18 18 41 01) 素敵な曲ばっかり!!(*≧∀≦*)待機!! -- POKUNA (2013-06-18 19 33 53) 買います! -- ゴリラ (2013-07-04 20 46 32) 金がねぇwwです。頑張って貯金しましょう。 -- 神奈川に潜むもの (2013-07-04 21 32 53) 少年と魔法のロボットがはやく聴きたい!! -- れいん (2013-07-12 14 21 15) ある意味人生かかってるし、本気という本気を出してるな。 -- 名無しさん (2013-07-16 06 38 38) ほすい -- 名無しさん (2013-08-01 21 28 28) 8月9日が待ち遠しいですね!! -- 名無しさん (2013-08-02 09 32 47) ↑ミスった9月ですw -- 名無しさん (2013-08-02 09 35 09) ジャケットイラスト可愛い -- 名無しさん (2013-08-05 10 32 50) すごい!みんなのうた出るんだ! -- 名無しさん (2013-08-05 12 09 40) 40mP様さいっこー☆* .。. o(≧ー≦)o .。. *☆ -- 名無しさん (2013-08-07 15 35 23) 『少年と魔法のロボット』をみんなのうたで聴いてマジで感動した…!はやくフルが聴きたい!! -- 鈴 (2013-08-08 17 34 09) 絶対買いますっ!少年と魔法のロボットすごかたです -- 名無しさん (2013-08-08 17 48 33) からくりピエロ入ってる時点で絶対買います。あと魔法のロボットとか春に一番近い街とか妄想スケッチとかトリノコシティとかシリョクケンサとかもう嬉しすぎます -- 花音ユウ (2013-08-14 13 18 55) コトバのうた入るのか…!ほしいな! -- 名無しさん (2013-08-19 09 45 39) 少年と魔法のロボットのフルが楽しみすぎます…!! -- 名無しさん (2013-08-27 20 07 56) ↑ですよね!! 『みんなのうた』でやっててびっくり 感動しました!! -- ぴより (2013-08-27 20 39 57) みんなのうたの楽譜で、やっと少年と魔法のロボットの全歌詞を知れた。 見るまでは、ラストハッピーエンドかな、バッドエンドかな…と悶々してたのでスッキリした。 楽譜の歌詞見たのが教室だったんだが、それでも感極まって泣きそうだったw -- 常和 (2013-09-06 07 31 22) みんなのうたはショートバージョンだから、フルバージョン楽しみです! -- 名無しさん (2013-09-08 13 23 12) 少年と魔法のロボット、NHKのみんなのうたで歌ってたよ。 -- 名無しさん (2013-09-09 20 37 34) 18日楽しみすぎる\(^o^)/ -- 名無しさん (2013-09-14 09 28 39) 今聴いてるけど、最高傑作!!アレンジいいし、全体的に優しい感じで素晴らしい! -- 名無しさん (2013-09-21 19 14 19) 過去作に収録された曲も演奏のおかげで別物みたいになってるね。タイトル曲は聴けば聴くほどいい曲。 -- 名無しさん (2013-09-30 21 18 50) 買ったぜ!!!!!! -- 40cmP (2013-11-05 07 21 05) 俺はこれのために新しいウォークマンと高いヘッドフォン買ったんだ。 -- ミク廃その○○そして40mP (2013-12-28 02 20 17) あ、名前ミスった -- ミク廃その○○ (2013-12-28 02 21 23) このCDの巨大少女がヤバイ。 -- ろんぐている (2014-01-21 21 21 05) 全体的に優しい感じになってた!買ってよかった -- 名無しさん (2014-02-01 23 54 38) 名前 コメント
https://w.atwiki.jp/sampleisbest/pages/223.html
開発環境 Microsoft Visual C# 2010 Express (SP1) 実行環境 Microsoft Windows XP Home Edition (SP3) プロジェクトの種類 Windows Game (4.0) プロジェクト名 XnaSphere2 CustomVertex.cs using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace CustomVertex { struct VertexPositionNormalColor IVertexType { public Vector3 Position; public Vector3 Normal; public Color Color; public VertexPositionNormalColor(Vector3 position, Vector3 normal, Color color) { Position = position; Normal = normal; Color = color; } static readonly VertexDeclaration VertexDeclaration = new VertexDeclaration( new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(sizeof(float) * 3, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0), new VertexElement(sizeof(float) * 6, VertexElementFormat.Color, VertexElementUsage.Color, 0)); VertexDeclaration IVertexType.VertexDeclaration { get { return VertexDeclaration; } } } } Game1.cs // XnaSphere2 - XNA 球体(法線) using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using CustomVertex; namespace XnaSphere { class Game1 Game { GraphicsDeviceManager graphics; SpriteBatch sprite; SpriteFont font; BasicEffect effect; VertexBuffer vertexBuffer; IndexBuffer indexBuffer; // fps int sec; int draw = 0; int fps = 0; // カメラ int camLat = 0; int camLong = 90; float camDist = 5; public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void LoadContent() { font = Content.Load SpriteFont ("SpriteFont1"); sprite = new SpriteBatch(GraphicsDevice); effect = new BasicEffect(GraphicsDevice); //effect.VertexColorEnabled = true; effect.EnableDefaultLighting(); effect.Projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio, 1, 100); // 頂点バッファ int stackNum = 16; // 輪切りの数 VertexPositionNormalColor[] vertices = new VertexPositionNormalColor[stackNum * stackNum + 2]; int i = 0; vertices[i++] = new VertexPositionNormalColor( new Vector3(0, 1, 0), new Vector3(0, 1, 0), Color.Yellow); for (int stack = 1; stack stackNum; stack++) { float rad = ((stackNum - 2 * stack) / (float)stackNum) * MathHelper.PiOver2; float y = (float)Math.Sin(rad); float r = (float)Math.Cos(rad); int sliceNum = 4 * Math.Min(stack, stackNum - stack); // 放射頂点の数 for (int slice = 0; slice sliceNum; slice++) { rad = (slice / (float)sliceNum) * MathHelper.TwoPi; float x = (float)Math.Cos(rad) * r; float z = (float)Math.Sin(rad) * r; Vector3 normal = Vector3.Normalize(new Vector3(x, y, z)); vertices[i++] = new VertexPositionNormalColor( normal, normal, (slice 1) == 0 ? Color.Red Color.Yellow); } } vertices[i++] = new VertexPositionNormalColor( new Vector3(0, -1, 0), new Vector3(0, -1, 0), Color.Yellow); vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionNormalColor), vertices.Length, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); // 索引バッファ short[] indices = new short[stackNum * stackNum * 6]; i = 0; int prevHead = 0; // 前の先頭頂点番号 int prevVtx = 1; // 前の頂点数 for (int stack = 0; stack stackNum / 2; stack++) { int currHead = prevHead + prevVtx; // 現在の先頭頂点番号 int currVtx = 4 * (stack + 1); // 現在の頂点数 for (int quad = 0; quad 4; quad++) // 4象限 { int prevQuad = quad * stack; // 前の象限オフセット int currQuad = quad * (stack + 1); // 現在の象限オフセット for (int n = 0; ; n++) { indices[i++] = (short)(prevHead + (prevQuad + n) % prevVtx); indices[i++] = (short)(currHead + (currQuad + n)); indices[i++] = (short)(currHead + (currQuad + n + 1) % currVtx); if (stack = n) break; indices[i++] = (short)(prevHead + (prevQuad + n)); indices[i++] = (short)(currHead + (currQuad + n + 1)); indices[i++] = (short)(prevHead + (prevQuad + n + 1) % prevVtx); } } prevHead = currHead; prevVtx = currVtx; } for (int stack = stackNum / 2 - 1; 0 = stack; stack--) { int currHead = prevHead + prevVtx; int currVtx = Math.Max(4 * stack, 1); for (int quad = 0; quad 4; quad++) // 4象限 { int prevQuad = quad * (stack + 1); int currQuad = quad * stack; for (int n = 0; ; n++) { indices[i++] = (short)(currHead + (currQuad + n) % currVtx); indices[i++] = (short)(prevHead + (prevQuad + n + 1) % prevVtx); indices[i++] = (short)(prevHead + (prevQuad + n)); if (stack = n) break; indices[i++] = (short)(currHead + (currQuad + n)); indices[i++] = (short)(currHead + (currQuad + n + 1) % currVtx); indices[i++] = (short)(prevHead + (prevQuad + n + 1)); } } prevHead = currHead; prevVtx = currVtx; } indexBuffer = new IndexBuffer(GraphicsDevice, typeof(short), indices.Length, BufferUsage.WriteOnly); indexBuffer.SetData(indices); base.LoadContent(); } protected override void Update(GameTime gameTime) { KeyboardState kState = Keyboard.GetState(); if (kState.IsKeyDown(Keys.Escape)) Exit(); if (kState.IsKeyDown(Keys.Up)) camLat++; if (kState.IsKeyDown(Keys.Down)) camLat--; if (kState.IsKeyDown(Keys.Left)) camLong = (camLong + 1) % 360; if (kState.IsKeyDown(Keys.Right)) camLong = (camLong + 359) % 360; if (kState.IsKeyDown(Keys.PageUp)) camDist -= 0.1f; if (kState.IsKeyDown(Keys.PageDown)) camDist += 0.1f; base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); //GraphicsDevice.RasterizerState = // new RasterizerState { FillMode = FillMode.WireFrame }; // カメラ位置 float rad = MathHelper.ToRadians(camLat); float y = (float)Math.Sin(rad) * camDist; float r = (float)Math.Cos(rad) * camDist; rad = MathHelper.ToRadians(camLong); float x = (float)Math.Cos(rad) * r; float z = (float)Math.Sin(rad) * r; effect.View = Matrix.CreateLookAt(new Vector3(x, y, z), Vector3.Zero, Vector3.Up); GraphicsDevice.SetVertexBuffer(vertexBuffer); GraphicsDevice.Indices = indexBuffer; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3); } // fps draw++; if (gameTime.TotalGameTime.Seconds != sec) { fps = draw; draw = 0; sec = gameTime.TotalGameTime.Seconds; } sprite.Begin(); string text = String.Format( "fps={0} lat={1} long={2} dist={3 f1}", fps, camLat, camLong, camDist); sprite.DrawString(font, text, new Vector2(0, 0), Color.White); sprite.End(); base.Draw(gameTime); } } }
https://w.atwiki.jp/sampleisbest/pages/71.html
開発環境 Microsoft Visual C++ 2010 Express (SP1) 実行環境 Microsoft Windows XP Home Edition (SP3) プロジェクトの種類 Win32 プロジェクト プロジェクト名 RadioButton アプリケーションの種類 Windows アプリケーション 追加のオプション 空のプロジェクト 文字セット Unicode RadioButton.cpp #include tchar.h #include Windows.h #include WindowsX.h #include "resource.h" INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); void OnOK(HWND hDlg); int APIENTRY _tWinMain( HINSTANCEhInstance, HINSTANCEhPrevInstance, LPTSTRlpCmdLine, intnCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DialogProc); return 0; } INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { INT_PTR iRetVal = TRUE; switch (uMsg) { case WM_COMMAND switch (LOWORD(wParam)) { case IDOK OnOK(hwndDlg); break; } break; case WM_INITDIALOG Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO1), BST_CHECKED); break; case WM_CLOSE EndDialog(hwndDlg, 0); break; default iRetVal = FALSE; } return iRetVal; } void OnOK(HWND hDlg) { LRESULTlr; inti1, i2, i3; i1 = GetDlgItemInt(hDlg, IDC_EDIT1, NULL, TRUE); i2 = GetDlgItemInt(hDlg, IDC_EDIT2, NULL, TRUE); lr = Button_GetCheck(GetDlgItem(hDlg, IDC_RADIO1)); if (lr == BST_CHECKED) { i3 = i1 + i2; } else { i3 = i1 - i2; } SetDlgItemInt(hDlg, IDC_EDIT3, i3, TRUE); } resource.h #define IDD_DIALOG100 #define IDC_STATIC-1 #define IDC_EDIT11000 #define IDC_EDIT21001 #define IDC_EDIT31002 #define IDC_RADIO11003 #define IDC_RADIO21004 RadioButton.rc #include windows.h #include "resource.h" IDD_DIALOG DIALOGEX 300, 200, 130, 55 STYLE WS_POPUPWINDOW | WS_MINIMIZEBOX EXSTYLE WS_EX_APPWINDOW CAPTION "RadioButton" FONT 9, "MS Pゴシック" BEGIN EDITTEXTIDC_EDIT1,4,4,36,12 EDITTEXTIDC_EDIT2,44,4,36,12 EDITTEXTIDC_EDIT3,88,4,36,12 CONTROL"+",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP, 8,32,28,12 CONTROL"-",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON, 40,32,28,12 GROUPBOX"演算子",IDC_STATIC,4,20,76,32,WS_GROUP DEFPUSHBUTTON"OK",IDOK,88,24,26,16 END