1
J'ai un tampon contenant une texture BGRA "brute" avec un octet par couleur. Les lignes sont dans l'ordre inverse (la texture est à l'envers).BGRA -> RGBA et bascule verticale, OptiX
Le tampon BGRA est tout en vert (0, 255, 0, 255).
Je dois convertir cela en RGBA et inverser les lignes de textures. Je essayé ceci:
// bgra is an unsigned char*
int width = 1366;
int height = 768;
unsigned char* rgba = new unsigned char[width * height * 4];
for(int y = height - 1; y >= 0; y--)
{
for(int x = 0; x < width; x++)
{
rgba[(x * y * 4)] = bgra[(x * y * 4) + 2];
rgba[(x * y * 4) + 1] = bgra[(x * y * 4) + 1];
rgba[(x * y * 4) + 2] = bgra[(x * y * 4)];
rgba[(x * y * 4) + 3] = bgra[(x * y * 4) + 3];
}
}
Mais le résultat au moment du rendu est pas un écran vert plein, mais ceci:
Que pourrais-je faire mal ici?
Merci, mon indexation était éteint. Mais, ce n'était pas mon seul problème. Question éditée. – EClaesson
L'indexation était le problème et il a été cassé plus bas dans le code. Merci. – EClaesson