www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - directx with d

reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

Bit of a help would be appreciated, the attached code should display a triangle.

http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

Contact me at elf_qt _deletethis_yahoo.com

ElfQT
Feb 07 2008
next sibling parent reply "Vladimir Panteleev" <thecybershadow gmail.com> writes:
On Thu, 07 Feb 2008 17:16:04 +0200, ElfQT <elf_qt _deletethis_yahoo.com> wrote:

 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT
Have you seen the Win32 API bindings project? They seem to have ported some or all of the DirectX headers: http://www.dsource.org/projects/bindings/wiki/WindowsApi Also, check out this in-progress 3D game engine written in D: http://www.yage3d.net/ -- Best regards, Vladimir mailto:thecybershadow gmail.com
Feb 07 2008
parent reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
Vladimir Panteleev Wrote:

 On Thu, 07 Feb 2008 17:16:04 +0200, ElfQT <elf_qt _deletethis_yahoo.com> wrote:
 
 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT
Have you seen the Win32 API bindings project? They seem to have ported some or all of the DirectX headers: http://www.dsource.org/projects/bindings/wiki/WindowsApi Also, check out this in-progress 3D game engine written in D: http://www.yage3d.net/ -- Best regards, Vladimir mailto:thecybershadow gmail.com
Yep, I am aware of the bindings, also I use them in newer code - in the attached code I tried to use a minimal version, and also a simple one which worked well with dmd back in 2005. Thanks for the link to Yage. Unfortunately Yage uses openGL. ElfQT
Feb 07 2008
parent Clay Smith <clayasaurus gmail.com> writes:
ElfQT wrote:
 Vladimir Panteleev Wrote:
 
 On Thu, 07 Feb 2008 17:16:04 +0200, ElfQT <elf_qt _deletethis_yahoo.com> wrote:

 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT
Have you seen the Win32 API bindings project? They seem to have ported some or all of the DirectX headers: http://www.dsource.org/projects/bindings/wiki/WindowsApi Also, check out this in-progress 3D game engine written in D: http://www.yage3d.net/ -- Best regards, Vladimir mailto:thecybershadow gmail.com
Yep, I am aware of the bindings, also I use them in newer code - in the attached code I tried to use a minimal version, and also a simple one which worked well with dmd back in 2005. Thanks for the link to Yage. Unfortunately Yage uses openGL. ElfQT
He probably meant this link www.dsource.org/projects/nonagon
Feb 07 2008
prev sibling parent reply Extrawurst <spam extrawurst.org> writes:
i tried your attached app and it works for me with dmd2.010 i just 
changed the depencies to get it working with phobos, cause i dont use tango.


ElfQT schrieb:
 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT


   
Feb 07 2008
parent reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
Extrawurst Wrote:

 i tried your attached app and it works for me with dmd2.010 i just 
 changed the depencies to get it working with phobos, cause i dont use tango.
 
 
 ElfQT schrieb:
 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT


   
Well, by working you mean you see the triangle (instead of the simple backgroud)? I'll try that with phobos, also with dmd2.010, if that difference causes this then there is an interesting bug somewhere... Thanks, ElfQT
Feb 07 2008
parent reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
ElfQT Wrote:

 Extrawurst Wrote:
 
 i tried your attached app and it works for me with dmd2.010 i just 
 changed the depencies to get it working with phobos, cause i dont use tango.
 
 
 ElfQT schrieb:
 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT


   
Well, by working you mean you see the triangle (instead of the simple backgroud)? I'll try that with phobos, also with dmd2.010, if that difference causes this then there is an interesting bug somewhere... Thanks, ElfQT
Whoa I see this is what happening. It works with dmdv1.026 and phobos. I am investigating this issue, right now I suspect tango - somebody from there please lend me a hand.
Feb 07 2008
next sibling parent reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
There is a problem - difference - between dmdc1.0124 AND default phobos versus
"tango-0.99.4-bin-win32-dmd.1.024".

See the code below:

// A structure for our custom vertex type
struct CUSTOMVERTEX
{
    FLOAT x, y, z, rhw; // The transformed position for the vertex
    DWORD color;        // The vertex color
};

// Initialize three vertices for rendering a triangle
static CUSTOMVERTEX[3] vertices =
[
	{ 150.0f,  50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color
	{ 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, },
	{  50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, },
];

int a = vertices.sizeof;

a is 120 with phobos, 60 with tango.


Some related question: is it possible for tango and phobos to live side by
side, also edit and debug side by side? (Something like an automated test that
is capable to compare phobos vs tango build?) It isn't simple to find a
difference like this one.

Or is this difference intentional to begin with?

ElfQT
Feb 09 2008
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"ElfQT" <elf_qt _deletethis_yahoo.com> wrote in message 
news:fols9e$19u0$1 digitalmars.com...
 There is a problem - difference - between dmdc1.0124 AND default phobos 
 versus "tango-0.99.4-bin-win32-dmd.1.024".

 See the code below:

 // A structure for our custom vertex type
 struct CUSTOMVERTEX
 {
    FLOAT x, y, z, rhw; // The transformed position for the vertex
    DWORD color;        // The vertex color
 };

 // Initialize three vertices for rendering a triangle
 static CUSTOMVERTEX[3] vertices =
 [
 { 150.0f,  50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color
 { 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, },
 {  50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, },
 ];

 int a = vertices.sizeof;

 a is 120 with phobos, 60 with tango.
I don't see why the size would differ based on the standard library, that's really odd. The library should have no effect on this code. Regardless, you should put align(1) on the CUSTOMVERTEX struct declaration, which SHOULD make it 60 in both.
 Some related question: is it possible for tango and phobos to live side by 
 side, also edit and debug side by side? (Something like an automated test 
 that is capable to compare phobos vs tango build?) It isn't simple to find 
 a difference like this one.

 Or is this difference intentional to begin with?
I'm not sure why you'd want to. There's tangobos which is an implementation of phobos in Tango, but you should really either target one, or if you really must, use "version(Tango) { ... } else { ... }" statements.
Feb 10 2008
prev sibling parent reply ElfQT <elf_qt _deletethis_yahoo.com> writes:
ElfQT Wrote:

Finally I have found the time to investigate this issue.
And the winner is...

Same code will follow with phobos then with tango:

//phobos
import std.c.windows.windows;

struct CUSTOMVERTEX { FLOAT x; };
static CUSTOMVERTEX[3] vertices = [ { 150.0f } ];

void main() { printf ("%d",vertices.sizeof); }

Prints 12.

//tango
import tango.sys.win32.Types;
import tango.stdc.stdio;

struct CUSTOMVERTEX { FLOAT x; };
static CUSTOMVERTEX[3] vertices = [ { 150.0f } ];
void main() { printf ("%d",vertices.sizeof); }

Prints 24.

The difference lies:

Phobos, \dmd\src\phobos\std\c\windows\windows.d:
alias float FLOAT;

Tango, D:\D\import\tango\sys\win32\Types.di:
alias double FLOAT;

(Before you ask, I use type FLOAT - uppercase - because I copy some directx
code, which already uses that.)
With directx on win32, the phobos approach is working, Tango FLOAT produces
errors.

Is this intended in Tango? Is there already code requiring FLOAT to be double?

The problem in the original post is disappears (and the directx triangle
appears), if I use float instead of FLOAT (so double in Tango).

ElfQT

 ElfQT Wrote:
 
 Extrawurst Wrote:
 
 i tried your attached app and it works for me with dmd2.010 i just 
 changed the depencies to get it working with phobos, cause i dont use tango.
 
 
 ElfQT schrieb:
 I have ported some directx tutorial back in 2005... This time I play around
again with directx and also with tango.
 But I have a problem even with the old directx code of mine - which of course
worked on the old dmd compiler.
 Right now the compiler and tango verisons are:
tango-0.99.4-bin-win32-dmd.1.024.zip

 Bit of a help would be appreciated, the attached code should display a
triangle.

 http://tmtinformatika.hu/_Others/Marton/dx_vertices.zip

 Contact me at elf_qt _deletethis_yahoo.com

 ElfQT


   
Well, by working you mean you see the triangle (instead of the simple backgroud)? I'll try that with phobos, also with dmd2.010, if that difference causes this then there is an interesting bug somewhere... Thanks, ElfQT
Whoa I see this is what happening. It works with dmdv1.026 and phobos. I am investigating this issue, right now I suspect tango - somebody from there please lend me a hand.
Mar 01 2008
parent reply torhu <no spam.invalid> writes:
ElfQT wrote:
 The difference lies:
 
 Phobos, \dmd\src\phobos\std\c\windows\windows.d:
 alias float FLOAT;
 
 Tango, D:\D\import\tango\sys\win32\Types.di:
 alias double FLOAT;
 
 (Before you ask, I use type FLOAT - uppercase - because I copy some directx
code, which already uses that.)
 With directx on win32, the phobos approach is working, Tango FLOAT produces
errors.
 
 Is this intended in Tango? Is there already code requiring FLOAT to be double?
This looks like a tango bug, FLOAT is a C float. http://msdn2.microsoft.com/en-us/library/aa383751.aspx
Mar 01 2008
parent reply torhu <no spam.invalid> writes:
torhu wrote:
 ElfQT wrote:
 The difference lies:
 
 Phobos, \dmd\src\phobos\std\c\windows\windows.d:
 alias float FLOAT;
 
 Tango, D:\D\import\tango\sys\win32\Types.di:
 alias double FLOAT;
 
 (Before you ask, I use type FLOAT - uppercase - because I copy some directx
code, which already uses that.)
 With directx on win32, the phobos approach is working, Tango FLOAT produces
errors.
 
 Is this intended in Tango? Is there already code requiring FLOAT to be double?
This looks like a tango bug, FLOAT is a C float. http://msdn2.microsoft.com/en-us/library/aa383751.aspx
Tango's PFLOAT is wrong too.
Mar 01 2008
parent ElfQT <elf_qt _deletethis_yahoo.com> writes:
Thanks. Issue entered to Tango's Trac,
http://www.dsource.org/projects/tango/ticket/955
ElfQT

torhu Wrote:

 torhu wrote:
 ElfQT wrote:
 The difference lies:
 
 Phobos, \dmd\src\phobos\std\c\windows\windows.d:
 alias float FLOAT;
 
 Tango, D:\D\import\tango\sys\win32\Types.di:
 alias double FLOAT;
 
 (Before you ask, I use type FLOAT - uppercase - because I copy some directx
code, which already uses that.)
 With directx on win32, the phobos approach is working, Tango FLOAT produces
errors.
 
 Is this intended in Tango? Is there already code requiring FLOAT to be double?
This looks like a tango bug, FLOAT is a C float. http://msdn2.microsoft.com/en-us/library/aa383751.aspx
Tango's PFLOAT is wrong too.
Mar 01 2008