@@ -19,6 +19,10 @@ | |||||
# define FAR | # define FAR | ||||
# define NEAR | # define NEAR | ||||
# include <d3d9.h> | # include <d3d9.h> | ||||
#elif defined _XBOX | |||||
# include <xtl.h> | |||||
# undef near /* Fuck Microsoft */ | |||||
# undef far /* Fuck Microsoft again */ | |||||
#endif | #endif | ||||
using namespace std; | using namespace std; | ||||
@@ -44,7 +48,7 @@ class FramebufferData | |||||
IDirect3DTexture9 *m_texture; | IDirect3DTexture9 *m_texture; | ||||
IDirect3DSurface9 *m_surface, *m_back_surface; | IDirect3DSurface9 *m_surface, *m_back_surface; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DTexture *m_texture; | D3DTexture *m_texture; | ||||
D3DSurface *m_surface, *m_back_surface; | D3DSurface *m_surface, *m_back_surface; | ||||
#else | #else | ||||
@@ -61,7 +65,7 @@ uint32_t FramebufferFormat::GetFormat() | |||||
{ | { | ||||
switch (m_format) | switch (m_format) | ||||
{ | { | ||||
#if defined USE_D3D9 || defined _XBOX | |||||
#if defined USE_D3D9 | |||||
case R_16_F: return D3DFMT_R16F; | case R_16_F: return D3DFMT_R16F; | ||||
case R_32_F: return D3DFMT_R32F; | case R_32_F: return D3DFMT_R32F; | ||||
case RG_16: | case RG_16: | ||||
@@ -80,6 +84,25 @@ uint32_t FramebufferFormat::GetFormat() | |||||
case RGBA_16_UI: return D3DFMT_A16B16G16R16; | case RGBA_16_UI: return D3DFMT_A16B16G16R16; | ||||
case RGBA_16_F: return D3DFMT_A16B16G16R16F; | case RGBA_16_F: return D3DFMT_A16B16G16R16F; | ||||
case RGBA_32_F: return D3DFMT_A32B32G32R32F; | case RGBA_32_F: return D3DFMT_A32B32G32R32F; | ||||
#elif defined _XBOX | |||||
case R_16_F: return D3DFMT_R16F; | |||||
case R_32_F: return D3DFMT_R32F; | |||||
case RG_16: | |||||
case RG_16_I: | |||||
case RG_16_UI: return D3DFMT_G16R16; | |||||
case RG_16_F: return D3DFMT_G16R16F; | |||||
case RG_32_F: return D3DFMT_G32R32F; | |||||
case RGB_8: | |||||
case RGB_8_I: | |||||
case RGB_8_UI: return D3DFMT_X8R8G8B8; | |||||
case RGBA_8: | |||||
case RGBA_8_I: | |||||
case RGBA_8_UI: return D3DFMT_A8R8G8B8; | |||||
case RGBA_16: | |||||
case RGBA_16_I: | |||||
case RGBA_16_UI: return D3DFMT_A16B16G16R16; | |||||
case RGBA_16_F: return D3DFMT_A16B16G16R16F; | |||||
case RGBA_32_F: return D3DFMT_A32B32G32R32F; | |||||
#elif defined __CELLOS_LV2__ | #elif defined __CELLOS_LV2__ | ||||
/* Supported drawable formats on the PS3: GL_ARGB_SCE, GL_RGB16F_ARB, | /* Supported drawable formats on the PS3: GL_ARGB_SCE, GL_RGB16F_ARB, | ||||
* GL_RGBA16F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB, GL_LUMINANCE32F_ARB. */ | * GL_RGBA16F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB, GL_LUMINANCE32F_ARB. */ | ||||
@@ -291,23 +314,25 @@ Framebuffer::Framebuffer(ivec2 size, FramebufferFormat fbo_format) | |||||
m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
if (FAILED(m_data->m_dev->CreateTexture(size.x, size.y, 1, | if (FAILED(m_data->m_dev->CreateTexture(size.x, size.y, 1, | ||||
D3DUSAGE_RENDERTARGET, | |||||
(D3DFORMAT)fbo_format.GetFormat(), D3DPOOL_DEFAULT, | |||||
&m_data->m_texture, nullptr))) | |||||
D3DUSAGE_RENDERTARGET, | |||||
(D3DFORMAT)fbo_format.GetFormat(), | |||||
D3DPOOL_DEFAULT, | |||||
&m_data->m_texture, nullptr))) | |||||
Abort(); | Abort(); | ||||
if (FAILED(m_data->m_texture->GetSurfaceLevel(0, &m_data->m_surface))) | if (FAILED(m_data->m_texture->GetSurfaceLevel(0, &m_data->m_surface))) | ||||
Abort(); | Abort(); | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
m_data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
m_data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
if (FAILED(m_data->m_dev->CreateTexture(size.x, size.y, 1, 0, | if (FAILED(m_data->m_dev->CreateTexture(size.x, size.y, 1, 0, | ||||
fbo_format.GetFormat(), D3DPOOL_DEFAULT, | |||||
&m_data->m_texture, nullptr))) | |||||
(D3DFORMAT)fbo_format.GetFormat(), | |||||
D3DPOOL_DEFAULT, | |||||
&m_data->m_texture, nullptr))) | |||||
Abort(); | Abort(); | ||||
if (FAILED(m_data->m_dev->CreateRenderTarget(size.x, size.y, | if (FAILED(m_data->m_dev->CreateRenderTarget(size.x, size.y, | ||||
fbo_format.GetFormat(), | |||||
D3DMULTISAMPLE_NONE, 0, 0, | |||||
&m_data->m_surface, nullptr))) | |||||
(D3DFORMAT)fbo_format.GetFormat(), | |||||
D3DMULTISAMPLE_NONE, 0, 0, | |||||
&m_data->m_surface, nullptr))) | |||||
Abort(); | Abort(); | ||||
#else | #else | ||||
# if GL_VERSION_1_1 | # if GL_VERSION_1_1 | ||||
@@ -19,6 +19,10 @@ | |||||
# define FAR | # define FAR | ||||
# define NEAR | # define NEAR | ||||
# include <d3d9.h> | # include <d3d9.h> | ||||
#elif defined _XBOX | |||||
# include <xtl.h> | |||||
# undef near /* Fuck Microsoft */ | |||||
# undef far /* Fuck Microsoft again */ | |||||
#endif | #endif | ||||
using namespace std; | using namespace std; | ||||
@@ -41,7 +45,7 @@ class IndexBufferData | |||||
IDirect3DDevice9 *m_dev; | IDirect3DDevice9 *m_dev; | ||||
IDirect3DIndexBuffer9 *m_ibo; | IDirect3DIndexBuffer9 *m_ibo; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DIndexBuffer *m_ibo; | D3DIndexBuffer *m_ibo; | ||||
#else | #else | ||||
GLuint m_ibo; | GLuint m_ibo; | ||||
@@ -64,7 +68,7 @@ IndexBuffer::IndexBuffer(size_t size) | |||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
# elif defined _XBOX | # elif defined _XBOX | ||||
m_data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
m_data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
# endif | # endif | ||||
if (FAILED(m_data->m_dev->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY, | if (FAILED(m_data->m_dev->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY, | ||||
@@ -97,7 +97,7 @@ Renderer::Renderer(ivec2 size) | |||||
XVIDEO_MODE VideoMode; | XVIDEO_MODE VideoMode; | ||||
XGetVideoMode(&VideoMode); | XGetVideoMode(&VideoMode); | ||||
size = lol::min(size, ivec2(VideoMode.dwDisplayWidth, | size = lol::min(size, ivec2(VideoMode.dwDisplayWidth, | ||||
VideoMode.dwDisplayHeight); | |||||
VideoMode.dwDisplayHeight)); | |||||
# endif | # endif | ||||
D3DPRESENT_PARAMETERS d3dpp; | D3DPRESENT_PARAMETERS d3dpp; | ||||
memset(&d3dpp, 0, sizeof(d3dpp)); | memset(&d3dpp, 0, sizeof(d3dpp)); | ||||
@@ -15,7 +15,7 @@ | |||||
#include <cstring> | #include <cstring> | ||||
#include <cstdio> | #include <cstdio> | ||||
#ifdef WIN32 | |||||
#if defined WIN32 && !defined _XBOX | |||||
# define WIN32_LEAN_AND_MEAN | # define WIN32_LEAN_AND_MEAN | ||||
# include <windows.h> | # include <windows.h> | ||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
@@ -25,6 +25,10 @@ | |||||
# include <d3d9.h> | # include <d3d9.h> | ||||
# include <d3dx9shader.h> | # include <d3dx9shader.h> | ||||
# endif | # endif | ||||
#elif defined _XBOX | |||||
# include <xtl.h> | |||||
# undef near /* Fuck Microsoft */ | |||||
# undef far /* Fuck Microsoft again */ | |||||
#endif | #endif | ||||
#include "core.h" | #include "core.h" | ||||
@@ -50,7 +54,7 @@ private: | |||||
IDirect3DPixelShader9 *frag_shader; | IDirect3DPixelShader9 *frag_shader; | ||||
ID3DXConstantTable *vert_table, *frag_table; | ID3DXConstantTable *vert_table, *frag_table; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DVertexShader *vert_shader; | D3DVertexShader *vert_shader; | ||||
D3DPixelShader *frag_shader; | D3DPixelShader *frag_shader; | ||||
ID3DXConstantTable *vert_table, *frag_table; | ID3DXConstantTable *vert_table, *frag_table; | ||||
@@ -192,7 +196,7 @@ Shader::Shader(char const *vert, char const *frag) | |||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
# elif defined _XBOX | # elif defined _XBOX | ||||
data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
# endif | # endif | ||||
hr = D3DXCompileShader(vert, (UINT)strlen(vert), macros, nullptr, "main", | hr = D3DXCompileShader(vert, (UINT)strlen(vert), macros, nullptr, "main", | ||||
@@ -45,8 +45,11 @@ class TextureData | |||||
D3DTEXTUREFILTERTYPE m_min_filter; | D3DTEXTUREFILTERTYPE m_min_filter; | ||||
D3DTEXTUREFILTERTYPE m_mip_filter; | D3DTEXTUREFILTERTYPE m_mip_filter; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DTexture *m_texture; | D3DTexture *m_texture; | ||||
D3DTEXTUREFILTERTYPE m_mag_filter; | |||||
D3DTEXTUREFILTERTYPE m_min_filter; | |||||
D3DTEXTUREFILTERTYPE m_mip_filter; | |||||
#else | #else | ||||
GLuint m_texture; | GLuint m_texture; | ||||
GLint m_internal_format; | GLint m_internal_format; | ||||
@@ -74,7 +77,7 @@ Texture::Texture(ivec2 size, PixelFormat format) | |||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
# elif defined _XBOX | # elif defined _XBOX | ||||
m_data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
m_data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
# endif | # endif | ||||
static struct | static struct | ||||
@@ -297,8 +300,10 @@ void Texture::SetMinFiltering(TextureMinFilter filter) | |||||
void Texture::GenerateMipmaps() | void Texture::GenerateMipmaps() | ||||
{ | { | ||||
#if defined _XBOX || defined USE_D3D9 | |||||
m_data->m_texture->GenerateMipSubLevels(); | |||||
#if defined USE_D3D9 | |||||
m_data->m_texture->->GenerateMipSubLevels(); | |||||
#elif defined _XBOX | |||||
/* FIXME: No direct mipmap generation support on X360 */ | |||||
#elif defined __CELLOS_LV2__ | #elif defined __CELLOS_LV2__ | ||||
glBindTexture(GL_TEXTURE_2D, m_data->m_texture); | glBindTexture(GL_TEXTURE_2D, m_data->m_texture); | ||||
glGenerateMipmapOES(GL_TEXTURE_2D); | glGenerateMipmapOES(GL_TEXTURE_2D); | ||||
@@ -19,6 +19,10 @@ | |||||
# define FAR | # define FAR | ||||
# define NEAR | # define NEAR | ||||
# include <d3d9.h> | # include <d3d9.h> | ||||
#elif defined _XBOX | |||||
# include <xtl.h> | |||||
# undef near /* Fuck Microsoft */ | |||||
# undef far /* Fuck Microsoft again */ | |||||
#endif | #endif | ||||
using namespace std; | using namespace std; | ||||
@@ -42,7 +46,7 @@ class VertexBufferData | |||||
IDirect3DDevice9 *m_dev; | IDirect3DDevice9 *m_dev; | ||||
IDirect3DVertexBuffer9 *m_vbo; | IDirect3DVertexBuffer9 *m_vbo; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DVertexBuffer *m_vbo; | D3DVertexBuffer *m_vbo; | ||||
#else | #else | ||||
GLuint m_vbo; | GLuint m_vbo; | ||||
@@ -64,7 +68,7 @@ class VertexDeclarationData | |||||
IDirect3DDevice9 *m_dev; | IDirect3DDevice9 *m_dev; | ||||
IDirect3DVertexDeclaration9 *m_vdecl; | IDirect3DVertexDeclaration9 *m_vdecl; | ||||
#elif defined _XBOX | #elif defined _XBOX | ||||
D3DDevice9 *m_dev; | |||||
D3DDevice *m_dev; | |||||
D3DVertexDeclaration *m_vdecl; | D3DVertexDeclaration *m_vdecl; | ||||
#else | #else | ||||
#endif | #endif | ||||
@@ -564,7 +568,7 @@ void VertexDeclaration::Initialize() | |||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
# elif defined _XBOX | # elif defined _XBOX | ||||
m_data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
m_data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
# endif | # endif | ||||
if (FAILED(m_data->m_dev->CreateVertexDeclaration(elements, | if (FAILED(m_data->m_dev->CreateVertexDeclaration(elements, | ||||
@@ -647,7 +651,7 @@ VertexBuffer::VertexBuffer(size_t size) | |||||
# if defined USE_D3D9 | # if defined USE_D3D9 | ||||
m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | m_data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | ||||
# elif defined _XBOX | # elif defined _XBOX | ||||
m_data->m_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
m_data->m_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
# endif | # endif | ||||
if (FAILED(m_data->m_dev->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, nullptr, | if (FAILED(m_data->m_dev->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, nullptr, | ||||
@@ -63,7 +63,7 @@ void XboxApp::Tick() | |||||
Ticker::TickDraw(); | Ticker::TickDraw(); | ||||
#if defined _XBOX | #if defined _XBOX | ||||
D3DDevice9 *d3d_dev = (D3DDevice9 *)g_renderer->GetDevice(); | |||||
D3DDevice *d3d_dev = (D3DDevice *)g_renderer->GetDevice(); | |||||
d3d_dev->Present(nullptr, nullptr, nullptr, nullptr); | d3d_dev->Present(nullptr, nullptr, nullptr, nullptr); | ||||
#endif | #endif | ||||
} | } | ||||