本文整理汇总了C++中GLTexture类的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture类的具体用法?C++ GLTexture怎么用?C++ GLTexture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GLTexture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
Canvas::text_transparent(PixelScalar x, PixelScalar y, const TCHAR *text)
{
assert(text != NULL);
assert(ValidateUTF8(text));
#ifdef HAVE_GLES
assert(x_offset == OpenGL::translate_x);
assert(y_offset == OpenGL::translate_y);
#endif
if (font == NULL)
return;
GLTexture *texture = TextCache::Get(font, text);
if (texture == NULL)
return;
GLEnable scope(GL_TEXTURE_2D);
texture->Bind();
GLLogicOp logic_op(GL_AND_INVERTED);
/* cut out the shape in black */
OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
texture->Draw(x, y);
if (text_color != COLOR_BLACK) {
/* draw the text color on top */
OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
logic_op.set(GL_OR);
text_color.Set();
texture->Draw(x, y);
}
}
示例2: assert
void
Canvas::DrawText(int x, int y, const TCHAR *text)
{
assert(text != nullptr);
assert(ValidateUTF8(text));
#ifdef HAVE_GLES
assert(offset == OpenGL::translate);
#endif
if (font == nullptr)
return;
GLTexture *texture = TextCache::Get(*font, text);
if (texture == nullptr)
return;
if (background_mode == OPAQUE)
DrawFilledRectangle(x, y,
x + texture->GetWidth(), y + texture->GetHeight(),
background_color);
PrepareColoredAlphaTexture(text_color);
#ifndef USE_GLSL
GLEnable scope(GL_TEXTURE_2D);
#endif
const GLBlend blend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
texture->Bind();
texture->Draw(x, y);
}
示例3: Message
bool GLVideo::BeginTargetScene(const Color& dwBGColor, const bool clear)
{
// explicit static cast for better performance
TexturePtr texturePtr = m_currentTarget.lock();
if (!texturePtr)
{
Message(GS_L("There's no render target"), GSMT_ERROR);
}
Texture *pTexture = texturePtr.get(); // safety compile-time error checking
GLTexture *pGLTexture = static_cast<GLTexture*>(pTexture); // safer direct cast
const GLuint target = pGLTexture->GetTextureInfo().m_frameBuffer;
glBindFramebuffer(GL_FRAMEBUFFER, target);
CheckFrameBufferStatus(target, pGLTexture->GetTextureInfo().m_texture, false);
if (clear)
{
math::Vector4 color;
color.SetColor(dwBGColor);
glClearColor(color.x, color.y, color.z, color.w);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
UpdateInternalShadersViewData(GetScreenSizeF(), true);
m_rendering = true;
return true;
}
示例4: syncGPUObject
void GLBackend::setResourceTexture(unsigned int slot, const TexturePointer& resourceTexture) {
// check cache before thinking
if (_resource._textures[slot] == resourceTexture) {
return;
}
// One more True texture bound
_stats._RSNumTextureBounded++;
// Always make sure the GLObject is in sync
GLTexture* object = syncGPUObject(resourceTexture);
if (object) {
GLuint to = object->_texture;
GLuint target = object->_target;
glActiveTexture(GL_TEXTURE0 + slot);
glBindTexture(target, to);
(void)CHECK_GL_ERROR();
_resource._textures[slot] = resourceTexture;
_stats._RSAmountTextureMemoryBounded += (int)object->size();
} else {
releaseResourceTexture(slot);
return;
}
}
示例5: moveTextureToBmp
BitmapPtr BmpTextureMover::moveTextureToBmp(GLTexture& tex, int mipmapLevel)
{
GLContext* pContext = GLContext::getCurrent();
unsigned fbo = pContext->genFBO();
glproc::BindFramebuffer(GL_FRAMEBUFFER, fbo);
glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
tex.getID(), mipmapLevel);
FBO::checkError("BmpTextureMover::moveTextureToBmp");
IntPoint size = tex.getMipmapSize(mipmapLevel);
BitmapPtr pBmp(new Bitmap(size, getPF()));
if (GLContext::getMain()->isGLES() && getPF() == B5G6R5) {
BitmapPtr pTmpBmp(new Bitmap(size, R8G8B8));
glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, pTmpBmp->getPixels());
FilterFlipRGB().applyInPlace(pTmpBmp);
pBmp->copyPixels(*pTmpBmp);
} else {
int glPixelFormat = tex.getGLFormat(getPF());
glReadPixels(0, 0, size.x, size.y, glPixelFormat, tex.getGLType(getPF()),
pBmp->getPixels());
}
GLContext::checkError("BmpTextureMover::moveTextureToBmp: glReadPixels()");
glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
0, 0);
pContext->returnFBOToCache(fbo);
glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
return pBmp;
}
示例6: Stretch
void
Canvas::Stretch(PixelScalar dest_x, PixelScalar dest_y,
UPixelScalar dest_width, UPixelScalar dest_height,
const GLTexture &texture)
{
Stretch(dest_x, dest_y, dest_width, dest_height,
texture, 0, 0, texture.GetWidth(), texture.GetHeight());
}
示例7: GLTexture
GLTexture* TexturesMap::TextureConstructor::construct (const TextureKey& key)
{
GLTexture* texture = new GLTexture(key.first, key.second);
if (m_cache->realised()) {
texture->realise();
}
return texture;
}
示例8: Stretch
void
Canvas::Stretch(int dest_x, int dest_y,
unsigned dest_width, unsigned dest_height,
const GLTexture &texture)
{
Stretch(dest_x, dest_y, dest_width, dest_height,
texture, 0, 0, texture.GetWidth(), texture.GetHeight());
}
示例9: TestCopyTexSubImage3D
// Read framebuffer to 'pixelsOut' via glCopyTexSubImage3D.
void TestCopyTexSubImage3D(int x, int y, int z, PixelRect *pixelsOut)
{
// Init texture with given pixels.
GLTexture destTexture;
pixelsOut->toTexture3D(destTexture.get(), kTextureDepth);
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, z, x, y, kReadWidth, kReadHeight);
readTexture3D(destTexture, kReadWidth, kReadHeight, z, pixelsOut);
}
示例10: TestCopyTexImage2D
// Read framebuffer to 'pixelsOut' via glCopyTexImage2D and GL_TEXTURE_2D.
void TestCopyTexImage2D(int x, int y, int, PixelRect *pixelsOut)
{
// Init texture with given pixels.
GLTexture destTexture;
pixelsOut->toTexture2D(GL_TEXTURE_2D, destTexture.get());
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, kReadWidth, kReadHeight, 0);
readTexture2D(GL_TEXTURE_2D, destTexture.get(), kReadWidth, kReadHeight, pixelsOut);
}
示例11: _lua_getter_samplers
void UniformVar::_lua_getter_samplers(const gb::utils::luatable_mapper & mapper, const char * name)
{
std::vector<string> ret = mapper.get_strings_by_key(name);
const std::size_t minCount = ret.size() > count ? count : ret.size();
for (std::size_t i = 0; i < minCount; i++)
{
GLTexture * tex = resource::Res<GLTexture>::Instance().Get(ret[i]);
textureObjs[i] = { tex->GetTarget(), tex->GetTextureObj() };
}
}
示例12: TestCopyTexSubImageCube
// Read framebuffer to 'pixelsOut' via glCopyTexSubImage2D and cube map.
void TestCopyTexSubImageCube(int x, int y, int, PixelRect *pixelsOut)
{
// Init texture with given pixels.
GLTexture destTexture;
pixelsOut->toTexture2D(GL_TEXTURE_CUBE_MAP, destTexture.get());
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 0, 0, x, y, kReadWidth, kReadHeight);
readTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, destTexture.get(), kReadWidth, kReadHeight,
pixelsOut);
}
示例13: commit
void AtlasTexture::commit(Image const &image, Vector2i const &topLeft) const
{
GLTexture *tex = const_cast<AtlasTexture *>(this);
if(size() == GLTexture::Size(0, 0))
{
// Hasn't been full-committed yet.
tex->setUndefinedImage(totalSize(), Image::RGBA_8888);
}
tex->setSubImage(image, topLeft);
}
示例14: glBindFramebuffer
void GLFramebuffer::setWidthAndHeight(unsigned int width, unsigned int height)
{
mWidth = std::max(width, 1u);
mHeight = std::max(height, 1u);
if (not mFinished)
{
return;
}
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
if (mDepthTexture != NULL)
{
GLTexture *glDepthTex = (GLTexture *)mDepthTexture;
glBindTexture(GL_TEXTURE_2D, glDepthTex->mTexture);
glDepthTex->allocData2D(mWidth, mHeight, mDepthFormat, Texture::Depth32F_Format, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, glDepthTex->mTexture, 0);
}
if (glIsRenderbuffer(mDepthRBO) and mDepthTexture == NULL)
{
glBindRenderbuffer(GL_RENDERBUFFER, mDepthRBO);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, mWidth, mHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthRBO);
}
unsigned int i=0;
GLenum drawBuffers[mColorTextures.size()];
for (std::vector<ColorTexture>::iterator it = mColorTextures.begin();
it != mColorTextures.end(); ++it)
{
GLTexture *glTexture = (GLTexture *)it->texture;
glBindTexture(GL_TEXTURE_2D, glTexture->mTexture);
glTexture->allocData2D(mWidth*it->scale.x, mHeight*it->scale.y, it->format, Texture::RGBU8_Format, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_TEXTURE_2D, glTexture->mTexture, 0);
drawBuffers[i] = GL_COLOR_ATTACHMENT0+i;
++i;
}
glDrawBuffers(mColorTextures.size(), drawBuffers);
}
示例15: syncGPUObject
void GLBackend::do_generateTextureMips(const Batch& batch, size_t paramOffset) {
TexturePointer resourceTexture = batch._textures.get(batch._params[paramOffset + 0]._uint);
if (!resourceTexture) {
return;
}
// DO not transfer the texture, this call is expected for rendering texture
GLTexture* object = syncGPUObject(resourceTexture);
if (!object) {
return;
}
object->generateMips();
}