2012-07-30 00:08:07 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 18:06:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2013-01-09 07:27:05 +01:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2012-07-22 19:54:04 +02:00
|
|
|
|
2014-05-28 21:14:11 +02:00
|
|
|
#include "image.h"
|
2014-09-14 06:45:47 +02:00
|
|
|
#include "../d3d/d3d_wrapper.h"
|
2012-07-23 16:38:29 +02:00
|
|
|
|
2014-06-17 17:44:48 +02:00
|
|
|
bool texture_image_load(struct texture_image *out_img, const char *path)
|
2012-07-22 19:54:04 +02:00
|
|
|
{
|
2012-08-05 17:18:19 +02:00
|
|
|
D3DXIMAGE_INFO m_imageInfo;
|
2015-01-26 19:26:06 +01:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2012-07-29 23:24:39 +02:00
|
|
|
|
2012-08-05 17:18:19 +02:00
|
|
|
out_img->vertex_buf = NULL;
|
2012-07-30 00:08:07 +02:00
|
|
|
|
2014-09-13 18:11:15 +02:00
|
|
|
out_img->pixels = d3d_texture_new(d3d->dev, path,
|
|
|
|
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0,
|
|
|
|
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT,
|
|
|
|
D3DX_DEFAULT, 0, &m_imageInfo, NULL);
|
|
|
|
|
|
|
|
if (!out_img->pixels)
|
2012-08-04 03:50:10 +02:00
|
|
|
return false;
|
2012-07-22 19:54:04 +02:00
|
|
|
|
2014-09-09 06:59:17 +02:00
|
|
|
/* create a vertex buffer for the quad that will display the texture */
|
2014-09-13 17:58:38 +02:00
|
|
|
out_img->vertex_buf = (LPDIRECT3DVERTEXBUFFER)d3d_vertex_buffer_new(
|
|
|
|
d3d->dev, 4 * sizeof(Vertex), D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX,
|
|
|
|
D3DPOOL_MANAGED, NULL);
|
|
|
|
|
|
|
|
if (!out_img->vertex_buf)
|
2012-08-04 03:50:10 +02:00
|
|
|
{
|
2014-09-13 18:11:15 +02:00
|
|
|
d3d_texture_free(out_img->pixels);
|
2012-08-04 03:50:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
2013-01-09 07:27:05 +01:00
|
|
|
|
2012-08-05 17:18:19 +02:00
|
|
|
out_img->width = m_imageInfo.Width;
|
|
|
|
out_img->height = m_imageInfo.Height;
|
2012-07-22 19:54:04 +02:00
|
|
|
|
2012-08-04 03:50:10 +02:00
|
|
|
return true;
|
2012-07-22 19:54:04 +02:00
|
|
|
}
|
2013-12-31 19:16:29 +01:00
|
|
|
|
2014-06-17 17:44:48 +02:00
|
|
|
void texture_image_free(struct texture_image *img)
|
2013-12-31 19:16:29 +01:00
|
|
|
{
|
2014-05-10 20:26:58 +02:00
|
|
|
if (!img)
|
|
|
|
return;
|
|
|
|
|
2014-09-13 18:11:15 +02:00
|
|
|
d3d_vertex_buffer_free(img->vertex_buf);
|
|
|
|
d3d_texture_free(img->pixels);
|
2013-12-31 19:16:29 +01:00
|
|
|
memset(img, 0, sizeof(*img));
|
|
|
|
}
|