2012-10-26 19:09:30 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2013-12-31 22:26:12 +00:00
|
|
|
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2013 - Daniel De Matteis
|
2012-10-26 19:09:30 +00: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef D3DVIDEO_HPP__
|
|
|
|
#define D3DVIDEO_HPP__
|
|
|
|
|
|
|
|
#include "../../general.h"
|
|
|
|
#include "../../driver.h"
|
2013-04-06 19:26:27 +00:00
|
|
|
#include "../shader_parse.h"
|
2012-10-26 19:09:30 +00:00
|
|
|
|
2013-04-07 17:34:44 +00:00
|
|
|
#include "../gfx_common.h"
|
|
|
|
|
2012-10-26 19:09:30 +00:00
|
|
|
#include <d3d9.h>
|
|
|
|
#include <d3dx9.h>
|
|
|
|
#include <d3dx9core.h>
|
2012-11-14 00:13:08 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CG
|
2012-10-26 19:09:30 +00:00
|
|
|
#include <Cg/cg.h>
|
|
|
|
#include <Cg/cgD3D9.h>
|
2012-11-14 00:13:08 +00:00
|
|
|
#endif
|
2013-12-31 23:58:21 +00:00
|
|
|
#include "d3d_defines.h"
|
2012-10-26 19:09:30 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class RenderChain;
|
|
|
|
|
2013-04-07 17:34:44 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct Coords
|
|
|
|
{
|
|
|
|
float x, y, w, h;
|
|
|
|
};
|
|
|
|
Coords tex_coords;
|
|
|
|
Coords vert_coords;
|
|
|
|
unsigned tex_w, tex_h;
|
|
|
|
bool fullscreen;
|
2013-10-21 11:26:23 +00:00
|
|
|
bool enabled;
|
2013-04-07 17:34:44 +00:00
|
|
|
float alpha_mod;
|
2013-12-31 23:27:55 +00:00
|
|
|
LPDIRECT3DTEXTURE tex;
|
|
|
|
LPDIRECT3DVERTEXBUFFER vert_buf;
|
2013-04-07 17:34:44 +00:00
|
|
|
} overlay_t;
|
|
|
|
|
2012-10-26 19:09:30 +00:00
|
|
|
class D3DVideo
|
|
|
|
{
|
|
|
|
public:
|
2013-12-31 22:19:51 +00:00
|
|
|
D3DVideo(const video_info_t* info, const input_driver_t **input,
|
|
|
|
void **input_data);
|
2012-10-26 19:09:30 +00:00
|
|
|
bool frame(const void* frame,
|
|
|
|
unsigned width, unsigned height, unsigned pitch,
|
|
|
|
const char *msg);
|
|
|
|
~D3DVideo();
|
|
|
|
|
|
|
|
bool alive();
|
|
|
|
bool focus() const;
|
|
|
|
void set_nonblock_state(bool state);
|
|
|
|
void set_rotation(unsigned rot);
|
2012-10-27 22:38:31 +00:00
|
|
|
void viewport_info(rarch_viewport &vp);
|
2012-10-26 19:09:30 +00:00
|
|
|
bool read_viewport(uint8_t *buffer);
|
2012-10-30 22:49:48 +00:00
|
|
|
void resize(unsigned new_width, unsigned new_height);
|
2012-10-31 15:28:09 +00:00
|
|
|
bool set_shader(const std::string &path);
|
2013-12-31 23:00:01 +00:00
|
|
|
int process_shader(void);
|
2012-10-26 19:09:30 +00:00
|
|
|
|
2013-04-07 17:34:44 +00:00
|
|
|
void set_filtering(unsigned index, bool smooth);
|
|
|
|
void set_font_rect(font_params_t *params);
|
|
|
|
|
|
|
|
void overlay_render(overlay_t &overlay);
|
|
|
|
|
2013-12-31 22:19:51 +00:00
|
|
|
void show_cursor(bool show);
|
|
|
|
|
2013-03-27 14:55:59 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2013-12-31 18:03:58 +00:00
|
|
|
bool overlay_load(const texture_image *images, unsigned num_images);
|
2013-10-21 11:26:23 +00:00
|
|
|
void overlay_tex_geom(unsigned index, float x, float y, float w, float h);
|
|
|
|
void overlay_vertex_geom(unsigned index, float x, float y, float w, float h);
|
2013-03-27 14:55:59 +00:00
|
|
|
void overlay_enable(bool state);
|
|
|
|
void overlay_full_screen(bool enable);
|
2013-10-21 11:26:23 +00:00
|
|
|
void overlay_set_alpha(unsigned index, float mod);
|
2013-03-27 14:55:59 +00:00
|
|
|
#endif
|
|
|
|
|
2013-11-08 03:36:16 +00:00
|
|
|
#ifdef HAVE_MENU
|
2013-04-07 17:34:44 +00:00
|
|
|
void set_rgui_texture_frame(const void *frame,
|
|
|
|
bool rgb32, unsigned width, unsigned height,
|
|
|
|
float alpha);
|
2013-04-13 14:58:05 +00:00
|
|
|
void set_rgui_texture_enable(bool state, bool fullscreen);
|
2013-04-07 17:34:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
bool restore();
|
|
|
|
void render_msg(const char *msg, font_params_t *params = nullptr);
|
|
|
|
|
2013-04-21 12:04:16 +00:00
|
|
|
bool should_resize;
|
2013-04-21 09:20:56 +00:00
|
|
|
inline video_info_t& info() { return video_info; }
|
|
|
|
|
2012-10-26 19:09:30 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
WNDCLASSEX windowClass;
|
|
|
|
HWND hWnd;
|
2013-12-31 23:27:55 +00:00
|
|
|
LPDIRECT3D g_pD3D;
|
|
|
|
LPDIRECT3DDEVICE dev;
|
2012-10-26 19:09:30 +00:00
|
|
|
LPD3DXFONT font;
|
|
|
|
|
2013-04-21 12:04:16 +00:00
|
|
|
void recompute_pass_sizes();
|
2012-10-26 19:09:30 +00:00
|
|
|
void calculate_rect(unsigned width, unsigned height, bool keep, float aspect);
|
2013-04-21 09:20:56 +00:00
|
|
|
void set_viewport(int x, int y, unsigned width, unsigned height);
|
2012-10-26 19:09:30 +00:00
|
|
|
unsigned screen_width;
|
|
|
|
unsigned screen_height;
|
|
|
|
unsigned rotation;
|
2013-12-31 23:27:55 +00:00
|
|
|
D3DVIEWPORT final_viewport;
|
2012-10-26 19:09:30 +00:00
|
|
|
|
|
|
|
std::string cg_shader;
|
|
|
|
|
2013-04-06 19:26:27 +00:00
|
|
|
struct gfx_shader shader;
|
|
|
|
|
2013-12-31 22:19:51 +00:00
|
|
|
void process(void);
|
2012-10-26 19:09:30 +00:00
|
|
|
|
2013-12-31 22:49:45 +00:00
|
|
|
int init(const video_info_t *info);
|
|
|
|
int init_base(const video_info_t *info);
|
2013-12-31 22:19:51 +00:00
|
|
|
void make_d3dpp(const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp);
|
|
|
|
void deinit(void);
|
|
|
|
RECT monitor_rect(void);
|
2013-04-21 09:20:56 +00:00
|
|
|
|
2012-10-26 19:09:30 +00:00
|
|
|
video_info_t video_info;
|
|
|
|
|
|
|
|
bool needs_restore;
|
|
|
|
|
2012-11-14 00:13:08 +00:00
|
|
|
#ifdef HAVE_CG
|
2012-10-26 19:09:30 +00:00
|
|
|
CGcontext cgCtx;
|
|
|
|
bool init_cg();
|
|
|
|
void deinit_cg();
|
2012-11-14 00:13:08 +00:00
|
|
|
#endif
|
2012-10-26 19:09:30 +00:00
|
|
|
|
2013-12-31 23:00:01 +00:00
|
|
|
int init_imports(void);
|
2013-12-31 22:19:51 +00:00
|
|
|
void init_luts(void);
|
2013-12-31 23:00:01 +00:00
|
|
|
int init_singlepass(void);
|
|
|
|
int init_multipass(void);
|
2013-12-31 22:19:51 +00:00
|
|
|
bool init_chain(const video_info_t *video_info);
|
2012-10-26 19:09:30 +00:00
|
|
|
std::unique_ptr<RenderChain> chain;
|
2013-12-31 22:19:51 +00:00
|
|
|
void deinit_chain(void);
|
2012-10-26 19:09:30 +00:00
|
|
|
|
2013-12-31 22:19:51 +00:00
|
|
|
bool init_font(void);
|
|
|
|
void deinit_font(void);
|
2012-10-26 19:09:30 +00:00
|
|
|
RECT font_rect;
|
|
|
|
RECT font_rect_shifted;
|
|
|
|
uint32_t font_color;
|
|
|
|
|
2013-12-31 22:19:51 +00:00
|
|
|
void update_title(void);
|
2013-03-27 14:55:59 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_OVERLAY
|
2013-10-21 11:26:23 +00:00
|
|
|
bool overlays_enabled;
|
|
|
|
std::vector<overlay_t> overlays;
|
|
|
|
void free_overlays();
|
2013-04-07 17:34:44 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-21 11:26:23 +00:00
|
|
|
void free_overlay(overlay_t &overlay);
|
|
|
|
|
2013-11-08 03:36:16 +00:00
|
|
|
#ifdef HAVE_MENU
|
2013-04-07 17:34:44 +00:00
|
|
|
overlay_t rgui;
|
2013-03-27 14:55:59 +00:00
|
|
|
#endif
|
2012-10-26 19:09:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|