Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
InitScene() { HRESULT hResult; ShowCursor(FALSE); hResult = Device->SetFVF(LOCAL_FVF); //Render States Device->SetRenderState(D3DRS_DITHERENABLE, TRUE); Device->SetRenderState(D3DRS_ZENABLE, FALSE); //Sampler States Device->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR); Device->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR); Device->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR); // Direct3D soll den Alphakanal der Texturen und den Alphawert der Streufarbe verwenden. Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE); //Getting Texture hResult = D3DXCreateTextureFromFileEx(Device, // Device "Sphere.bmp", // Dateiname D3DX_DEFAULT, // Breite D3DX_DEFAULT, // Höhe D3DX_DEFAULT, // MIP-Maps 0, // Verwendungszweck D3DFMT_UNKNOWN, // Format D3DPOOL_MANAGED, // Speicherklasse D3DX_FILTER_NONE, // Filter D3DX_FILTER_LINEAR, // MIP-Map-Filter 0, // Color-Key NULL, // Unwichtig NULL, // Unwichtig &pTexture); // Die Textur if(hResult != D3D_OK) { MessageBox(NULL,"Could not load texture!","Fatal Error!",MB_OK|MB_ICONERROR); return false; } D3DXLoadMeshFromX("Box.x",D3DXMESH_MANAGED,Device,&ppBoxXBuffer,NULL,NULL,NULL,&ppStdBoxMesh); //Creating Projection-Matrix D3DXMatrixPerspectiveFovLH(&mProjection,1.0f , fAspect, 0.1f, 100.0f); Device->SetTransform(D3DTS_PROJECTION,&mProjection); //Filling Identity-Matrix D3DXMatrixIdentity(&mIdentity); bLoaded = true; return true; }; |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
´ Render() { HRESULT hResult; Device->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,D3DCOLOR_XRGB(0,0,0),1.0f,0); Device->BeginScene(); vTranslation = D3DXVECTOR3(0.0f,0.0f,5.0f); D3DXMatrixTranslation(&mTranslation,vTranslation.x,vTranslation.y,vTranslation.z); mWorld = mIdentity*mTranslation; Device->SetTransform(D3DTS_WORLD,&mWorld); Device->SetRenderState(D3DRS_LIGHTING, TRUE); ZeroMemory(&DxLight, sizeof(D3DLIGHT9)); DxLight.Type = D3DLIGHT_POINT; DxLight.Diffuse = tbColor(1.0f, 1.0f, 0.75f); DxLight.Ambient = tbColor(1.0f, 1.0f, 0.75f); DxLight.Position = D3DXVECTOR3(0.0f,0.0f,0.0f); DxLight.Range = 1000.0f; DxLight.Attenuation0 = 1.0f; DxLight.Attenuation1 = 0.0f; DxLight.Attenuation2 = 0.0f; Device->SetLight(0, &DxLight); Device->LightEnable(0, TRUE); Device->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR); Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCCOLOR); DxMaterial.Diffuse = tbColor(1.0f, 0.0f, 0.0f, 0.0f); DxMaterial.Ambient = tbColor(0.0f, 1.0f, 0.0f); DxMaterial.Emissive = tbColor(1.0f, 1.0f, 0.75f); DxMaterial.Power = 5.0f; Device->SetMaterial(&DxMaterial); Device->SetTexture(0,pTexture); Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); ppStdBoxMesh->DrawSubset(0); Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); ppStdBoxMesh->DrawSubset(0); //hResult = Device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); Device->EndScene(); Device->Present(NULL,NULL,NULL,NULL); return true; } |
Administrator
Quellcode |
|
1 2 |
Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR); Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCCOLOR); |
Werbeanzeige