本文整理汇总了C++中D3D_SetError函数的典型用法代码示例。如果您正苦于以下问题:C++ D3D_SetError函数的具体用法?C++ D3D_SetError怎么用?C++ D3D_SetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3D_SetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: D3D_SetRenderTarget
static int
D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
D3D_TextureData *texturedata;
HRESULT result;
D3D_ActivateRenderer(renderer);
/* Release the previous render target if it wasn't the default one */
if (data->currentRenderTarget != NULL) {
IDirect3DSurface9_Release(data->currentRenderTarget);
data->currentRenderTarget = NULL;
}
if (texture == NULL) {
IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget);
return 0;
}
texturedata = (D3D_TextureData *) texture->driverdata;
result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture, 0, &data->currentRenderTarget);
if(FAILED(result)) {
D3D_SetError("GetSurfaceLevel()", result);
return -1;
}
result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget);
if(FAILED(result)) {
D3D_SetError("SetRenderTarget()", result);
return -1;
}
return 0;
}
示例2: D3D_RenderReadPixels
static int
D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
D3DSURFACE_DESC desc;
LPDIRECT3DSURFACE9 backBuffer;
LPDIRECT3DSURFACE9 surface;
RECT d3drect;
D3DLOCKED_RECT locked;
HRESULT result;
result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
if (FAILED(result)) {
return D3D_SetError("GetBackBuffer()", result);
}
result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
if (FAILED(result)) {
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("GetDesc()", result);
}
result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
if (FAILED(result)) {
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("CreateOffscreenPlainSurface()", result);
}
result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
if (FAILED(result)) {
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("GetRenderTargetData()", result);
}
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
if (FAILED(result)) {
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return D3D_SetError("LockRect()", result);
}
SDL_ConvertPixels(rect->w, rect->h,
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
format, pixels, pitch);
IDirect3DSurface9_UnlockRect(surface);
IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return 0;
}
示例3: D3D_RenderDrawLines
static int
D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
Vertex *vertices;
int i;
HRESULT result;
if (data->beginScene) {
IDirect3DDevice9_BeginScene(data->device);
data->beginScene = SDL_FALSE;
}
D3D_SetBlendMode(data, renderer->blendMode);
result =
IDirect3DDevice9_SetTexture(data->device, 0,
(IDirect3DBaseTexture9 *) 0);
if (FAILED(result)) {
D3D_SetError("SetTexture()", result);
return -1;
}
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
vertices = SDL_stack_alloc(Vertex, count);
for (i = 0; i < count; ++i) {
vertices[i].x = (float) points[i].x;
vertices[i].y = (float) points[i].y;
vertices[i].z = 0.0f;
vertices[i].rhw = 1.0f;
vertices[i].color = color;
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
result =
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
vertices, sizeof(*vertices));
/* DirectX 9 has the same line rasterization semantics as GDI,
so we need to close the endpoint of the line */
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
vertices[0].x = (float) points[count-1].x;
vertices[0].y = (float) points[count-1].y;
result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
}
SDL_stack_free(vertices);
if (FAILED(result)) {
D3D_SetError("DrawPrimitiveUP()", result);
return -1;
}
return 0;
}
示例4: D3D_RenderLine
static int
D3D_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
Vertex vertices[2];
HRESULT result;
if (data->beginScene) {
IDirect3DDevice9_BeginScene(data->device);
data->beginScene = SDL_FALSE;
}
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
vertices[0].x = (float) x1 - 0.5f;
vertices[0].y = (float) y1 - 0.5f;
vertices[0].z = 0.0f;
vertices[0].rhw = 1.0f;
vertices[0].color = color;
vertices[0].u = 0.0f;
vertices[0].v = 0.0f;
vertices[1].x = (float) x2 - 0.5f;
vertices[1].y = (float) y2 - 0.5f;
vertices[1].z = 0.0f;
vertices[1].rhw = 1.0f;
vertices[1].color = color;
vertices[1].u = 0.0f;
vertices[1].v = 0.0f;
D3D_SetBlendMode(data, renderer->blendMode);
result =
IDirect3DDevice9_SetTexture(data->device, 0,
(IDirect3DBaseTexture9 *) 0);
if (FAILED(result)) {
D3D_SetError("SetTexture()", result);
return -1;
}
result =
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINELIST, 1,
vertices, sizeof(*vertices));
if (FAILED(result)) {
D3D_SetError("DrawPrimitiveUP()", result);
return -1;
}
return 0;
}
示例5: D3D_UpdateClipRect
static int
D3D_UpdateClipRect(SDL_Renderer * renderer)
{
const SDL_Rect *rect = &renderer->clip_rect;
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
RECT r;
HRESULT result;
if (!SDL_RectEmpty(rect)) {
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE);
r.left = rect->x;
r.top = rect->y;
r.right = rect->w + rect->w;
r.bottom = rect->y + rect->h;
result = IDirect3DDevice9_SetScissorRect(data->device, &r);
if (result != D3D_OK) {
D3D_SetError("SetScissor()", result);
return -1;
}
} else {
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE);
}
return 0;
}
示例6: D3D_LockTexture
static int
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, int markDirty, void **pixels,
int *pitch)
{
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
if (data->yuv) {
return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
pitch);
} else {
RECT d3drect;
D3DLOCKED_RECT locked;
HRESULT result;
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
result =
IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
markDirty ? 0 :
D3DLOCK_NO_DIRTY_UPDATE);
if (FAILED(result)) {
D3D_SetError("LockRect()", result);
return -1;
}
*pixels = locked.pBits;
*pitch = locked.Pitch;
return 0;
}
}
示例7: D3D_Reset
static int
D3D_Reset(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
HRESULT result;
/* Release the default render target before reset */
if (data->defaultRenderTarget) {
IDirect3DSurface9_Release(data->defaultRenderTarget);
data->defaultRenderTarget = NULL;
}
result = IDirect3DDevice9_Reset(data->device, &data->pparams);
if (FAILED(result)) {
if (result == D3DERR_DEVICELOST) {
/* Don't worry about it, we'll reset later... */
return 0;
} else {
return D3D_SetError("Reset()", result);
}
}
IDirect3DDevice9_SetVertexShader(data->device, NULL);
IDirect3DDevice9_SetFVF(data->device,
D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
return 0;
}
示例8: D3D_RenderDrawPoints
static int
D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
int count)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
Vertex *vertices;
int i;
HRESULT result;
if (data->beginScene) {
IDirect3DDevice9_BeginScene(data->device);
data->beginScene = SDL_FALSE;
}
D3D_SetBlendMode(data, renderer->blendMode);
result =
IDirect3DDevice9_SetTexture(data->device, 0,
(IDirect3DBaseTexture9 *) 0);
if (FAILED(result)) {
D3D_SetError("SetTexture()", result);
return -1;
}
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
vertices = SDL_stack_alloc(Vertex, count);
for (i = 0; i < count; ++i) {
vertices[i].x = (float) points[i].x;
vertices[i].y = (float) points[i].y;
vertices[i].z = 0.0f;
vertices[i].rhw = 1.0f;
vertices[i].color = color;
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
result =
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
vertices, sizeof(*vertices));
SDL_stack_free(vertices);
if (FAILED(result)) {
D3D_SetError("DrawPrimitiveUP()", result);
return -1;
}
return 0;
}
示例9: D3D_UpdateTexture
static int
D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
{
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
RECT d3drect;
D3DLOCKED_RECT locked;
const Uint8 *src;
Uint8 *dst;
int row, length;
HRESULT result;
#ifdef USE_DYNAMIC_TEXTURE
if (texture->access == SDL_TEXTUREACCESS_STREAMING &&
rect->x == 0 && rect->y == 0 &&
rect->w == texture->w && rect->h == texture->h) {
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, NULL, D3DLOCK_DISCARD);
} else
#endif
{
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
}
if (FAILED(result)) {
D3D_SetError("LockRect()", result);
return -1;
}
src = pixels;
dst = locked.pBits;
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
if (length == pitch && length == locked.Pitch) {
SDL_memcpy(dst, src, length*rect->h);
} else {
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
dst += locked.Pitch;
}
}
IDirect3DTexture9_UnlockRect(data->texture, 0);
return 0;
}
示例10: D3D_RenderClear
static int
D3D_RenderClear(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
DWORD color;
HRESULT result;
if (D3D_ActivateRenderer(renderer) < 0) {
return -1;
}
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
/* Don't reset the viewport if we don't have to! */
if (!renderer->viewport.x && !renderer->viewport.y &&
renderer->viewport.w == data->pparams.BackBufferWidth &&
renderer->viewport.h == data->pparams.BackBufferHeight) {
result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
} else {
D3DVIEWPORT9 viewport;
/* Clear is defined to clear the entire render target */
viewport.X = 0;
viewport.Y = 0;
viewport.Width = data->pparams.BackBufferWidth;
viewport.Height = data->pparams.BackBufferHeight;
viewport.MinZ = 0.0f;
viewport.MaxZ = 1.0f;
IDirect3DDevice9_SetViewport(data->device, &viewport);
result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
/* Reset the viewport */
viewport.X = renderer->viewport.x;
viewport.Y = renderer->viewport.y;
viewport.Width = renderer->viewport.w;
viewport.Height = renderer->viewport.h;
viewport.MinZ = 0.0f;
viewport.MaxZ = 1.0f;
IDirect3DDevice9_SetViewport(data->device, &viewport);
}
if (FAILED(result)) {
D3D_SetError("Clear()", result);
return -1;
}
return 0;
}
示例11: D3D_CreateTexture
static int
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
SDL_Window *window = renderer->window;
SDL_VideoDisplay *display = window->display;
Uint32 display_format = display->current_mode.format;
D3D_TextureData *data;
HRESULT result;
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
if (!data) {
SDL_OutOfMemory();
return -1;
}
texture->driverdata = data;
if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
(texture->format != SDL_PIXELFORMAT_YUY2 ||
!D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
display_format, texture->format))
&& (texture->format != SDL_PIXELFORMAT_YVYU
|| !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
display_format, texture->format))) {
data->yuv =
SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
if (!data->yuv) {
return -1;
}
data->format = display->current_mode.format;
} else {
data->format = texture->format;
}
result =
IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
texture->h, 1, 0,
PixelFormatToD3DFMT(data->format),
D3DPOOL_SDL, &data->texture, NULL);
if (FAILED(result)) {
D3D_SetError("CreateTexture()", result);
return -1;
}
return 0;
}
示例12: D3D_CreateTexture
static int
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
SDL_Window *window = renderer->window;
D3DFORMAT display_format = renderdata->pparams.BackBufferFormat;
D3D_TextureData *data;
D3DPOOL pool;
DWORD usage;
HRESULT result;
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
if (!data) {
SDL_OutOfMemory();
return -1;
}
data->scaleMode = GetScaleQuality();
texture->driverdata = data;
#ifdef USE_DYNAMIC_TEXTURE
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
pool = D3DPOOL_DEFAULT;
usage = D3DUSAGE_DYNAMIC;
} else
#endif
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
/* D3DPOOL_MANAGED does not work with D3DUSAGE_RENDERTARGET */
pool = D3DPOOL_DEFAULT;
usage = D3DUSAGE_RENDERTARGET;
} else {
pool = D3DPOOL_MANAGED;
usage = 0;
}
result =
IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
texture->h, 1, usage,
PixelFormatToD3DFMT(texture->format),
pool, &data->texture, NULL);
if (FAILED(result)) {
D3D_SetError("CreateTexture()", result);
return -1;
}
return 0;
}
示例13: D3D_ActivateRenderer
static int
D3D_ActivateRenderer(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
HRESULT result;
if (data->updateSize) {
SDL_Window *window = renderer->window;
int w, h;
SDL_GetWindowSize(window, &w, &h);
data->pparams.BackBufferWidth = w;
data->pparams.BackBufferHeight = h;
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
data->pparams.BackBufferFormat =
PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
} else {
data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
}
if (D3D_Reset(renderer) < 0) {
return -1;
}
D3D_UpdateViewport(renderer);
data->updateSize = SDL_FALSE;
}
if (data->beginScene) {
result = IDirect3DDevice9_BeginScene(data->device);
if (result == D3DERR_DEVICELOST) {
if (D3D_Reset(renderer) < 0) {
return -1;
}
result = IDirect3DDevice9_BeginScene(data->device);
}
if (FAILED(result)) {
D3D_SetError("BeginScene()", result);
return -1;
}
data->beginScene = SDL_FALSE;
}
return 0;
}
示例14: D3D_LockTexture
static int
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, void **pixels, int *pitch)
{
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
RECT d3drect;
D3DLOCKED_RECT locked;
HRESULT result;
d3drect.left = rect->x;
d3drect.right = rect->x + rect->w;
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
if (FAILED(result)) {
return D3D_SetError("LockRect()", result);
}
*pixels = locked.pBits;
*pitch = locked.Pitch;
return 0;
}
示例15: D3D_Reset
static int
D3D_Reset(SDL_Renderer * renderer)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
HRESULT result;
result = IDirect3DDevice9_Reset(data->device, &data->pparams);
if (FAILED(result)) {
if (result == D3DERR_DEVICELOST) {
/* Don't worry about it, we'll reset later... */
return 0;
} else {
D3D_SetError("Reset()", result);
return -1;
}
}
IDirect3DDevice9_SetVertexShader(data->device, NULL);
IDirect3DDevice9_SetFVF(data->device,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
return 0;
}