Sign in to follow this  
spawn_thang

Com C++ or and assembler

Recommended Posts

spawn_thang    148
Hello,

This post is to check what I understand is right or not and is about COM. I have understood that COM objects / interfaces are written in C++ and COM was created for C++ and that is what is used to create a COM object / COM interface.

So, my question is really this : Would it be possible to create a COM object or a function that the interface called using Assembler ?

MY guess is that it would not be possible and is not done but on the other hand, it might be possible and if it is possible does Direct X use any assembler driven functionality ?

Thanks,

Robert.

Share this post


Link to post
Share on other sites
wack    1358
Hello,

If I understand you correctly, you want to know if it's possible to call COM objects from assembler code.

The layout of COM objects is not C++ specific, and with a little trickery it should be possible to call and COM objects from assembler. Here is a little article about the memory layout to get you started: [url="http://blogs.msdn.com/b/oldnewthing/archive/2004/02/05/68017.aspx"]http://blogs.msdn.com/b/oldnewthing/archive/2004/02/05/68017.aspx[/url]

Share this post


Link to post
Share on other sites
Cygon    1219
COM very accurately specifies the binary structure of its objects (= what the C++ compiler spews out, eg. that classes must use a vtable, where this vtable is located, etc.). That is one of COM's purposes: to allow multiple programming languages to work together.

You can use as well as create COM objects in assembly, C++, Visual Basic 6, .NET, Delphi and many other languages.

Share this post


Link to post
Share on other sites
rip-off    10976
Anything that can be done on your CPU can be done in assembler. After all - your computer only executes machine code, and assembler is just machine code for humans.

One of the moderators was doing this just the other day:
[list]
[*] [url="http://www.gamedev.net/blog/32/entry-2254703-when-boredom-strikes/"]When Boredom Strikes[/url]
[*] [url="http://www.gamedev.net/blog/32/entry-2254711-oh-god-it-gets-even-worse/"]Oh God, It gets even worse![/url]
[/list]

I wouldn't recommend it, it looks rather tedious.

[quote]
... does Direct X use any assembler driven functionality?
[/quote]
Direct X doesn't (intentionally) expose anything interesting to clients written directly in assembly that isn't available to clients in high level languages.

Just in case you are not aware, high performance in modern graphics programming is not achieved by hand-coding assembly. Your research time would be better dedicated to ensuring you are efficiently batching the data to be drawn rather than wasted wondering about assembly. Unless you are bored and looking for a coding challenge like Washu, I don't think it is worth it.

Share this post


Link to post
Share on other sites
spawn_thang    148
Hello again,

Yeah, reading through the replies, especially the last one, I have a question because for a long time I got stuck on a problem and I figure it has something to do with Opengl having better maths libraries than Direct X. For, in an article that compares direct X to Opengl it mentioned that no one uses Direct X to create Scientifically precise applications. And since a 3D Modeler comes under the heading of a scientifically precise application. I was led to believe that it was not possible to create a 3d editor using Direct X unless a math library that included for instance, a more precise rotation matrix was created by the developer. So, that when a calculation needed a better result than Direct X could provide, the developers math library could be uses to calculate the required result which would then pass the results back to the Direct X object.

And this is why, I was wondering if any of the interfaces were written in assembler, for I had seemed to me that it might be possible to get better results if rotation math were performed in assembler and then passed back to the object. For, the level of error in the Direct X rotation matrix seem to be fairly serious.

Anyhow's, those are the lines I have been thinking along.

Share this post


Link to post
Share on other sites
Washu    7829
[quote name='Thermal Blast' timestamp='1339876398' post='4949876']
Hello again,

Yeah, reading through the replies, especially the last one, I have a question because for a long time I got stuck on a problem and I figure it has something to do with Opengl having better maths libraries than Direct X. For, in an article that compares direct X to Opengl it mentioned that no one uses Direct X to create Scientifically precise applications. And since a 3D Modeler comes under the heading of a scientifically precise application. I was led to believe that it was not possible to create a 3d editor using Direct X unless a math library that included for instance, a more precise rotation matrix was created by the developer. So, that when a calculation needed a better result than Direct X could provide, the developers math library could be uses to calculate the required result which would then pass the results back to the Direct X object.[/quote]
No. OpenGL does not have better "math" than DirectX. They do pretty much IDENTICAL work as far as the graphics pipeline goes. The primary reason why OpenGL was the main goto thing for "scientific" computing has pretty much NOTHING to do with accuracy (accuracy is achieved through the use of bignum libraries. Not through graphics APIs). It has to do with a scientists limited knowledge set. Most scientists can program in C, or C++, or Delphi or similar languages. But they're not very good at it. When you're trying to visualize the data output from an n-body simulation the easiest thing in the world to do is simply use OpenGL immediate mode. Not to mention, some of these folks aren't running on Windows machines.

Share this post


Link to post
Share on other sites
spawn_thang    148
Okay, from reading back through this today, I see two options to improve the accuracy of matrix rotations :
1) Pass the matrix data to a big num library.
2) Use Quaternions instead of matrices.


Also, it has to be said, there is nothing out there written in Direct X that can touch Blender which is written in Opengl and there must be a good reason for that, one I guess is that Opengl has a huge and very accurate Math library.

Share this post


Link to post
Share on other sites
Brother Bob    10344
Internal data processing within your application has nothing to with visualization. If you need high-precision processing, then you need high-precision processing within your application and not within the graphics API. OpenGL really offers nothing more than Direct3D on this front. Nothing.

If you're having problem with with precision of your rotation matrices, then, if Direct3D is not an option, OpenGL is certainly not the solution to your problem either. But why do you think you have a precision problem with your matrices anyway? What kind of problems are you having that requires a higher precision graphics API?

Share this post


Link to post
Share on other sites
spawn_thang    148
HI Bob,

Thanks for the reply. I have distanced myself from the problems I was experiencing with matrix math and apparent floating point inaccuracy and it may well be the way I tried to implement the math but what ever I tried over a couple of years always resulted in the same problem, which was a floating point error in rotation when feeding a rotation calculation a couple of inverse tangents in order for the matrix to rotate a mesh by a specified degree/radian. There were significant errors and the way I was trying to do this may have been totally wrong but this is what I was trying to do.

I had a number of vertices selected on an object say a sphere, on the left side of the object and above the equator.

I wanted to extrude these vertices along a tangent and my math was not good enough.to try and work out how to do it with out translating the object
to the center of the view and then rotating through, Y and X until the sub object was orthogonal to the view and set round the origin.

The premise was that once the sub mesh was at that point, it could be processed and returned back to its original position and then a series
of edits could be built up in real time, hence and extrusion function that appear to extrude through a tangent.

I knew it worked because if the vertices were orthogonal to the view (if that is the correct term), then I could process without a problem.

The issue became one if the vertices were not central or orthogonal to the view for I could translate the object to the center but every time
I tried to rotate this sub mesh, the rotation was just a little bit out.

And I tried everything I could. Although I think maybe it would have been better to implement the calculation in a virtual way so that the
sub mesh was not actually rotated but set when the virtual rotation had been calculated behind the scene.

So, every thing failed until on night visualized a possible solution that was like 'rotating a flag round a flag pole'.

What this meant was not to translate to the center but to place an anchor vertex on say the lower left vertex and translate the
sub mesh to the right side of 'the equation', which meant the anchor vertex was set at the origin.

This meant I could then rotate around Y and then rotate through Z and then finally though X.

From there, I could shift the sub mesh left by half its width and then down by half its height.

This made it central to the view and I could then apply a process to the sub mesh and re translate and then re rotate
back to its original position.

The only problem was, that if I hard coded the tangents the calculation would always fail, so I had to ask the application to 'spin' the sub mesh
until it was 'as close to zero' as it could be and after several thousand spins, each successive rotation 'hit zero' and was 'kind of ok'.

And this is why I have been asking questions about the floating point accuracy.

From the distance I am away from this work now, I would say I was overloading the system whereas, I should have processed this in a
virtual way without the sub mesh.

Anyhow's, my dark secrets are public now !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this