Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


tweduk

Member Since 05 Oct 2006
Offline Last Active Mar 06 2013 11:15 AM

Topics I've Started

Windowed mode and enumerating adapters and outputs

02 February 2013 - 09:55 AM

I'm a little confused about the proper way for a Windowed mode app, which must work nicely with multimonitor setups, to create its principal objects such as the device and swapchain.

 

Suppose I have a window (i.e. an HWND), which can be on any monitor (i.e. output), and I want to create a D3D11 device and swapchain for it. To keep things simple initially, I'll assume that the window doesn't span multiple monitors. How can I figure out which adapter and output the window lives on?

 

From reading the docs in the Jun 2010 DX SDK, it seems that the only available method for this type of query is IDXGISwapChain::GetContainingOutput. But this requires a swap chain to be created, which seems to require a device to be created, which seems to require me to guess which device / adapter contains my window, defeating the original object. I am assuming that adapters and devices are just different aspects of the same thing.

 

Do I really have to enumerate every adapter, creating a device and swapchain until I find the one that contains the majority of my window's client area? I guess I am probably missing something, or making some invalid assumptions.

 

All of the examples that I've looked at avoid this issue because either they use D3D11CreateDeviceAndSwapChain to create a device, or they operate in fullscreen mode, or they simply don't appear to care about working correctly on multimonitor setups.

 

IDXGISwapChain::GetContainingOutput only returns the output containing the majority of a window's client area, so I can't see how to support the more general case (find the complete set of adapters and outputs on which any part of the window's client area is visible).

 

I guess I could use D3D11CreateDeviceAndSwapChain, but I prefer to know what's really going on, and also to have the knowledge to make the application work in the most general case.

 

Thanks in advance for any wisdom.

Tom


[.net] Generic classes in mixed C# and C++/CLI VS2010 solution

24 April 2010 - 07:20 AM

Hi, I have a trivial .NET 4.0 C# project, consisting of ICSharpInterface.cs:
namespace CSharp {
    public interface ICSharpInterface<T> where T : struct {
    }
}

According to the documentation, "where T : struct" constrains T to be a value type. I also have a trivial .NET 4.0 C++/CLI project that references the C# project. It consists of CPPImplementation.h and CPPImplentation.cpp:
#pragma once

namespace CPlusPlus {
    generic <typename T> where T : value class
        public ref class CPPImplementation : CSharp::ICSharpInterface<T>
	{
	};
}

#include "CPPImplementation.h"

According to the documentation, "where T : value class" constrains T to be a value type. When I attempt to build the solution, it fails as follows when compiling CPPImplementation.cpp: Error 1 error C3214: 'T' : invalid type argument for generic parameter 'T' of generic 'CSharp::ICSharpInterface', does not meet constraint 'System::ValueType ^' y:\develop\vs2010\test\cppimplementation\CPPImplementation.h 5 1 CPPImplementation Any ideas who or what is at fault here? I find it odd that it wants T to be "System::ValueType^" instead of "System::ValueType". Maybe the definition of "value type" is different in C++/CLI and C#, even though they both run on top of .NET ? thanks Tom

[SlimDX r1242] How to use a compiled DX10 shader without effects framework

24 October 2009 - 01:23 AM

Hi, If (for example) I have a compiled vertex shader in a file and want to create a VertexShader object (without using the effects framework), there doesn't seem to be a way to do it. I am looking at the r1242 SlimDX sources. I would have thought the most logical way to do it would be to have an overload in the ShaderByteCode class, maybe a constructor, that accepts something like an array of byte, which would be the compiled shader loaded from the file. However the current methods seem to imply that the only supported way to get a ShaderByteCode object is by compiling some HLSL programmatically. In other words, the current system doesn't appear to support precompiled shaders without the effects framework. I could easily be missing something though... Any advice for me? It's not really a pressing concern, since I have worked around this so far by hacking on a few methods to SlimDX. cheers

[SlimDX r1200 D3D10] No way to create ShaderBytecode object from byte array?

06 September 2009 - 08:20 AM

Hi, I saw that someone had requested from additional methods for dealing with Direct3D10 shaders, and Mike P added some stuff. However, I think that Mike's changes didn't quite go all the way. The problem remains that there's still no way to create a ShaderBytecode object from a memory array (as far as I can see, looking at the r1200 source code). What we need is a method as per the suggestion in http://code.google.com/p/slimdx/issues/detail?id=293&can=1&q=shader&colspec=ID Type Status Priority Owner Summary Milestone Or am I missing something? In the meantime I will knock up a method myself based on the issue 293 suggestion. regards & thanks for the good work so far on SlimDX, Tomas

Eigenvector of a 3 x 3 matrix for plane fitting

19 May 2008 - 05:04 AM

In Dave Eberly's excellent website, there is a paper about data fitting: http://www.geometrictools.com/Documentation/LeastSquaresFitting.pdf Specifically, I am interested in orthogonal regression fitting of a set of 3D points to a plane. This is covered by section 4 of the above paper. In my case, n = 3 (dimension of points is 3). The number of points could be anywhere from 3 to several thousand. So, to find the normal vector of the best-fit plane, I need to find the eigenvector corresponding to the smallest eigenvalue of a 3 x 3 matrix. Is the following a reasonable solution (assuming the specific case of n = 3): 1. Set matrix M' to be: M' = (M - aI) where 'M' is the matrix whose eigenvector I want and 'a' is an eigenvalue of 'M'. 2. Generate characteristic polynomial, from the expression det(M') = det(M - aI) = 0 This will give a cubic polynomial in 'a'. 3. Solve the cubic polynomial to get the 3 roots for 'a'. Take the smallest root to be the required eigenvalue. From Eberly's paper, M' appears to be a symmetric matrix, so the eigenvalues are guaranteed to be real. 4. Using the expression (M - sI)x = 0 where 's' is the smallest eigenvalue found in step 3 above, apply Cramer's Rule to find the eigenvector 'x'. This should be a vector normal to the best fit plane, and I'm done. I must admit that my linear algebra is at only a basic level, so I'd be interested to know if my reasoning is sound, and what drawbacks there are to this method (e.g. poor numerical stability). I don't need the best fit plane to be super-accurate. The reason I ask is because the eigensystem solvers that come in various numerical packages seem awfully heavyweight for what I want to do. I would prefer not to have to distribute a numerical package with my application. It's also a bit of a pain to make some of them (e.g. GSL) work well in a C# application. thanks for any comments Tom [Edited by - tweduk on May 19, 2008 11:42:20 AM]

PARTNERS