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 |
CrearTexturaLightmap(int indice, byte pMapaDeBits[128][128][3], int ancho, int alto) { D3DXCreateTexture(m_pD3DDev,128,128,0,0,D3DFMT_R5G6B5,D3DPOOL_MANAGED,&m_pLightmap[i]); IDirect3DSurface8 *TextureSurface; m_pLightmap[indice]->GetSurfaceLevel(0, &TextureSurface); D3DLOCKED_RECT pLockedRect; RECT rectangleToLock; rectangleToLock.top = 0; rectangleToLock.left = 0; rectangleToLock.bottom = 128; rectangleToLock.right = 128; if(FAILED(TextureSurface->LockRect(&pLockedRect,NULL,0 ))) PostQuitMessage(0); USHORT* pData = (USHORT*)pLockedRect.pBits; for(int p = 0; p<128;p++) { for(int q = 0; q<128; q++) { WORD r = pMapaDeBits[q][p][0]>>3; WORD g = pMapaDeBits[q][p][1]>>2; WORD b = pMapaDeBits[q][p][2]>>3; WORD lightmap_pixel_565 =RGB_16BIT565 (r,g,b); pData[(q * (pLockedRect.Pitch/2)) + p] = lightmap_pixel_565; } } if(FAILED(TextureSurface->UnlockRect())) PostQuitMessage(0); TextureSurface->Release(); } |
Administrator
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 |
void WINAPI fillCallback(D3DXVECTOR4* p_out, const D3DXVECTOR2* p_coords, const D3DXVECTOR2* p_texelSize, void* p_data) { int x = (int)(p_coords->x * 127); int y = (int)(p_coords->y * 127); BYTE* p_rgb = (BYTE*)(p_data); p_out->x = (float)(p_rgb[y * 384 + x * 3]) / 255.0f; p_out->y = (float)(p_rgb[y * 384 + x * 3 + 1]) / 255.0f; p_out->z = (float)(p_rgb[y * 384 + x * 3 + 2]) / 255.0f; p_out->w = 1.0f; } LPDIRECT3DTEXTURE9 createLightMap(BYTE* p_data, D3DFORMAT format, UINT numLevels, LPDIRECT3DDEVICE9 p_d3dDevice) { LPDIRECT3DTEXTURE9 p_texture; // Textur erstellen D3DXCreateTexture(p_d3dDevice, 128, 128, numLevels, D3DUSAGE_WRITEONLY, format, D3DPOOL_DEFAULT, &p_texture); // Textur mit den Daten füllen D3DXFillTexture(p_texture, fillCallback, p_data); return p_texture; } |
Quellcode |
|
1 |
g_pD3DLightmaps[i] = createLightMap((unsigned char *)(&g_pLightmaps[i].imageBits), D3DFMT_X8R8G8B8, 4, g_pD3DDevice); |
Administrator
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void WINAPI fillCallback(D3DXVECTOR4* p_out, const D3DXVECTOR2* p_coords, const D3DXVECTOR2* p_texelSize, void* p_data) { int x = (int)(p_coords->x * 127); int y = (int)(p_coords->y * 127); BYTE* p_rgb = (BYTE*)(p_data); //D3DXVECTOR4 pixel; p_out->x = p_rgb[y * 384 + 3 * x]; p_out->y = p_rgb[y * 384 + 3 * x + 1]; p_out->z = p_rgb[y * 384 + 3 * x + 2]; p_out->w = 1.0f; //return pixel; } |
Quellcode |
|
1 |
g_pD3DLightmaps[i] = createLightMap((unsigned char *)(g_pLightmaps[i].imageBits), D3DFMT_X8R8G8B8, 4, g_pD3DDevice); |
Quellcode |
|
1 |
g_pD3DLightmaps[i] = createLightMap((unsigned char *)g_pLightmaps[i].imageBits, D3DFMT_X8R8G8B8, 4, g_pD3DDevice); |
Administrator
Administrator
Administrator
Werbeanzeige