Jump to content
  • Advertisement
Sign in to follow this  
kkc0923

OpenGL question: 2D rendering and multiple scene rendering for GUI using DirectX11

This topic is 1465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. Im working now on rich 3d modeling application for my graduate school project. I worked with WinForm Controls + OpenTK (OpenGL), but there is a lot of limitations in WinForm GUI. So I decide to re-write entire application with custom GUI and change rendering API to SharpDX (DirectX) to support WindowsRT and Windows Phone. (Yes. I'm MS geek :) )

 

I have experiences of using GDI based rendering, but it seems that DirectX11 does not have 2D rendering methods (manual pixel blitz, draw rect/circle/line/point, and so on). Here is my first question, how to render efficiently 2d (point, line, rect or circle ...) geometries? (drawing 3d quad is looks inefficient in especially draw single line or rectangle with boundary lines.)

 

Last question is that about render multiple view(multiple camera) for single scene. For example, 3ds max and Blender, it can add more than one scene view for single scene. So you can see top, bottom, left, right view at the same time. I think that this can be implemented by using Render-to-texture technique, Make each camera and render target texture. and render to each render target texture, then draw each textures to current swapchain using quad texture rendering technique. Is this correct and most efficient way?

 

Thanks.

 

(Im very happy if there is resource or samples for 2D rendering and Multi-view rendering technique using DirectX (especially, SharpDX))

 

Share this post


Link to post
Share on other sites
Advertisement

Hi. there.

For you 2d rendering you may look up orthographic projection.(don't forget to base positioning for ui based on percentage of screen and not pixels dimentions)

You can use GPU and geometry shader to expand a point to a quad or you can define the quad in the app and go with vertex shader.

 

 

and for lines and things it only triangles 2 for a quad.  A quad can be made to look like a line.

 

For multi view rendering you could use rendertargets or maybe viewport settings can be mapped to porstions of the screen.

Share this post


Link to post
Share on other sites

Hi. there.

For you 2d rendering you may look up orthographic projection.(don't forget to base positioning for ui based on percentage of screen and not pixels dimentions)

You can use GPU and geometry shader to expand a point to a quad or you can define the quad in the app and go with vertex shader.

 

 

and for lines and things it only triangles 2 for a quad.  A quad can be made to look like a line.

 

For multi view rendering you could use rendertargets or maybe viewport settings can be mapped to porstions of the screen.

 

Thanks for reply. I found that there is no GDI and directdraw, but Direct2D. It seems that direct2d can draw 2d geometries to direct3d textures. Is this efficient that Using direct2D for creating GUI textures (contains menu, controls, text ...) and draw these textures to swapchain by using Direct3D Quad ?

Share this post


Link to post
Share on other sites

I found that there is no GDI..

 

GDI (and GDI+) can, indeed, be used with Direct3D 11 - the device and swapchain just have to be setup for their use. I'd be curious where you "found" that there is no GDI support. It may not be a part of SharpDX, but explicit support is provided in D3D11.

 

The device is created with D3D11_CREATE_DEVICE_BGRA_SUPPORT, the backbuffer format is set to DXGI_FORMAT_B8G8R8A8_UNORM, and the swapchain creation flags include DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE.

 

Before the backbuffer is Presented:

        //========================================= testing GDI ========================
        IDXGISurface1* pSurface1;
        HRESULT hr = g_pSwapChain->GetBuffer(0, __uuidof(IDXGISurface1), (void**)&pSurface1);
        if(SUCCEEDED(hr))
        {
             HDC hdc;
             hr = pSurface1->GetDC(FALSE, &hdc);
             if(SUCCEEDED(hr))
             {
                  TextOut(hdc, 10, 10, "Hello", 5); // GDI or GDI+ stuff goes here
                  pSurface1->ReleaseDC(NULL);
              }
              pSurface1->Release();
        }

That is not to say that using GDI or GDI+ is fast, by any means. However, for limited use such as debugging, routines for which rendering speed is not a consideration, etc., it's fine.

Edited by Buckeye

Share this post


Link to post
Share on other sites

@Buckeye

Thanks for reply.

Actually,I found that there is no GDI support in WindowsRT and Windows Phone :) . My plan is that building complete GUI system which rely on not WinForms but only directx, so make easy to sharing same code between desktop app WinRT apps (Metro, WP8). I'll try to imitate GUI system in Blender Project, it looks really cool. It only uses OpenGL so it can draw completely same GUI experience for variable OS (Linux, Windows ...).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!