framework.cpp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. #include <d3d11.h>
  2. #include <Array.h>
  3. #include <Punkt.h>
  4. #include <Bild.h>
  5. #include <Fenster.h>
  6. #include <Text.h>
  7. #include <Zeichnung.h>
  8. #include <Globals.h>
  9. #include <Zeit.h>
  10. #include <ToolTip.h>
  11. #include <MausEreignis.h>
  12. #include <TextFeld.h>
  13. #include <TastaturEreignis.h>
  14. #include <RenderThread.h>
  15. #include <iostream>
  16. #include <Bildschirm.h>
  17. #include <d3dx10math.h>
  18. #include <d3dx11async.h>
  19. using namespace Framework;
  20. namespace Framework2
  21. {
  22. //Diese Klasse wird das Bild auf dem Bildschirm verwalten
  23. class Bildschirm : public Framework::Bildschirm
  24. {
  25. private:
  26. struct VertexType
  27. {
  28. D3DXVECTOR3 position;
  29. D3DXVECTOR2 texture;
  30. };
  31. struct MatrixBufferType
  32. {
  33. D3DXMATRIX world;
  34. D3DXMATRIX view;
  35. D3DXMATRIX projection;
  36. };
  37. ID3D11Device *d3d11Device;
  38. ID3D11DeviceContext *d3d11Context;
  39. IDXGISwapChain *d3d11SpawChain;
  40. ID3D11Texture2D *d3d11FrameworkBuffer;
  41. ID3D11Buffer *vertexBuffer, *indexBuffer;
  42. ID3D11VertexShader* vertexShader;
  43. ID3D11PixelShader* pixelShader;
  44. ID3D11InputLayout* layout;
  45. ID3D11Buffer* matrixBuffer;
  46. ID3D11SamplerState* sampleState;
  47. ID3D11ShaderResourceView *resource;
  48. ID3D11RenderTargetView *rtview;
  49. ID3D11DepthStencilView *dsView;
  50. ID3D11Texture2D *depthStencilBuffer;
  51. ID3D11DepthStencilState *depthStencilState;
  52. ID3D11RasterizerState *rasterizerState;
  53. ID3D11DepthStencilState *depthDisabledStencilState;
  54. ID3D11BlendState *blendStateAlphaBlend;
  55. WFenster *fenster;
  56. Bild *renderB;
  57. int ref;
  58. ZeichnungArray *members;
  59. int füllFarbe;
  60. int deckFarbe;
  61. Zeichnung *onTop;
  62. bool renderOnTop;
  63. bool renderZeichnungen;
  64. bool vollbild;
  65. bool rendering;
  66. ZeitMesser *renderZeit;
  67. Punkt backBufferGröße;
  68. CRITICAL_SECTION cs;
  69. RCArray< ToolTip > *tips;
  70. int tipAnzahl;
  71. bool testRend;
  72. bool füll;
  73. bool rend;
  74. public:
  75. // Konstruktor
  76. Bildschirm( WFenster *fenster )
  77. : Framework::Bildschirm( 0 ),
  78. d3d11Device( 0 ),
  79. d3d11Context( 0 ),
  80. d3d11SpawChain( 0 ),
  81. d3d11FrameworkBuffer( 0 ),
  82. vertexBuffer( 0 ),
  83. indexBuffer( 0 ),
  84. vertexShader( 0 ),
  85. pixelShader( 0 ),
  86. layout( 0 ),
  87. matrixBuffer( 0 ),
  88. sampleState( 0 ),
  89. resource( 0 ),
  90. rtview( 0 ),
  91. dsView( 0 ),
  92. depthStencilBuffer( 0 ),
  93. depthStencilState( 0 ),
  94. rasterizerState( 0 ),
  95. depthDisabledStencilState( 0 ),
  96. blendStateAlphaBlend( 0 ),
  97. fenster( fenster ),
  98. renderB( new Bild( 1 ) ),
  99. ref( 1 ),
  100. members( new ZeichnungArray() ),
  101. füllFarbe( 0 ),
  102. deckFarbe( 0 ),
  103. onTop( 0 ),
  104. renderOnTop( 0 ),
  105. renderZeichnungen( 1 ),
  106. vollbild( 0 ),
  107. rendering( 0 ),
  108. renderZeit( new ZeitMesser() ),
  109. backBufferGröße( 0, 0 ),
  110. tips( new RCArray< ToolTip >() ),
  111. tipAnzahl( 0 ),
  112. testRend( 1 ),
  113. füll( 1 ),
  114. rend( 0 )
  115. {
  116. InitializeCriticalSection( &cs );
  117. }
  118. // Destruktor
  119. ~Bildschirm()
  120. {
  121. lock();
  122. if( renderB )
  123. renderB->release();
  124. if( d3d11Device )
  125. {
  126. d3d11Device->Release();
  127. d3d11Device = NULL;
  128. }
  129. if( d3d11Context )
  130. {
  131. d3d11Context->Release();
  132. d3d11Context = NULL;
  133. }
  134. if( d3d11SpawChain )
  135. {
  136. d3d11SpawChain->Release();
  137. d3d11SpawChain = NULL;
  138. }
  139. if( d3d11FrameworkBuffer )
  140. {
  141. d3d11FrameworkBuffer->Release();
  142. d3d11FrameworkBuffer = NULL;
  143. }
  144. if( vertexBuffer )
  145. {
  146. vertexBuffer->Release();
  147. vertexBuffer = NULL;
  148. }
  149. if( indexBuffer )
  150. {
  151. indexBuffer->Release();
  152. indexBuffer = NULL;
  153. }
  154. if( pixelShader )
  155. {
  156. pixelShader->Release();
  157. pixelShader = NULL;
  158. }
  159. if( vertexShader )
  160. {
  161. vertexShader->Release();
  162. vertexShader = NULL;
  163. }
  164. if( layout )
  165. {
  166. layout->Release();
  167. layout = 0;
  168. }
  169. if( matrixBuffer )
  170. {
  171. matrixBuffer->Release();
  172. matrixBuffer = 0;
  173. }
  174. if( sampleState )
  175. {
  176. sampleState->Release();
  177. sampleState = 0;
  178. }
  179. if( resource )
  180. {
  181. resource->Release();
  182. resource = 0;
  183. }
  184. if( rtview )
  185. {
  186. rtview->Release();
  187. rtview = 0;
  188. }
  189. if( dsView )
  190. {
  191. dsView->Release();
  192. dsView = 0;
  193. }
  194. if( depthStencilBuffer )
  195. {
  196. depthStencilBuffer->Release();
  197. depthStencilBuffer = 0;
  198. }
  199. if( depthStencilState )
  200. {
  201. depthStencilState->Release();
  202. depthStencilState = 0;
  203. }
  204. if( rasterizerState )
  205. {
  206. rasterizerState->Release();
  207. rasterizerState = 0;
  208. }
  209. if( depthDisabledStencilState )
  210. {
  211. depthDisabledStencilState->Release();
  212. depthDisabledStencilState = 0;
  213. }
  214. if( blendStateAlphaBlend )
  215. {
  216. blendStateAlphaBlend->Release();
  217. blendStateAlphaBlend = 0;
  218. }
  219. if( fenster )
  220. fenster->release();
  221. delete members;
  222. tipAnzahl = 0;
  223. tips->release();
  224. renderZeit->release();
  225. unlock();
  226. DeleteCriticalSection( &cs );
  227. }
  228. // nicht constant
  229. void lock()
  230. {
  231. EnterCriticalSection( &cs );
  232. }
  233. void unlock()
  234. {
  235. LeaveCriticalSection( &cs );
  236. }
  237. void setFüll( bool f )
  238. {
  239. füll = f;
  240. }
  241. void update()
  242. {
  243. lock();
  244. HRESULT result;
  245. //------------------------------------------------------
  246. // Clean up
  247. if( d3d11Device )
  248. {
  249. d3d11Device->Release();
  250. d3d11Device = 0;
  251. }
  252. if( d3d11Context )
  253. {
  254. d3d11Context->Release();
  255. d3d11Context = 0;
  256. }
  257. if( d3d11SpawChain )
  258. {
  259. d3d11SpawChain->Release();
  260. d3d11SpawChain = NULL;
  261. }
  262. if( d3d11FrameworkBuffer )
  263. {
  264. d3d11FrameworkBuffer->Release();
  265. d3d11FrameworkBuffer = 0;
  266. }
  267. if( vertexBuffer )
  268. {
  269. vertexBuffer->Release();
  270. vertexBuffer = NULL;
  271. }
  272. if( indexBuffer )
  273. {
  274. indexBuffer->Release();
  275. indexBuffer = NULL;
  276. }
  277. if( pixelShader )
  278. {
  279. pixelShader->Release();
  280. pixelShader = NULL;
  281. }
  282. if( vertexShader )
  283. {
  284. vertexShader->Release();
  285. vertexShader = NULL;
  286. }
  287. if( layout )
  288. {
  289. layout->Release();
  290. layout = 0;
  291. }
  292. if( matrixBuffer )
  293. {
  294. matrixBuffer->Release();
  295. matrixBuffer = 0;
  296. }
  297. if( sampleState )
  298. {
  299. sampleState->Release();
  300. sampleState = 0;
  301. }
  302. if( resource )
  303. {
  304. resource->Release();
  305. resource = 0;
  306. }
  307. if( rtview )
  308. {
  309. rtview->Release();
  310. rtview = 0;
  311. }
  312. if( dsView )
  313. {
  314. dsView->Release();
  315. dsView = 0;
  316. }
  317. if( depthStencilBuffer )
  318. {
  319. depthStencilBuffer->Release();
  320. depthStencilBuffer = 0;
  321. }
  322. if( depthStencilState )
  323. {
  324. depthStencilState->Release();
  325. depthStencilState = 0;
  326. }
  327. if( rasterizerState )
  328. {
  329. rasterizerState->Release();
  330. rasterizerState = 0;
  331. }
  332. if( depthDisabledStencilState )
  333. {
  334. depthDisabledStencilState->Release();
  335. depthDisabledStencilState = 0;
  336. }
  337. if( blendStateAlphaBlend )
  338. {
  339. blendStateAlphaBlend->Release();
  340. blendStateAlphaBlend = 0;
  341. }
  342. //--------------------------------------------------------------------
  343. // Create Device
  344. // create a struct to hold information about the swap chain
  345. DXGI_SWAP_CHAIN_DESC scd;
  346. // clear out the struct for use
  347. ZeroMemory( &scd, sizeof( DXGI_SWAP_CHAIN_DESC ) );
  348. // fill the swap chain description struct
  349. scd.BufferCount = 1; // one back buffer
  350. scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used
  351. scd.OutputWindow = fenster ? fenster->getFensterHandle() : 0; // the window to be used
  352. scd.SampleDesc.Count = 1;
  353. // Set the scan line ordering and scaling to unspecified.
  354. scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
  355. scd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
  356. scd.Windowed = !vollbild;
  357. if( !backBufferGröße.x || !backBufferGröße.y )
  358. backBufferGröße = fenster ? fenster->getKörperGröße() : Punkt( 0, 0 );
  359. scd.BufferDesc.Width = backBufferGröße.x;
  360. scd.BufferDesc.Height = backBufferGröße.y; // windowed/full-screen mode
  361. scd.BufferDesc.RefreshRate.Denominator = 1;
  362. scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color
  363. // Discard the back buffer contents after presenting.
  364. scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
  365. if( renderB )
  366. renderB->release();
  367. renderB = new Bild( 1 );
  368. renderB->neuBild( backBufferGröße.x, backBufferGröße.y, füllFarbe );
  369. D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
  370. // create a device, device context and swap chain using the information in the scd struct
  371. D3D11CreateDeviceAndSwapChain( NULL,
  372. D3D_DRIVER_TYPE_HARDWARE,
  373. NULL,
  374. D3D11_CREATE_DEVICE_DEBUG,
  375. &featureLevel,
  376. 1,
  377. D3D11_SDK_VERSION,
  378. &scd,
  379. &d3d11SpawChain,
  380. &d3d11Device,
  381. NULL,
  382. &d3d11Context );
  383. ID3D11Texture2D *backBufferPtr;
  384. // Get the pointer to the back buffer.
  385. result = d3d11SpawChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&backBufferPtr );
  386. // Create the render target view with the back buffer pointer.
  387. result = d3d11Device->CreateRenderTargetView( backBufferPtr, NULL, &rtview );
  388. // Release pointer to the back buffer as we no longer need it.
  389. backBufferPtr->Release();
  390. // Initialize the description of the depth buffer.
  391. D3D11_TEXTURE2D_DESC depthBufferDesc;
  392. ZeroMemory( &depthBufferDesc, sizeof( depthBufferDesc ) );
  393. // Set up the description of the depth buffer.
  394. depthBufferDesc.Width = backBufferGröße.x;
  395. depthBufferDesc.Height = backBufferGröße.y;
  396. depthBufferDesc.MipLevels = 1;
  397. depthBufferDesc.ArraySize = 1;
  398. depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
  399. depthBufferDesc.SampleDesc.Count = 1;
  400. depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;
  401. depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
  402. // Create the texture for the depth buffer using the filled out description.
  403. result = d3d11Device->CreateTexture2D( &depthBufferDesc, NULL, &depthStencilBuffer );
  404. // Initialize the description of the stencil state.
  405. D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
  406. ZeroMemory( &depthStencilDesc, sizeof( depthStencilDesc ) );
  407. // Set up the description of the stencil state.
  408. depthStencilDesc.DepthEnable = true;
  409. depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
  410. depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
  411. depthStencilDesc.StencilEnable = true;
  412. depthStencilDesc.StencilReadMask = 0xFF;
  413. depthStencilDesc.StencilWriteMask = 0xFF;
  414. // Stencil operations if pixel is front-facing.
  415. depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
  416. depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
  417. depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
  418. depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
  419. // Stencil operations if pixel is back-facing.
  420. depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
  421. depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
  422. depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
  423. depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
  424. // Create the depth stencil state.
  425. result = d3d11Device->CreateDepthStencilState( &depthStencilDesc, &depthStencilState );
  426. // Set the depth stencil state.
  427. d3d11Context->OMSetDepthStencilState( depthStencilState, 1 );
  428. // Initialize the depth stencil view.
  429. D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
  430. ZeroMemory( &depthStencilViewDesc, sizeof( depthStencilViewDesc ) );
  431. // Set up the depth stencil view description.
  432. depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
  433. depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
  434. // Create the depth stencil view.
  435. result = d3d11Device->CreateDepthStencilView( depthStencilBuffer, &depthStencilViewDesc, &dsView );
  436. // Bind the render target view and depth stencil buffer to the output render pipeline.
  437. d3d11Context->OMSetRenderTargets( 1, &rtview, dsView );
  438. D3D11_RASTERIZER_DESC rasterDesc;
  439. // Setup the raster description which will determine how and what polygons will be drawn.
  440. rasterDesc.AntialiasedLineEnable = false;
  441. rasterDesc.CullMode = D3D11_CULL_BACK;
  442. rasterDesc.DepthBiasClamp = 0.0f;
  443. rasterDesc.DepthClipEnable = true;
  444. rasterDesc.FillMode = D3D11_FILL_SOLID;
  445. rasterDesc.FrontCounterClockwise = false;
  446. rasterDesc.MultisampleEnable = false;
  447. rasterDesc.ScissorEnable = false;
  448. rasterDesc.SlopeScaledDepthBias = 0.0f;
  449. // Create the rasterizer state from the description we just filled out.
  450. result = d3d11Device->CreateRasterizerState( &rasterDesc, &rasterizerState );
  451. // Now set the rasterizer state.
  452. d3d11Context->RSSetState( rasterizerState );
  453. D3D11_VIEWPORT vp;
  454. memset( &vp, 0, sizeof( D3D11_VIEWPORT ) );
  455. vp.Width = backBufferGröße.x;
  456. vp.Height = backBufferGröße.y;
  457. vp.MinDepth = 0.0f;
  458. vp.MaxDepth = 1.0f;
  459. vp.TopLeftX = 0.0f;
  460. vp.TopLeftY = 0.0f;
  461. d3d11Context->RSSetViewports( 1, &vp );
  462. D3D11_DEPTH_STENCIL_DESC depthDisabledStencilDesc;
  463. // Clear the second depth stencil state before setting the parameters.
  464. ZeroMemory( &depthDisabledStencilDesc, sizeof( depthDisabledStencilDesc ) );
  465. // Now create a second depth stencil state which turns off the Z buffer for 2D rendering. The only difference is
  466. // that DepthEnable is set to false, all other parameters are the same as the other depth stencil state.
  467. depthDisabledStencilDesc.DepthEnable = false;
  468. depthDisabledStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
  469. depthDisabledStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
  470. depthDisabledStencilDesc.StencilEnable = true;
  471. depthDisabledStencilDesc.StencilReadMask = 0xFF;
  472. depthDisabledStencilDesc.StencilWriteMask = 0xFF;
  473. depthDisabledStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
  474. depthDisabledStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
  475. depthDisabledStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
  476. depthDisabledStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
  477. depthDisabledStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
  478. depthDisabledStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
  479. depthDisabledStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
  480. depthDisabledStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
  481. // Create the state using the device.
  482. result = d3d11Device->CreateDepthStencilState( &depthDisabledStencilDesc, &depthDisabledStencilState );
  483. //-------------------------------------------------
  484. // Shaders
  485. ID3D10Blob* errorMessage;
  486. ID3D10Blob* vertexShaderBuffer;
  487. ID3D10Blob* pixelShaderBuffer;
  488. D3D11_INPUT_ELEMENT_DESC polygonLayout[ 2 ];
  489. result = D3DX11CompileFromFile( "texture.vs", NULL, NULL, "TextureVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG, 0, NULL,
  490. &vertexShaderBuffer, &errorMessage, NULL );
  491. if( errorMessage )
  492. {
  493. char *err = (char*)errorMessage->GetBufferPointer();
  494. std::cout << err;
  495. }
  496. result = D3DX11CompileFromFile( "texture.ps", NULL, NULL, "TexturePixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG, 0, NULL,
  497. &pixelShaderBuffer, &errorMessage, NULL );
  498. if( errorMessage )
  499. {
  500. char *err = (char*)errorMessage->GetBufferPointer();
  501. std::cout << err;
  502. }
  503. result = d3d11Device->CreateVertexShader( vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertexShader );
  504. result = d3d11Device->CreatePixelShader( pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixelShader );
  505. // Create the vertex input layout description.
  506. // This setup needs to match the VertexType stucture in the ModelClass and in the shader.
  507. polygonLayout[ 0 ].SemanticName = "POSITION";
  508. polygonLayout[ 0 ].SemanticIndex = 0;
  509. polygonLayout[ 0 ].Format = DXGI_FORMAT_R32G32B32_FLOAT;
  510. polygonLayout[ 0 ].InputSlot = 0;
  511. polygonLayout[ 0 ].AlignedByteOffset = 0;
  512. polygonLayout[ 0 ].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
  513. polygonLayout[ 0 ].InstanceDataStepRate = 0;
  514. polygonLayout[ 1 ].SemanticName = "TEXCOORD";
  515. polygonLayout[ 1 ].SemanticIndex = 0;
  516. polygonLayout[ 1 ].Format = DXGI_FORMAT_R32G32_FLOAT;
  517. polygonLayout[ 1 ].InputSlot = 0;
  518. polygonLayout[ 1 ].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
  519. polygonLayout[ 1 ].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
  520. polygonLayout[ 1 ].InstanceDataStepRate = 0;
  521. // Get a count of the elements in the layout.
  522. unsigned int numElements = sizeof( polygonLayout ) / sizeof( polygonLayout[ 0 ] );
  523. // Create the vertex input layout.
  524. result = d3d11Device->CreateInputLayout( polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(),
  525. &layout );
  526. // Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
  527. vertexShaderBuffer->Release();
  528. vertexShaderBuffer = 0;
  529. pixelShaderBuffer->Release();
  530. pixelShaderBuffer = 0;
  531. // Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
  532. D3D11_BUFFER_DESC matrixBufferDesc;
  533. matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
  534. matrixBufferDesc.ByteWidth = sizeof( MatrixBufferType );
  535. matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
  536. matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  537. matrixBufferDesc.MiscFlags = 0;
  538. matrixBufferDesc.StructureByteStride = 0;
  539. // Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
  540. result = d3d11Device->CreateBuffer( &matrixBufferDesc, NULL, &matrixBuffer );
  541. // Create a texture sampler state description.
  542. D3D11_SAMPLER_DESC samplerDesc;
  543. samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
  544. samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
  545. samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
  546. samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
  547. samplerDesc.MipLODBias = 0.0f;
  548. samplerDesc.MaxAnisotropy = 1;
  549. samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
  550. samplerDesc.BorderColor[ 0 ] = 0;
  551. samplerDesc.BorderColor[ 1 ] = 0;
  552. samplerDesc.BorderColor[ 2 ] = 0;
  553. samplerDesc.BorderColor[ 3 ] = 0;
  554. samplerDesc.MinLOD = 0;
  555. samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
  556. // Create the texture sampler state.
  557. result = d3d11Device->CreateSamplerState( &samplerDesc, &sampleState );
  558. //---------------------------------------------------------------
  559. // Framework Backbuffer Texture
  560. D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
  561. D3D11_SUBRESOURCE_DATA vertexData, indexData;
  562. unsigned long indices[ 6 ];
  563. VertexType vertices[ 6 ];
  564. // Load the index array with data.
  565. for( int i = 0; i < 6; i++ )
  566. {
  567. indices[ i ] = i;
  568. }
  569. vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
  570. vertexBufferDesc.ByteWidth = sizeof( vertices );
  571. vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
  572. vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  573. vertexBufferDesc.MiscFlags = 0;
  574. vertexBufferDesc.StructureByteStride = 0;
  575. // Give the subresource structure a pointer to the vertex data.
  576. vertexData.pSysMem = vertices;
  577. vertexData.SysMemPitch = 0;
  578. vertexData.SysMemSlicePitch = 0;
  579. // Now create the vertex buffer.
  580. result = d3d11Device->CreateBuffer( &vertexBufferDesc, &vertexData, &vertexBuffer );
  581. // Set up the description of the static index buffer.
  582. indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
  583. indexBufferDesc.ByteWidth = sizeof( unsigned long ) * 6;
  584. indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
  585. indexBufferDesc.CPUAccessFlags = 0;
  586. indexBufferDesc.MiscFlags = 0;
  587. indexBufferDesc.StructureByteStride = 0;
  588. // Give the subresource structure a pointer to the index data.
  589. indexData.pSysMem = indices;
  590. indexData.SysMemPitch = 0;
  591. indexData.SysMemSlicePitch = 0;
  592. // Create the index buffer.
  593. result = d3d11Device->CreateBuffer( &indexBufferDesc, &indexData, &indexBuffer );
  594. D3D11_TEXTURE2D_DESC bufferDesc;
  595. memset( &bufferDesc, 0, sizeof( D3D11_TEXTURE2D_DESC ) );
  596. bufferDesc.ArraySize = 1;
  597. bufferDesc.Width = backBufferGröße.x;
  598. bufferDesc.Height = backBufferGröße.y;
  599. bufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
  600. bufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  601. bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  602. bufferDesc.SampleDesc.Count = 1;
  603. bufferDesc.MipLevels = 1;
  604. bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
  605. d3d11Device->CreateTexture2D( &bufferDesc, 0, &d3d11FrameworkBuffer );
  606. D3D11_SHADER_RESOURCE_VIEW_DESC resourceDesk;
  607. memset( &resourceDesk, 0, sizeof( D3D11_SHADER_RESOURCE_VIEW_DESC ) );
  608. resourceDesk.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
  609. resourceDesk.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
  610. resourceDesk.Texture2D.MipLevels = 1;
  611. d3d11Device->CreateShaderResourceView( d3d11FrameworkBuffer, &resourceDesk, &resource );
  612. //resource->Release();
  613. //result = D3DX11CreateShaderResourceViewFromFile( d3d11Device, "seafloor.dds", NULL, NULL, &resource, NULL );
  614. float left, right, top, bottom;
  615. // Calculate the screen coordinates of the left side of the bitmap.
  616. left = (float)( ( backBufferGröße.x / 2.0 ) * -1 );
  617. // Calculate the screen coordinates of the right side of the bitmap.
  618. right = left + (float)backBufferGröße.x;
  619. // Calculate the screen coordinates of the top of the bitmap.
  620. top = (float)( backBufferGröße.y / 2.0 );
  621. // Calculate the screen coordinates of the bottom of the bitmap.
  622. bottom = top - (float)backBufferGröße.y;
  623. // Load the vertex array with data.
  624. // First triangle.
  625. vertices[ 0 ].position = D3DXVECTOR3( left, top, 0.0f ); // Top left.
  626. vertices[ 0 ].texture = D3DXVECTOR2( 0.0f, 0.0f );
  627. vertices[ 1 ].position = D3DXVECTOR3( right, bottom, 0.0f ); // Bottom right.
  628. vertices[ 1 ].texture = D3DXVECTOR2( 1.0f, 1.0f );
  629. vertices[ 2 ].position = D3DXVECTOR3( left, bottom, 0.0f ); // Bottom left.
  630. vertices[ 2 ].texture = D3DXVECTOR2( 0.0f, 1.0f );
  631. // Second triangle.
  632. vertices[ 3 ].position = D3DXVECTOR3( left, top, 0.0f ); // Top left.
  633. vertices[ 3 ].texture = D3DXVECTOR2( 0.0f, 0.0f );
  634. vertices[ 4 ].position = D3DXVECTOR3( right, top, 0.0f ); // Top right.
  635. vertices[ 4 ].texture = D3DXVECTOR2( 1.0f, 0.0f );
  636. vertices[ 5 ].position = D3DXVECTOR3( right, bottom, 0.0f ); // Bottom right.
  637. vertices[ 5 ].texture = D3DXVECTOR2( 1.0f, 1.0f );
  638. D3D11_MAPPED_SUBRESOURCE mappedResource;
  639. // Lock the vertex buffer so it can be written to.
  640. result = d3d11Context->Map( vertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource );
  641. // Copy the data into the vertex buffer.
  642. memcpy( mappedResource.pData, (void*)vertices, ( sizeof( VertexType ) * 6 ) );
  643. // Unlock the vertex buffer.
  644. d3d11Context->Unmap( vertexBuffer, 0 );
  645. D3D11_BLEND_DESC blendState;
  646. ZeroMemory( &blendState, sizeof( D3D10_BLEND_DESC ) );
  647. blendState.AlphaToCoverageEnable = false;
  648. blendState.IndependentBlendEnable = false;
  649. blendState.RenderTarget[ 0 ].BlendEnable = true;
  650. blendState.RenderTarget[ 0 ].SrcBlend = D3D11_BLEND_SRC_ALPHA;
  651. blendState.RenderTarget[ 0 ].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
  652. blendState.RenderTarget[ 0 ].BlendOp = D3D11_BLEND_OP_ADD;
  653. blendState.RenderTarget[ 0 ].SrcBlendAlpha = D3D11_BLEND_ZERO;
  654. blendState.RenderTarget[ 0 ].DestBlendAlpha = D3D11_BLEND_ONE;
  655. blendState.RenderTarget[ 0 ].BlendOpAlpha = D3D11_BLEND_OP_ADD;
  656. blendState.RenderTarget[ 0 ].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
  657. d3d11Device->CreateBlendState( &blendState, &blendStateAlphaBlend );
  658. rend = 1;
  659. unlock();
  660. }
  661. void setTestRend( bool tr )
  662. {
  663. testRend = tr;
  664. }
  665. void setRenderZeichnungen( bool rO )
  666. {
  667. lock();
  668. renderZeichnungen = rO;
  669. rend = 1;
  670. unlock();
  671. }
  672. void setOnTop( bool onTop )
  673. {
  674. renderOnTop = onTop;
  675. rend = 1;
  676. }
  677. void setOnTopZeichnung( Zeichnung *obj )
  678. {
  679. lock();
  680. onTop = obj;
  681. rend = 1;
  682. unlock();
  683. }
  684. void setdeckFarbe( int f )
  685. {
  686. deckFarbe = f;
  687. rend = 1;
  688. }
  689. void addMember( Zeichnung *obj )
  690. {
  691. lock();
  692. members->addZeichnung( obj );
  693. members->updateIndex( 0 );
  694. rend = 1;
  695. unlock();
  696. }
  697. void removeMember( Zeichnung *obj )
  698. {
  699. lock();
  700. members->removeZeichnung( obj );
  701. members->updateIndex( 0 );
  702. rend = 1;
  703. unlock();
  704. }
  705. void render()
  706. {
  707. if( !rend && testRend )
  708. return;
  709. rendering = 1;
  710. int count = 0;
  711. if( renderB && d3d11Device )
  712. {
  713. lock();
  714. renderZeit->messungStart();
  715. float color[ 4 ];
  716. // Setup the color to clear the buffer to.
  717. color[ 0 ] = 0;
  718. color[ 1 ] = 0;
  719. color[ 2 ] = 0;
  720. color[ 3 ] = 0;
  721. // Clear the back buffer.
  722. d3d11Context->ClearRenderTargetView( rtview, color );
  723. // Clear the depth buffer.
  724. d3d11Context->ClearDepthStencilView( dsView, D3D11_CLEAR_DEPTH, 1.0f, 0 );
  725. if( füll )
  726. renderB->setFarbe( füllFarbe );
  727. if( renderZeichnungen )
  728. {
  729. if( renderOnTop && deckFarbe && ( deckFarbe & ( füllFarbe | 0xFF000000 ) ) == deckFarbe )
  730. {
  731. renderB->setAlpha( 255 - (unsigned char)( deckFarbe >> 24 ) );
  732. members->render( *renderB ); // zeichnen nach zwischenbuffer
  733. renderB->releaseAlpha();
  734. }
  735. else
  736. {
  737. members->render( *renderB ); // zeichnen nach zwischenbuffer
  738. if( renderOnTop && deckFarbe )
  739. renderB->alphaRegion( 0, 0, renderB->getBreite(), renderB->getHöhe(), deckFarbe );
  740. }
  741. for( int i = 0; i < tipAnzahl; ++i )
  742. tips->z( i )->render( *renderB );
  743. }
  744. if( renderOnTop && onTop )
  745. onTop->render( *renderB );
  746. Bild *tmp = renderB->getThis();
  747. unlock();
  748. // Beginne Bild
  749. HRESULT result;
  750. D3D11_MAPPED_SUBRESOURCE buffer;
  751. result = d3d11Context->Map( d3d11FrameworkBuffer, 0, D3D11_MAP::D3D11_MAP_WRITE_DISCARD, 0, &buffer );
  752. // kopieren zum Bildschrirm
  753. renderB->füllRegion( 100, 100, 100, 100, 0xFF0000FF );
  754. int *bgBuff = tmp->getBuffer();
  755. int tmpBr = sizeof( D3DCOLOR )* tmp->getBreite();
  756. for( int y = 0, pitch = 0, bry = 0; y < tmp->getHöhe(); ++y, pitch += buffer.RowPitch, bry += tmp->getBreite() )
  757. memcpy( &( (BYTE *)buffer.pData )[ pitch ], (void*)&( bgBuff[ bry ] ), tmpBr );
  758. // Beende Bild
  759. d3d11Context->Unmap( d3d11FrameworkBuffer, 0 );
  760. tmp->release();
  761. unsigned int stride = sizeof( VertexType );
  762. unsigned int offset = 0;
  763. d3d11Context->IASetVertexBuffers( 0, 1, &vertexBuffer, &stride, &offset );
  764. d3d11Context->IASetIndexBuffer( indexBuffer, DXGI_FORMAT_R32_UINT, 0 );
  765. d3d11Context->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
  766. D3D11_MAPPED_SUBRESOURCE mappedResource;
  767. MatrixBufferType* dataPtr;
  768. result = d3d11Context->Map( matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource );
  769. dataPtr = (MatrixBufferType*)mappedResource.pData;
  770. D3DXVECTOR3 up, position, lookAt;
  771. // Setup the vector that points upwards.
  772. up.x = 0.0f;
  773. up.y = 1.0f;
  774. up.z = 0.0f;
  775. // Setup the position of the camera in the world.
  776. position.x = 0;
  777. position.y = 0;
  778. position.z = -backBufferGröße.y * 1.2075;
  779. // Setup where the camera is looking by default.
  780. lookAt.x = 0.0f;
  781. lookAt.y = 0.0f;
  782. lookAt.z = 1.0f;
  783. // Finally create the view matrix from the three updated vectors.
  784. D3DXMatrixLookAtLH( &dataPtr->view, &position, &lookAt, &up );
  785. // Setup the projection matrix.
  786. //float fieldOfView = (float)D3DX_PI / 4.0f;
  787. float screenAspect = (float)backBufferGröße.x / (float)backBufferGröße.y;
  788. // Create the projection matrix for 3D rendering.
  789. D3DXMatrixPerspectiveFovLH( &dataPtr->projection, (float)D3DX_PI / 4.0f, screenAspect, 0.1, 10000 );
  790. // Copy the matrices into the constant buffer.
  791. D3DXMatrixIdentity( &dataPtr->world );
  792. D3DXMatrixTranspose( &dataPtr->world, &dataPtr->world );
  793. D3DXMatrixTranspose( &dataPtr->view, &dataPtr->view );
  794. D3DXMatrixTranspose( &dataPtr->projection, &dataPtr->projection );
  795. // Unlock the constant buffer.
  796. d3d11Context->Unmap( matrixBuffer, 0 );
  797. // Now set the constant buffer in the vertex shader with the updated values.
  798. d3d11Context->VSSetConstantBuffers( 0, 1, &matrixBuffer );
  799. // Set shader texture resource in the pixel shader.
  800. d3d11Context->PSSetShaderResources( 0, 1, &resource );
  801. // Set the vertex input layout.
  802. d3d11Context->IASetInputLayout( layout );
  803. // Set the vertex and pixel shaders that will be used to render this triangle.
  804. d3d11Context->VSSetShader( vertexShader, NULL, 0 );
  805. d3d11Context->PSSetShader( pixelShader, NULL, 0 );
  806. // Set the sampler state in the pixel shader.
  807. d3d11Context->PSSetSamplers( 0, 1, &sampleState );
  808. d3d11Context->OMSetBlendState( blendStateAlphaBlend, 0, 0xFFFFFFFF );
  809. d3d11Context->DrawIndexed( 6, 0, 0 );
  810. result = d3d11SpawChain->Present( 0, 0 );
  811. renderZeit->messungEnde();
  812. std::cout << renderZeit->getSekunden() << "\n";
  813. if( result != S_OK )
  814. {
  815. ++count;
  816. update();
  817. }
  818. else if( count )
  819. --count;
  820. }
  821. if( !d3d11Device )
  822. {
  823. ++count;
  824. update();
  825. }
  826. if( count > 10 )
  827. {
  828. WMessageBox( fenster ? fenster->getFensterHandle() : 0, new Text( "Fehler" ), new Text( "Es ist ein Fehler beim rendern aufgetreten." ), MB_ICONERROR );
  829. count = 0;
  830. }
  831. rendering = 0;
  832. rend = 0;
  833. }
  834. void setFüllFarbe( int f )
  835. {
  836. füllFarbe = f;
  837. rend = 1;
  838. }
  839. void setVollbild( bool fullscreen )
  840. {
  841. lock();
  842. this->vollbild = fullscreen;
  843. rend = 1;
  844. unlock();
  845. }
  846. void tick( double tickval )
  847. {
  848. lock();
  849. if( !renderOnTop )
  850. {
  851. for( int i = 0; i < tipAnzahl; ++i )
  852. rend |= tips->z( i )->tick( tickval );
  853. rend |= members->tick( tickval );
  854. }
  855. else if( onTop )
  856. {
  857. rend |= onTop->tick( tickval );
  858. for( int i = 0; i < tipAnzahl; ++i )
  859. rend |= tips->z( i )->tick( tickval );
  860. }
  861. unlock();
  862. }
  863. void setBackBufferGröße( int breite, int höhe )
  864. {
  865. lock();
  866. backBufferGröße.x = breite;
  867. backBufferGröße.y = höhe;
  868. rend = 1;
  869. unlock();
  870. }
  871. void setBackBufferGröße( Punkt &größe )
  872. {
  873. lock();
  874. backBufferGröße = größe;
  875. rend = 1;
  876. unlock();
  877. }
  878. void doMausEreignis( MausEreignis &me )
  879. {
  880. int fBr = backBufferGröße.x;
  881. int fHö = backBufferGröße.y;
  882. if( fenster )
  883. {
  884. fBr = fenster->getKörperBreite();
  885. fHö = fenster->getKörperHöhe();
  886. }
  887. me.mx = (int)( me.mx * backBufferGröße.x / (double)fBr + 0.5 );
  888. me.my = (int)( me.my * backBufferGröße.y / (double)fHö + 0.5 );
  889. lock();
  890. if( !renderOnTop )
  891. {
  892. for( int i = 0; i < tipAnzahl; ++i )
  893. tips->z( i )->doMausEreignis( me );
  894. members->sendMausAll( me );
  895. }
  896. else if( onTop )
  897. {
  898. onTop->doMausEreignis( me );
  899. for( int i = 0; i < tipAnzahl; ++i )
  900. tips->z( i )->doMausEreignis( me );
  901. }
  902. unlock();
  903. }
  904. void doTastaturEreignis( TastaturEreignis &te )
  905. {
  906. lock();
  907. if( !renderOnTop )
  908. members->sendTastaturAll( te );
  909. else if( onTop )
  910. onTop->doTastaturEreignis( te );
  911. unlock();
  912. }
  913. void addToolTip( ToolTip *tip )
  914. {
  915. lock();
  916. tips->add( tip, tipAnzahl );
  917. ++tipAnzahl;
  918. rend = 1;
  919. unlock();
  920. }
  921. bool removeToolTip( ToolTip *zTip )
  922. {
  923. lock();
  924. bool gefunden = 0;
  925. for( int i = 0; i < tipAnzahl; ++i )
  926. {
  927. ToolTip *tmp = tips->z( i );
  928. if( tmp == zTip )
  929. {
  930. tips->lösche( i );
  931. --tipAnzahl;
  932. gefunden = 1;
  933. rend = 1;
  934. break;
  935. }
  936. }
  937. unlock();
  938. return gefunden;
  939. }
  940. Bild *getRenderBild() const
  941. {
  942. return renderB->getThis();
  943. }
  944. Bild *zRenderBild() const
  945. {
  946. return renderB;
  947. }
  948. ZeichnungArray *getMembers() const
  949. {
  950. return members;
  951. }
  952. int getFüllFarbe() const
  953. {
  954. return füllFarbe;
  955. }
  956. bool istVolbild() const
  957. {
  958. return vollbild;
  959. }
  960. const Punkt &getBackBufferGröße() const
  961. {
  962. return backBufferGröße;
  963. }
  964. void warteAufRendern() const
  965. {
  966. while( rendering )
  967. {
  968. if( !rendering )
  969. return;
  970. }
  971. }
  972. double getRenderZeit() const
  973. {
  974. return renderZeit->getSekunden();
  975. }
  976. Bildschirm *getThis()
  977. {
  978. ++ref;
  979. return this;
  980. }
  981. Bildschirm *release()
  982. {
  983. --ref;
  984. if( !ref )
  985. delete this;
  986. return 0;
  987. }
  988. };
  989. }
  990. Bildschirm *bs;
  991. void FClose( void *p, void *zF )
  992. {
  993. StopNachrichtenSchleife( ( (WFenster*)zF )->getFensterHandle() );
  994. }
  995. int main()
  996. {
  997. initFramework();
  998. float a = 0xFF000000;
  999. int i = (int)a >> 24;
  1000. WFenster *f = new WFenster();
  1001. WNDCLASS fc = F_Normal( 0 );
  1002. fc.lpszClassName = "Test";
  1003. f->erstellen( WS_OVERLAPPEDWINDOW, fc );
  1004. f->setSize( 1600, 900 );
  1005. f->setVSchließAktion( FClose );
  1006. f->setMausAktion( _ret1ME );
  1007. f->setTastaturAktion( _ret1TE );
  1008. f->setAnzeigeModus( 1 );
  1009. bs = new Framework2::Bildschirm( f->getThis() );
  1010. f->setBildschirm( ( Framework::Bildschirm* )bs->getThis() );
  1011. bs->setTestRend( 0 );
  1012. RenderTh *r = new RenderTh();
  1013. r->setBildschirm( ( Framework::Bildschirm* )bs->getThis() );
  1014. r->setMaxFps( 60 );
  1015. r->beginn();
  1016. TextFeld *tf = new TextFeld();
  1017. tf->setPosition( 0, 0 );
  1018. tf->setGröße( 1600, 900 );
  1019. tf->setStyle( TextFeld::Style::TextFeld | TextFeld::Style::Hintergrund );
  1020. tf->setLinienRahmenFarbe( 0xFFFF0000 );
  1021. tf->setLinienRahmenBreite( 1 );
  1022. tf->setAlphaFeldFarbe( 0xFF00FF00 );
  1023. tf->setAlphaFeldStärke( 10 );
  1024. tf->setHintergrundFarbe( 0xFF0000FF );
  1025. bs->addMember( tf );
  1026. StartNachrichtenSchleife();
  1027. r->beenden();
  1028. r->release();
  1029. f->setBildschirm( 0 );
  1030. bs->release();
  1031. f->release();
  1032. tf->release();
  1033. releaseFramework();
  1034. getchar();
  1035. return 0;
  1036. }