custom geometry in DX10/11

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

KN4CK3R
Just popping in
Just popping in
Posts: 2
Joined: Sun Oct 27, 2013 21:58

custom geometry in DX10/11

Postby KN4CK3R » Sun Oct 27, 2013 22:19

Hi,

I was playing around with custom geometry in the CEGUI Sample App and found a problem:
I added this code inside RenderSingleFrame (CEGuiBaseApplication.cpp).

Code: Select all

gui_renderer->beginRendering();

d_sampleApp->renderGUIContexts();

static auto *buffer = &gui_renderer->createGeometryBuffer();
static bool once = true;
if (once)
{
   once = false;

   using namespace CEGUI;

   const Rectf scrn(d_renderer->getDefaultRenderTarget().getArea());
   buffer->setClippingRegion(scrn);

   int x = 50, y = 50;
   
   Vertex vertices[6];
   #define init(i, v, t, c) vertices[i].position = v; vertices[i].tex_coords = t; vertices[i].colour_val = c;
   init(0,Vector3f(x, y, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))
   init(1,Vector3f(x + 100, y, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))
   init(2,Vector3f(x, y + 100, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))
   init(3,Vector3f(x + 100, y + 100, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))
   init(4,Vector3f(x, y + 100, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))
   init(5,Vector3f(x + 100, y, 0.0f), Vector2f(0, 0), Colour(0xFFFFFFFF))

   buffer->appendGeometry(vertices, 6);

   auto fnt = System::getSingleton().getDefaultGUIContext().getDefaultFont();
   if (fnt)
   {
      fnt->drawText(*buffer, "test", Vector2f(10, 10), nullptr, Colour(0xFFFFFFFF));
   }
}

buffer->draw();

gui_renderer->endRendering();


This will draw "test" and a white rectangle. It works fine in DX9 and OpenGL but not in DX10/11. Only the text is drawn there. I think it is because the text uses a texture while the rectangle doesn't.
Did I miss something? How can I draw the rectangle in DX10/11 too?

KN4CK3R
Just popping in
Just popping in
Posts: 2
Joined: Sun Oct 27, 2013 21:58

Re: custom geometry in DX10/11

Postby KN4CK3R » Mon Oct 28, 2013 16:04

I fixed it.
I think it is because the text uses a texture while the rectangle doesn't.

This was true, so I rewrote some parts of the shader.

Shader:

Code: Select all

[...]

Texture2D BoundTexture;
bool useShaderTexture;

[...]

float4 PSMain(PSSceneIn input) : SV_Target
{
   float4 colour;
   if (useShaderTexture)
      colour = BoundTexture.Sample(LinearSampler, input.tex) * input.colour;
   else
      colour = input.colour;
   return colour;
}

[...]


Renderer:

Code: Select all

//in Direct3D10Renderer::Direct3D10Renderer(ID3D10Device* device)
useShaderTextureVariable = effect->GetVariableByName("useShaderTexture")->AsScalar();

//in Direct3D10Renderer::setCurrentTextureShaderResource(ID3D10ShaderResourceView* srv)
d_boundTextureVariable->SetResource(srv);
useShaderTextureVariable->SetBool(srv != nullptr);


I haven't tested it for DX11 but it must be the same problem. ;)

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: custom geometry in DX10/11

Postby Kulik » Thu Nov 07, 2013 10:55

Interesting, it looks like we definitely want this fixed.

Could you provide a pull request / patch for both DX10 and 11? I don't have Windows so it's hard for me to test this fix.

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: custom geometry in DX10/11

Postby Ident » Mon Nov 11, 2013 21:41

this does not seem like a correct solution to me, and if/else in fragment shaders are kind of nasty. Can you explain exactly what you are trying to achieve? you want to render a rectanlge with CEGUI if i got that right? Is everything i nthe samples working for you though?
CrazyEddie: "I don't like GUIs"


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 1 guest