ccdemos/common_sdl.h
branchpyrit
changeset 89 fcf1487b398b
parent 81 9dbb9c8c115b
child 90 f6a72eb99631
equal deleted inserted replaced
88:f7edb3b90816 89:fcf1487b398b
    26 	if (SDL_MUSTLOCK(screen))
    26 	if (SDL_MUSTLOCK(screen))
    27 		if (SDL_LockSurface(screen) < 0)
    27 		if (SDL_LockSurface(screen) < 0)
    28 			return;
    28 			return;
    29 
    29 
    30 	Uint32 *bufp = (Uint32 *)screen->pixels;
    30 	Uint32 *bufp = (Uint32 *)screen->pixels;
    31 	unsigned char c[3];
       
    32 	for (Float *fd = render_buffer; fd != render_buffer + w*h*3; fd += 3)
    31 	for (Float *fd = render_buffer; fd != render_buffer + w*h*3; fd += 3)
    33 	{
    32 	{
       
    33 #ifdef NO_SSE
       
    34 		unsigned char c[3];
    34 		for (int i = 0; i < 3; i++)
    35 		for (int i = 0; i < 3; i++)
    35 		{
    36 		{
    36 			if (fd[i] > 1.0)
    37 			if (fd[i] > 1.0)
    37 				c[i] = 255;
    38 				c[i] = 255;
    38 			else
    39 			else
    39 				c[i] = (unsigned char)(fd[i] * 255.0);
    40 				c[i] = (unsigned char)(fd[i] * 255.0);
    40 		}
    41 		}
    41 		*bufp = SDL_MapRGB(screen->format, c[0], c[1], c[2]);
    42 		*bufp = SDL_MapRGB(screen->format, c[0], c[1], c[2]);
       
    43 #else
       
    44 		__m64 m = _mm_cvtps_pi8(_mm_mul_ps(_mm_set_ps1(255.0),
       
    45 			_mm_min_ps(mOne, _mm_set_ps(0, fd[2],fd[1],fd[0]))));
       
    46 		*bufp = SDL_MapRGB(screen->format, ((char*)&m)[0], ((char*)&m)[1], ((char*)&m)[2]);
       
    47 #endif
    42 		bufp++;
    48 		bufp++;
    43 	}
    49 	}
    44 
    50 
    45 	if (SDL_MUSTLOCK(screen))
    51 	if (SDL_MUSTLOCK(screen))
    46 		SDL_UnlockSurface(screen);
    52 		SDL_UnlockSurface(screen);