|
|
|
|
@@ -24,9 +24,27 @@
|
|
|
|
|
|
|
|
|
|
#include "../../lib/irrlicht/source/Irrlicht/COpenGLTexture.h"
|
|
|
|
|
|
|
|
|
|
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,
|
|
|
|
|
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
|
|
|
|
|
float tex_width, float tex_height)
|
|
|
|
|
// ============================================================================
|
|
|
|
|
class Primitive2DList : public Shader<Primitive2DList>,
|
|
|
|
|
public TextureReadNew<ST_BILINEAR_FILTERED >
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Primitive2DList()
|
|
|
|
|
{
|
|
|
|
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "primitive2dlist.vert",
|
|
|
|
|
GL_FRAGMENT_SHADER, "transparent.frag");
|
|
|
|
|
assignUniforms();
|
|
|
|
|
assignSamplerNames(m_program, 0, "tex", ST_BILINEAR_FILTERED);
|
|
|
|
|
} // Primitive2DList
|
|
|
|
|
}; //Primitive2DList
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
static void drawTexColoredQuad(const video::ITexture *texture,
|
|
|
|
|
const video::SColor *col, float width,
|
|
|
|
|
float height, float center_pos_x,
|
|
|
|
|
float center_pos_y, float tex_center_pos_x,
|
|
|
|
|
float tex_center_pos_y, float tex_width,
|
|
|
|
|
float tex_height)
|
|
|
|
|
{
|
|
|
|
|
unsigned colors[] = {
|
|
|
|
|
col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(),
|
|
|
|
|
@@ -51,38 +69,40 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
|
|
|
|
|
glGetError();
|
|
|
|
|
}
|
|
|
|
|
} // drawTexColoredQuad
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void drawTexQuad(GLuint texture, float width, float height,
|
|
|
|
|
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
|
|
|
|
|
float tex_width, float tex_height)
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
static void drawTexQuad(GLuint texture, float width, float height,
|
|
|
|
|
float center_pos_x, float center_pos_y,
|
|
|
|
|
float tex_center_pos_x, float tex_center_pos_y,
|
|
|
|
|
float tex_width, float tex_height)
|
|
|
|
|
{
|
|
|
|
|
UIShader::TextureRectShader::getInstance()->use();
|
|
|
|
|
glBindVertexArray(SharedObject::UIVAO);
|
|
|
|
|
|
|
|
|
|
UIShader::TextureRectShader::getInstance()->setTextureUnits(texture);
|
|
|
|
|
UIShader::TextureRectShader::getInstance()->setUniforms(
|
|
|
|
|
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
|
|
|
|
|
core::vector2df(tex_center_pos_x, tex_center_pos_y),
|
|
|
|
|
core::vector2df(tex_width, tex_height));
|
|
|
|
|
core::vector2df(center_pos_x, center_pos_y),
|
|
|
|
|
core::vector2df(width, height),
|
|
|
|
|
core::vector2df(tex_center_pos_x, tex_center_pos_y),
|
|
|
|
|
core::vector2df(tex_width, tex_height) );
|
|
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
|
|
|
|
|
glGetError();
|
|
|
|
|
}
|
|
|
|
|
} // drawTexQuad
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
getSize(unsigned texture_width, unsigned texture_height, bool textureisRTT,
|
|
|
|
|
const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect,
|
|
|
|
|
float &width, float &height,
|
|
|
|
|
float ¢er_pos_x, float ¢er_pos_y,
|
|
|
|
|
float &tex_width, float &tex_height,
|
|
|
|
|
float &tex_center_pos_x, float &tex_center_pos_y
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
static void getSize(unsigned texture_width, unsigned texture_height,
|
|
|
|
|
bool textureisRTT, const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect,
|
|
|
|
|
float &width, float &height,
|
|
|
|
|
float ¢er_pos_x, float ¢er_pos_y,
|
|
|
|
|
float &tex_width, float &tex_height,
|
|
|
|
|
float &tex_center_pos_x, float &tex_center_pos_y )
|
|
|
|
|
{
|
|
|
|
|
core::dimension2d<u32> frame_size = irr_driver->getActualScreenSize();
|
|
|
|
|
const int screen_w = frame_size.Width;
|
|
|
|
|
@@ -112,35 +132,36 @@ float &tex_center_pos_x, float &tex_center_pos_y
|
|
|
|
|
|
|
|
|
|
const f32 invW = 1.f / static_cast<f32>(texture_width);
|
|
|
|
|
const f32 invH = 1.f / static_cast<f32>(texture_height);
|
|
|
|
|
const core::rect<f32> tcoords(
|
|
|
|
|
sourceRect.UpperLeftCorner.X * invW,
|
|
|
|
|
sourceRect.UpperLeftCorner.Y * invH,
|
|
|
|
|
sourceRect.LowerRightCorner.X * invW,
|
|
|
|
|
sourceRect.LowerRightCorner.Y *invH);
|
|
|
|
|
}
|
|
|
|
|
const core::rect<f32> tcoords(sourceRect.UpperLeftCorner.X * invW,
|
|
|
|
|
sourceRect.UpperLeftCorner.Y * invH,
|
|
|
|
|
sourceRect.LowerRightCorner.X * invW,
|
|
|
|
|
sourceRect.LowerRightCorner.Y * invH);
|
|
|
|
|
} // getSize
|
|
|
|
|
|
|
|
|
|
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
|
|
|
|
|
const video::SColor &colors, bool useAlphaChannelOfTexture)
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
void draw2DImage(const video::ITexture* texture,
|
|
|
|
|
const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect,
|
|
|
|
|
const core::rect<s32>* clip_rect,
|
|
|
|
|
const video::SColor &colors, bool use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
if (!CVS->isGLSL()) {
|
|
|
|
|
video::SColor duplicatedArray[4] = {
|
|
|
|
|
colors, colors, colors, colors
|
|
|
|
|
};
|
|
|
|
|
draw2DImage(texture, destRect, sourceRect, clipRect, duplicatedArray, useAlphaChannelOfTexture);
|
|
|
|
|
if (!CVS->isGLSL())
|
|
|
|
|
{
|
|
|
|
|
video::SColor duplicatedArray[4] = { colors, colors, colors, colors };
|
|
|
|
|
draw2DImage(texture, destRect, sourceRect, clip_rect, duplicatedArray,
|
|
|
|
|
use_alpha_channel_of_texture);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float width, height,
|
|
|
|
|
center_pos_x, center_pos_y,
|
|
|
|
|
tex_width, tex_height,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y;
|
|
|
|
|
float width, height, center_pos_x, center_pos_y;
|
|
|
|
|
float tex_width, tex_height, tex_center_pos_x, tex_center_pos_y;
|
|
|
|
|
|
|
|
|
|
getSize(texture->getSize().Width, texture->getSize().Height, texture->isRenderTarget(),
|
|
|
|
|
destRect, sourceRect, width, height, center_pos_x, center_pos_y,
|
|
|
|
|
tex_width, tex_height, tex_center_pos_x, tex_center_pos_y);
|
|
|
|
|
getSize(texture->getSize().Width, texture->getSize().Height,
|
|
|
|
|
texture->isRenderTarget(), destRect, sourceRect, width, height,
|
|
|
|
|
center_pos_x, center_pos_y, tex_width, tex_height,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y);
|
|
|
|
|
|
|
|
|
|
if (useAlphaChannelOfTexture)
|
|
|
|
|
if (use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
@@ -149,40 +170,54 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
|
|
|
|
{
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
if (clipRect)
|
|
|
|
|
|
|
|
|
|
if (clip_rect)
|
|
|
|
|
{
|
|
|
|
|
if (!clipRect->isValid())
|
|
|
|
|
if (!clip_rect->isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
|
const core::dimension2d<u32>& renderTargetSize = irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
|
|
|
|
clipRect->getWidth(), clipRect->getHeight());
|
|
|
|
|
const core::dimension2d<u32>& render_target_size =
|
|
|
|
|
irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clip_rect->UpperLeftCorner.X,
|
|
|
|
|
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
|
|
|
|
clip_rect->getWidth(), clip_rect->getHeight());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()->use();
|
|
|
|
|
glBindVertexArray(SharedObject::UIVAO);
|
|
|
|
|
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()->setTextureUnits(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName());
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
|
|
|
|
|
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height), colors);
|
|
|
|
|
const video::COpenGLTexture *c_texture =
|
|
|
|
|
static_cast<const video::COpenGLTexture*>(texture);
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()
|
|
|
|
|
->setTextureUnits(c_texture->getOpenGLTextureName());
|
|
|
|
|
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()
|
|
|
|
|
->setUniforms(core::vector2df(center_pos_x, center_pos_y),
|
|
|
|
|
core::vector2df(width, height),
|
|
|
|
|
core::vector2df(tex_center_pos_x, tex_center_pos_y),
|
|
|
|
|
core::vector2df(tex_width, tex_height),
|
|
|
|
|
colors);
|
|
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
if (clipRect)
|
|
|
|
|
if (clip_rect)
|
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
|
glUseProgram(0);
|
|
|
|
|
|
|
|
|
|
glGetError();
|
|
|
|
|
}
|
|
|
|
|
} // draw2DImage
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
|
|
|
|
|
const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
|
|
|
|
|
const video::SColor &colors, bool useAlphaChannelOfTexture)
|
|
|
|
|
const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect,
|
|
|
|
|
const core::rect<s32>* clip_rect,
|
|
|
|
|
const video::SColor &colors,
|
|
|
|
|
bool use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
if (useAlphaChannelOfTexture)
|
|
|
|
|
if (use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
@@ -200,36 +235,42 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
|
|
|
|
|
glBindVertexArray(SharedObject::UIVAO);
|
|
|
|
|
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()->setTextureUnits(texture);
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()->setUniforms(
|
|
|
|
|
core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height),
|
|
|
|
|
core::vector2df(tex_center_pos_x, tex_center_pos_y), core::vector2df(tex_width, tex_height),
|
|
|
|
|
colors);
|
|
|
|
|
UIShader::UniformColoredTextureRectShader::getInstance()
|
|
|
|
|
->setUniforms(core::vector2df(center_pos_x, center_pos_y),
|
|
|
|
|
core::vector2df(width, height),
|
|
|
|
|
core::vector2df(tex_center_pos_x, tex_center_pos_y),
|
|
|
|
|
core::vector2df(tex_width, tex_height), colors );
|
|
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
}
|
|
|
|
|
} // draw2DImageFromRTT
|
|
|
|
|
|
|
|
|
|
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
|
|
|
|
|
const video::SColor* const colors, bool useAlphaChannelOfTexture)
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
void draw2DImage(const video::ITexture* texture,
|
|
|
|
|
const core::rect<s32>& destRect,
|
|
|
|
|
const core::rect<s32>& sourceRect,
|
|
|
|
|
const core::rect<s32>* clip_rect,
|
|
|
|
|
const video::SColor* const colors,
|
|
|
|
|
bool use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
if (!CVS->isGLSL())
|
|
|
|
|
{
|
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture);
|
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect,
|
|
|
|
|
clip_rect, colors,
|
|
|
|
|
use_alpha_channel_of_texture);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float width, height,
|
|
|
|
|
center_pos_x, center_pos_y,
|
|
|
|
|
tex_width, tex_height,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y;
|
|
|
|
|
float width, height, center_pos_x, center_pos_y, tex_width, tex_height;
|
|
|
|
|
float tex_center_pos_x, tex_center_pos_y;
|
|
|
|
|
|
|
|
|
|
getSize(texture->getSize().Width, texture->getSize().Height, texture->isRenderTarget(),
|
|
|
|
|
destRect, sourceRect, width, height, center_pos_x, center_pos_y,
|
|
|
|
|
tex_width, tex_height, tex_center_pos_x, tex_center_pos_y);
|
|
|
|
|
getSize(texture->getSize().Width, texture->getSize().Height,
|
|
|
|
|
texture->isRenderTarget(), destRect, sourceRect, width, height,
|
|
|
|
|
center_pos_x, center_pos_y, tex_width, tex_height,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y);
|
|
|
|
|
|
|
|
|
|
if (useAlphaChannelOfTexture)
|
|
|
|
|
if (use_alpha_channel_of_texture)
|
|
|
|
|
{
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
@@ -238,66 +279,86 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
|
|
|
|
|
{
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
}
|
|
|
|
|
if (clipRect)
|
|
|
|
|
if (clip_rect)
|
|
|
|
|
{
|
|
|
|
|
if (!clipRect->isValid())
|
|
|
|
|
if (!clip_rect->isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
|
const core::dimension2d<u32>& renderTargetSize = irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y,
|
|
|
|
|
clipRect->getWidth(), clipRect->getHeight());
|
|
|
|
|
const core::dimension2d<u32>& render_target_size =
|
|
|
|
|
irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clip_rect->UpperLeftCorner.X,
|
|
|
|
|
render_target_size.Height - clip_rect->LowerRightCorner.Y,
|
|
|
|
|
clip_rect->getWidth(), clip_rect->getHeight());
|
|
|
|
|
}
|
|
|
|
|
if (colors)
|
|
|
|
|
drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
|
|
|
|
{
|
|
|
|
|
drawTexColoredQuad(texture, colors, width, height, center_pos_x,
|
|
|
|
|
center_pos_y, tex_center_pos_x, tex_center_pos_y,
|
|
|
|
|
tex_width, tex_height);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
drawTexQuad(static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), width, height, center_pos_x, center_pos_y,
|
|
|
|
|
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
|
|
|
|
|
if (clipRect)
|
|
|
|
|
{
|
|
|
|
|
const video::COpenGLTexture *c_texture =
|
|
|
|
|
static_cast<const video::COpenGLTexture*>(texture);
|
|
|
|
|
drawTexQuad(c_texture->getOpenGLTextureName(), width, height,
|
|
|
|
|
center_pos_x, center_pos_y, tex_center_pos_x,
|
|
|
|
|
tex_center_pos_y, tex_width, tex_height);
|
|
|
|
|
}
|
|
|
|
|
if (clip_rect)
|
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
|
glUseProgram(0);
|
|
|
|
|
|
|
|
|
|
glGetError();
|
|
|
|
|
}
|
|
|
|
|
} // draw2DImage
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
|
|
|
|
|
u32 vertexCount, const void* indexList, u32 primitiveCount,
|
|
|
|
|
video::E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, video::E_INDEX_TYPE iType)
|
|
|
|
|
u32 vertexCount, const void* indexList,
|
|
|
|
|
u32 primitiveCount, video::E_VERTEX_TYPE vType,
|
|
|
|
|
scene::E_PRIMITIVE_TYPE pType,
|
|
|
|
|
video::E_INDEX_TYPE iType)
|
|
|
|
|
{
|
|
|
|
|
if (!CVS->isGLSL())
|
|
|
|
|
{
|
|
|
|
|
irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType);
|
|
|
|
|
irr_driver->getVideoDriver()
|
|
|
|
|
->draw2DVertexPrimitiveList(vertices, vertexCount, indexList,
|
|
|
|
|
primitiveCount, vType, pType, iType);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GLuint tmpvao, tmpvbo, tmpibo;
|
|
|
|
|
primitiveCount += 2;
|
|
|
|
|
glGenVertexArrays(1, &tmpvao);
|
|
|
|
|
glBindVertexArray(tmpvao);
|
|
|
|
|
glGenBuffers(1, &tmpvbo);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, tmpvbo);
|
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * getVertexPitchFromType(vType), vertices, GL_STREAM_DRAW);
|
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * getVertexPitchFromType(vType),
|
|
|
|
|
vertices, GL_STREAM_DRAW);
|
|
|
|
|
glGenBuffers(1, &tmpibo);
|
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tmpibo);
|
|
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, primitiveCount * sizeof(u16), indexList, GL_STREAM_DRAW);
|
|
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, primitiveCount * sizeof(u16),
|
|
|
|
|
indexList, GL_STREAM_DRAW);
|
|
|
|
|
|
|
|
|
|
VertexUtils::bindVertexArrayAttrib(vType);
|
|
|
|
|
|
|
|
|
|
UIShader::Primitive2DList::getInstance()->use();
|
|
|
|
|
UIShader::Primitive2DList::getInstance()->setUniforms();
|
|
|
|
|
const video::SOverrideMaterial &m = irr_driver->getVideoDriver()->getOverrideMaterial();
|
|
|
|
|
Primitive2DList::getInstance()->use();
|
|
|
|
|
Primitive2DList::getInstance()->setUniforms();
|
|
|
|
|
const video::SOverrideMaterial &m = irr_driver->getVideoDriver()
|
|
|
|
|
->getOverrideMaterial();
|
|
|
|
|
compressTexture(tex, false);
|
|
|
|
|
UIShader::Primitive2DList::getInstance()->setTextureUnits(getTextureGLuint(tex));
|
|
|
|
|
Primitive2DList::getInstance()->setTextureUnits(getTextureGLuint(tex));
|
|
|
|
|
glDrawElements(GL_TRIANGLE_FAN, primitiveCount, GL_UNSIGNED_SHORT, 0);
|
|
|
|
|
|
|
|
|
|
glDeleteVertexArrays(1, &tmpvao);
|
|
|
|
|
glDeleteBuffers(1, &tmpvbo);
|
|
|
|
|
glDeleteBuffers(1, &tmpibo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} // draw2DVertexPrimitiveList
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
|
|
|
|
const core::rect<s32>* clip)
|
|
|
|
|
const core::rect<s32>* clip)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (!CVS->isGLSL())
|
|
|
|
|
@@ -336,14 +397,18 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
|
const core::dimension2d<u32>& renderTargetSize = irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clip->UpperLeftCorner.X, renderTargetSize.Height - clip->LowerRightCorner.Y,
|
|
|
|
|
clip->getWidth(), clip->getHeight());
|
|
|
|
|
const core::dimension2d<u32>& render_target_size =
|
|
|
|
|
irr_driver->getActualScreenSize();
|
|
|
|
|
glScissor(clip->UpperLeftCorner.X,
|
|
|
|
|
render_target_size.Height - clip->LowerRightCorner.Y,
|
|
|
|
|
clip->getWidth(), clip->getHeight());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIShader::ColoredRectShader::getInstance()->use();
|
|
|
|
|
glBindVertexArray(SharedObject::UIVAO);
|
|
|
|
|
UIShader::ColoredRectShader::getInstance()->setUniforms(core::vector2df(center_pos_x, center_pos_y), core::vector2df(width, height), color);
|
|
|
|
|
UIShader::ColoredRectShader::getInstance()
|
|
|
|
|
->setUniforms(core::vector2df(center_pos_x, center_pos_y),
|
|
|
|
|
core::vector2df(width, height), color );
|
|
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
|
@@ -353,4 +418,4 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
|
|
|
|
|
glUseProgram(0);
|
|
|
|
|
|
|
|
|
|
glGetError();
|
|
|
|
|
}
|
|
|
|
|
} // GL32_draw2DRectangle
|
|
|
|
|
|