本文整理汇总了C++中RendererException函数的典型用法代码示例。如果您正苦于以下问题:C++ RendererException函数的具体用法?C++ RendererException怎么用?C++ RendererException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RendererException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenGLTextureTarget
//----------------------------------------------------------------------------//
OpenGLWGLPBTextureTarget::OpenGLWGLPBTextureTarget(OpenGLRendererBase& owner) :
OpenGLTextureTarget(owner),
d_pixfmt(0),
d_pbuffer(0),
d_context(0),
d_hdc(0),
d_prevContext(0),
d_prevDC(0)
{
if (!WGLEW_ARB_pbuffer)
CEGUI_THROW(RendererException("WGL_ARB_pbuffer extension is needed to "
"use OpenGLWGLPBTextureTarget!"));
HDC hdc = wglGetCurrentDC();
uint fmtcnt;
wglChoosePixelFormatARB(hdc, pbAttrs, 0, 1, &d_pixfmt, &fmtcnt);
if (!fmtcnt)
CEGUI_THROW(RendererException(
"pbuff creation failure, no suitable pixel formats."));
initialiseTexture();
// set default size (and cause initialisation of the pbuffer)
declareRenderSize(Sizef(DEFAULT_SIZE, DEFAULT_SIZE));
}
示例2: CEGUI_THROW
//----------------------------------------------------------------------------//
void NullTexture::loadFromFile(const String& filename,
const String& resourceGroup)
{
// get and check existence of CEGUI::System object
System* sys = System::getSingletonPtr();
if (!sys)
CEGUI_THROW(RendererException(
"CEGUI::System object has not been created!"));
// load file to memory via resource provider
RawDataContainer texFile;
sys->getResourceProvider()->loadRawDataContainer(filename, texFile,
resourceGroup);
Texture* res = sys->getImageCodec().load(texFile, this);
// unload file data buffer
sys->getResourceProvider()->unloadRawDataContainer(texFile);
// throw exception if data was load loaded to texture.
if (!res)
CEGUI_THROW(RendererException(
sys->getImageCodec().getIdentifierString() +
" failed to load image '" + filename + "'."));
}
示例3: switch
//----------------------------------------------------------------------------//
GLint OpenGLTexture::internalFormat() const
{
if (OpenGLInfo::getSingleton().isSizedInternalFormatSupported())
{
const char* err = "Invalid or unsupported OpenGL pixel format.";
switch (d_format)
{
case GL_RGBA:
switch (d_subpixelFormat)
{
case GL_UNSIGNED_BYTE:
return GL_RGBA8;
case GL_UNSIGNED_SHORT_4_4_4_4:
return GL_RGBA4;
default:
throw RendererException(err);
}
case GL_RGB:
switch (d_subpixelFormat)
{
case GL_UNSIGNED_BYTE:
return GL_RGB8;
case GL_UNSIGNED_SHORT_5_6_5:
return GL_RGB565;
default:
throw RendererException(err);
}
default:
throw RendererException(err);
}
}
else
return d_format;
}
示例4: loadRawDataContainer
//----------------------------------------------------------------------------//
void OpenGLTexture::loadFromFile(const String& filename,
const String& resourceGroup)
{
// Note from PDT:
// There is somewhat tight coupling here between OpenGLTexture and the
// ImageCodec classes - we have intimate knowledge of how they are
// implemented and that knowledge is relied upon in an unhealthy way; this
// should be addressed at some stage.
// load file to memory via resource provider
RawDataContainer texFile;
System::getSingleton().getResourceProvider()->
loadRawDataContainer(filename, texFile, resourceGroup);
// get and check existence of CEGUI::System (needed to access ImageCodec)
System* sys = System::getSingletonPtr();
if (!sys)
CEGUI_THROW(RendererException("OpenGLTexture::loadFromFile - "
"CEGUI::System object has not been created: "
"unable to access ImageCodec."));
Texture* res = sys->getImageCodec().load(texFile, this);
// unload file data buffer
System::getSingleton().getResourceProvider()->
unloadRawDataContainer(texFile);
if (!res)
// It's an error
CEGUI_THROW(RendererException("OpenGLTexture::loadFromFile - " +
sys->getImageCodec().getIdentifierString() +
" failed to load image '" + filename + "'."));
}
示例5: setArea
//----------------------------------------------------------------------------//
void OpenGLApplePBTextureTarget::declareRenderSize(const Size& sz)
{
// exit if current size is enough
if ((d_area.getWidth() >= sz.d_width) &&
(d_area.getHeight() >= sz.d_height))
return;
setArea(Rect(d_area.getPosition(), d_owner.getAdjustedTextureSize(sz)));
// dump any previous pbuffer
if (d_pbuffer)
{
CGLDestroyPBuffer(d_pbuffer);
d_pbuffer = 0;
}
CGLError err;
if (err = CGLCreatePBuffer(d_area.getWidth(), d_area.getHeight(),
GL_TEXTURE_2D, GL_RGBA, 0, &d_pbuffer))
{
CEGUI_THROW(RendererException(
"OpenGLApplePBTextureTarget::declareRenderSize "
"- CGLCreatePBuffer failed: " + String(CGLErrorString(err))));
}
if (err = CGLSetPBuffer(d_context, d_pbuffer, 0, 0, d_screen))
CEGUI_THROW(RendererException(
"OpenGLApplePBTextureTarget::declareRenderSize "
"- CGLSetPBuffer failed: " + String(CGLErrorString(err))));
clear();
// make d_texture use the pbuffer as it's data source
// save old texture binding
GLuint old_tex;
glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast<GLint*>(&old_tex));
glBindTexture(GL_TEXTURE_2D, d_texture);
err = CGLTexImagePBuffer(CGLGetCurrentContext(), d_pbuffer, GL_FRONT);
// restore previous texture binding.
glBindTexture(GL_TEXTURE_2D, old_tex);
if (err)
CEGUI_THROW(RendererException(
"OpenGLApplePBTextureTarget::declareRenderSize "
"- CGLTexImagePBuffer failed: " + String(CGLErrorString(err))));
// ensure CEGUI::Texture is wrapping real GL texture and has correct size
d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize());
}
示例6: releasePBuffer
//----------------------------------------------------------------------------//
void OpenGLWGLPBTextureTarget::initialisePBuffer()
{
int creation_attrs[] =
{
WGL_PBUFFER_LARGEST_ARB, true,
0
};
releasePBuffer();
HDC hdc = wglGetCurrentDC();
d_pbuffer = wglCreatePbufferARB(hdc, d_pixfmt,
static_cast<int>(d_area.getWidth()),
static_cast<int>(d_area.getHeight()),
creation_attrs);
if (!d_pbuffer)
CEGUI_THROW(RendererException(
"OpenGLWGLPBTextureTarget::initialisePBuffer - "
"pbuffer creation failure, wglCreatePbufferARB() call failed."));
d_hdc = wglGetPbufferDCARB(d_pbuffer);
if (!d_hdc)
CEGUI_THROW(RendererException(
"OpenGLWGLPBTextureTarget::initialisePBuffer - "
"pbuffer creation failure, wglGetPbufferDCARB() call failed."));
d_context= wglCreateContext(d_hdc);
if (!d_hdc)
CEGUI_THROW(RendererException(
"OpenGLWGLPBTextureTarget::initialisePBuffer - "
"pbuffer creation failure, wglCreateContext() call failed."));
if(!wglShareLists(wglGetCurrentContext(), d_context))
CEGUI_THROW(RendererException(
"OpenGLWGLPBTextureTarget::initialisePBuffer - "
"pbuffer creation failure, wglShareLists() call failed."));
// extract the actual size of the created bufer
int actual_width, actual_height;
wglQueryPbufferARB(d_pbuffer, WGL_PBUFFER_WIDTH_ARB, &actual_width);
wglQueryPbufferARB(d_pbuffer, WGL_PBUFFER_HEIGHT_ARB, &actual_height);
d_area.setSize(Size(static_cast<float>(actual_width),
static_cast<float>(actual_height)));
// ensure CEGUI::Texture is wrapping real GL texture and has correct size
d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize());
}
示例7: glXDestroyPbuffer
//----------------------------------------------------------------------------//
void OpenGLGLXPBTextureTarget::initialisePBuffer()
{
int creation_attrs[] =
{
GLX_PBUFFER_WIDTH, d_area.getWidth(),
GLX_PBUFFER_HEIGHT, d_area.getHeight(),
GLX_LARGEST_PBUFFER, True,
GLX_PRESERVED_CONTENTS, True,
None
};
// release any existing pbuffer
if (d_pbuffer)
glXDestroyPbuffer(d_dpy, d_pbuffer);
d_pbuffer = glXCreatePbuffer(d_dpy, d_fbconfig, creation_attrs);
if (!d_pbuffer)
throw RendererException("OpenGLGLXPBTextureTarget::initialisePBuffer - "
"pbuffer creation error: glXCreatePbuffer() failed");
// get the real size of the buffer that was created
GLuint actual_width, actual_height;
glXQueryDrawable(d_dpy, d_pbuffer, GLX_WIDTH, &actual_width);
glXQueryDrawable(d_dpy, d_pbuffer, GLX_HEIGHT, &actual_height);
d_area.setSize(Size(actual_width, actual_height));
// ensure CEGUI::Texture is wrapping real GL texture and has correct size
d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize());
}
示例8: size
//----------------------------------------------------------------------------//
void OpenGLTexture::setTextureSize(const Size& sz)
{
const Size size(d_owner.getAdjustedTextureSize(sz));
// make sure size is within boundaries
GLfloat maxSize;
glGetFloatv(GL_MAX_TEXTURE_SIZE, &maxSize);
if ((size.d_width > maxSize) || (size.d_height > maxSize))
CEGUI_THROW(RendererException(
"OpenGLTexture::setTextureSize: size too big"));
// save old texture binding
GLuint old_tex;
glGetIntegerv(GL_TEXTURE_BINDING_2D, reinterpret_cast<GLint*>(&old_tex));
// set texture to required size
glBindTexture(GL_TEXTURE_2D, d_ogltexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
static_cast<GLsizei>(size.d_width),
static_cast<GLsizei>(size.d_height),
0, GL_RGBA , GL_UNSIGNED_BYTE, 0);
// restore previous texture binding.
glBindTexture(GL_TEXTURE_2D, old_tex);
d_dataSize = d_size = size;
updateCachedScaleValues();
}
示例9: CEGUI_THROW
//----------------------------------------------------------------------------//
void Direct3D9Texture::loadFromMemory(const void* buffer,
const Sizef& buffer_size,
PixelFormat pixel_format)
{
if (!isPixelFormatSupported(pixel_format))
CEGUI_THROW(InvalidRequestException(
"Data was supplied in an unsupported pixel format."));
const D3DFORMAT pixfmt = toD3DPixelFormat(pixel_format);
createDirect3D9Texture(buffer_size, pixfmt);
LPDIRECT3DSURFACE9 surface = getTextureSurface();
const PixelBuffer pixel_buffer(buffer, buffer_size, pixel_format);
const RECT src_rect = { 0, 0,
static_cast<LONG>(buffer_size.d_width),
static_cast<LONG>(buffer_size.d_height) };
HRESULT hr = D3DXLoadSurfaceFromMemory(
surface, 0, 0, pixel_buffer.getPixelDataPtr(),
pixfmt == D3DFMT_X8R8G8B8 ? D3DFMT_R8G8B8 : pixfmt,
pixel_buffer.getPitch(), 0, &src_rect, D3DX_FILTER_NONE, 0);
surface->Release();
if (FAILED(hr))
CEGUI_THROW(RendererException(
"D3DXLoadSurfaceFromMemory failed."));
}
示例10: d_device
//----------------------------------------------------------------------------//
Direct3D11Texture::Direct3D11Texture(IDevice11& device, const Size& sz) :
d_device(device),
d_texture(0),
d_resourceView(0),
d_size(0, 0),
d_dataSize(0, 0),
d_texelScaling(0, 0)
{
D3D11_TEXTURE2D_DESC tex_desc;
ZeroMemory(&tex_desc, sizeof(tex_desc));
tex_desc.Width = static_cast<UINT>(sz.d_width);
tex_desc.Height = static_cast<UINT>(sz.d_height);
tex_desc.ArraySize = 1;
tex_desc.SampleDesc.Count = 1;
tex_desc.SampleDesc.Quality = 0;
tex_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
tex_desc.Usage = D3D11_USAGE_DEFAULT;
tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tex_desc.CPUAccessFlags = 0;
tex_desc.MiscFlags = 0;
tex_desc.MipLevels = 1;
if (FAILED(d_device.d_device->CreateTexture2D(&tex_desc, 0, &d_texture)))
CEGUI_THROW(RendererException(
"Direct3D11Texture: Failed to create texture with specified size."));
initialiseShaderResourceView();
d_dataSize = sz;
updateTextureSize();
updateCachedScaleValues();
}
示例11: createVertexBuffer
void OgreGeometryBuffer::setVertexBuffer(size_t count) const
{
// We first check if some other buffer has already allocated a suited buffer
// for us
Ogre::HardwareVertexBufferSharedPtr already_created =
d_owner.getVertexBuffer(count);
if (!already_created.isNull())
{
d_hwBuffer = already_created;
} else {
// Create the a new vertex buffer
d_hwBuffer = Ogre::HardwareBufferManager::getSingleton().
createVertexBuffer(getVertexAttributeElementCount()*sizeof(float), count,
Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
false);
}
if (d_hwBuffer.isNull())
{
throw RendererException("Failed to create Ogre vertex buffer, "
"probably because the vertex layout is invalid.");
}
// bind the vertex buffer for rendering
d_renderOp.vertexData->vertexBufferBinding->setBinding(0, d_hwBuffer);
}
示例12: size
//----------------------------------------------------------------------------//
void OpenGLESTexture::setTextureSize_impl(const Sizef& sz)
{
const Sizef size(d_owner.getAdjustedTextureSize(sz));
if (!d_isCompressed)
{
// make sure size is within boundaries
GLfloat maxSize = static_cast<GLfloat>(d_owner.getMaxTextureSize());
if ((size.d_width > maxSize) || (size.d_height > maxSize))
CEGUI_THROW(RendererException("size too big"));
// save old texture binding
GLuint old_tex;
glGetIntegerv(GL_TEXTURE_BINDING_2D,
reinterpret_cast<GLint*>(&old_tex));
// set texture to required size
glBindTexture(GL_TEXTURE_2D, d_ogltexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
static_cast<GLsizei>(size.d_width),
static_cast<GLsizei>(size.d_height),
0, d_format , d_subpixelFormat, 0);
// restore previous texture binding.
glBindTexture(GL_TEXTURE_2D, old_tex);
}
d_size = size;
}
示例13: RendererException
/*************************************************************************
Direct3D support method that must be called after a Reset call on the
Direct3DDevice.
*************************************************************************/
void DirectX9Renderer::postD3DReset(void)
{
// Recreate a vertex buffer
if (FAILED(d_device->CreateVertexBuffer((VERTEXBUFFER_CAPACITY * sizeof(QuadVertex)), D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, VERTEX_FVF, D3DPOOL_DEFAULT, &d_buffer, 0)))
{
throw RendererException("DirectX9Renderer::postD3DReset - Failed to "
"create the VertexBuffer for use by the "
"DirectX9Renderer object.");
}
// perform post-reset operations on all textures
std::list<DirectX9Texture*>::iterator ctex = d_texturelist.begin();
std::list<DirectX9Texture*>::iterator endtex = d_texturelist.end();
for (; ctex != endtex; ++ctex)
{
(*ctex)->postD3DReset();
}
// update display size
setDisplaySize(getViewportSize());
// Now we've come back, we MUST ensure a full redraw is done since the
// textures in the stored quads will have been invalidated.
System::getSingleton().signalRedraw();
}
示例14: loadRawDataContainer
//----------------------------------------------------------------------------//
void OpenGLTexture::loadFromFile(const String& filename,
const String& resourceGroup)
{
// Note from PDT:
// There is somewhat tight coupling here between OpenGLTexture and the
// ImageCodec classes - we have intimate knowledge of how they are
// implemented and that knowledge is relied upon in an unhealthy way; this
// should be addressed at some stage.
// load file to memory via resource provider
RawDataContainer texFile;
CEGUI::System& system = System::getSingleton();
system.getResourceProvider()->
loadRawDataContainer(filename, texFile, resourceGroup);
Texture* res = system.getImageCodec().load(texFile, this);
// unload file data buffer
System::getSingleton().getResourceProvider()->
unloadRawDataContainer(texFile);
if (!res)
// It's an error
throw RendererException(
system.getImageCodec().getIdentifierString() +
" failed to load image '" + filename + "'.");
}
示例15: cleanupDirect3D11Texture
//----------------------------------------------------------------------------//
void Direct3D11Texture::loadFromMemory(const void* buffer,
const Size& buffer_size,
PixelFormat pixel_format)
{
cleanupDirect3D11Texture();
const void* img_src = buffer;
if (pixel_format == PF_RGB)
{
const char* src = static_cast<const char*>(buffer);
char* dest = new char[buffer_size.d_width * buffer_size.d_height * 4];
for (int i = 0; i < buffer_size.d_width * buffer_size.d_height; ++i)
{
dest[i * 4 + 0] = src[i * 3 + 0];
dest[i * 4 + 1] = src[i * 3 + 1];
dest[i * 4 + 2] = src[i * 3 + 2];
dest[i * 4 + 3] = 0xFF;
}
img_src = dest;
}
D3D11_TEXTURE2D_DESC tex_desc;
ZeroMemory(&tex_desc, sizeof(tex_desc));
tex_desc.Width = static_cast<UINT>(buffer_size.d_width);
tex_desc.Height = static_cast<UINT>(buffer_size.d_height);
tex_desc.ArraySize = 1;
tex_desc.SampleDesc.Count = 1;
tex_desc.SampleDesc.Quality = 0;
tex_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
tex_desc.Usage = D3D11_USAGE_DEFAULT;
tex_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
tex_desc.CPUAccessFlags = 0;
tex_desc.MiscFlags = 0;
tex_desc.MipLevels = 1;
D3D11_SUBRESOURCE_DATA data;
ZeroMemory(&data, sizeof(D3D11_SUBRESOURCE_DATA));
data.pSysMem = img_src;
data.SysMemPitch = 4 * tex_desc.Width;
HRESULT hr = d_device.d_device->CreateTexture2D(&tex_desc, &data, &d_texture);
if (pixel_format == PF_RGB)
delete[] img_src;
if (FAILED(hr))
CEGUI_THROW(RendererException(
"Direct3D11Texture::loadFromMemory: Failed to "
"create texture from memory buffer."));
initialiseShaderResourceView();
d_dataSize = buffer_size;
updateTextureSize();
updateCachedScaleValues();
}