Changeset 33
- Timestamp:
- 03/05/09 19:19:26 (3 years ago)
- Files:
-
- trunk/nonagon/node.d (modified) (9 diffs)
- trunk/test.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/nonagon/node.d
r32 r33 26 26 protected Matrix mMatGlobal; 27 27 protected Matrix mMatRotation; 28 protected bool mMatDirty; 28 29 29 30 protected Node mParent; 30 protected Node[] mChildren; 31 protected Node mSibling; 32 protected Node mChild; 31 33 protected char[] mName; 32 protected bool mMatDirty;33 34 34 35 // ================================================================================================================================================ … … 614 615 615 616 /** 616 Returns: 617 The Node's current parent. 617 Gets this node's parent, or null if it has none. 618 618 */ 619 619 Node parent() 620 620 { 621 621 return mParent; 622 } 623 624 /** 625 Gets this node's next sibling, or null if it has none. You cannot set siblings, only parents. 626 */ 627 Node sibling() 628 { 629 return mSibling; 630 } 631 632 /** 633 Gets this node's first child, or null if it has no children. You cannot set children, only 634 parents. 635 */ 636 Node child() 637 { 638 return mChild; 622 639 } 623 640 … … 634 651 int opApply(int delegate(ref Node) dg) 635 652 { 636 for each(n; mChildren)653 for(auto n = mChild; n !is null; n = n.mSibling) 637 654 if(auto result = dg(n)) 638 655 return result; … … 653 670 int opApply(int delegate(ref uword i, ref Node) dg) 654 671 { 655 foreach(i, n; mChildren) 672 uword i = 0; 673 674 for(auto n = mChild; n !is null; n = n.mSibling, i++) 656 675 if(auto result = dg(i, n)) 657 676 return result; … … 680 699 if(recursive) 681 700 { 682 for each(n; mChildren)701 for(auto n = mChild; n !is null; n = n.mSibling) 683 702 { 684 703 if(n.name == name) … … 691 710 else 692 711 { 693 for each(n; mChildren)712 for(auto n = mChild; n !is null; n = n.mSibling) 694 713 if(n.name == name) 695 714 return n; … … 732 751 protected void addChild(Node c) 733 752 { 734 debug foreach(child; mChildren) assert(c !is child); 735 mChildren ~= c; 753 debug for(auto n = mChild; n !is null; n = n.mSibling) assert(c !is n); 754 755 c.mSibling = mChild; 756 mChild = c; 736 757 } 737 758 738 759 protected void removeChild(Node c) 739 760 { 740 foreach(i, child; mChildren)761 if(c is mChild) 741 762 { 742 if(c is child) 763 mChild = c.mSibling; 764 return; 765 } 766 else 767 { 768 for(auto n = mChild; n !is null; n = n.mSibling) 743 769 { 744 mChildren[i] = mChildren[$ - 1]; 745 mChildren.length = mChildren.length - 1; 746 return; 770 if(c.mSibling is n) 771 { 772 c.mSibling = n.mSibling; 773 return; 774 } 747 775 } 748 776 } … … 755 783 mMatDirty = true; 756 784 757 for each(Node n; mChildren)785 for(auto n = mChild; n !is null; n = n.mSibling) 758 786 n.matNeedsUpdate(); 759 787 } … … 764 792 updateMatrixSolo(); 765 793 766 for each(Node n; mChildren)794 for(auto n = mChild; n !is null; n = n.mSibling) 767 795 n.updateMatrix(); 768 796 } trunk/test.d
r32 r33 8 8 9 9 import nonagon.node; 10 11 import derelict.openal.al; 12 13 char[][] fromStringsz(char* s) 14 { 15 char[][] ret; 16 17 while(*s != '\0') 18 { 19 ret ~= fromStringz(s); 20 s += ret[$ - 1].length + 1; 21 } 22 23 return ret; 24 } 10 25 11 26 void main() … … 22 37 }; 23 38 39 DerelictAL.load(); 40 auto device = alcOpenDevice(null); // open default device 41 auto context = alcCreateContext(device, null); // create context 42 alcMakeContextCurrent(context); // set active context 43 44 Stdout.formatln("ALC:"); 45 Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER))); 46 Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_DEVICE_SPECIFIER))); 47 Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_EXTENSIONS))); 48 Stdout.formatln("{}", fromStringsz(alcGetString(null, ALC_DEVICE_SPECIFIER))); 49 // Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER))); 50 // Stdout.formatln("{}", fromStringz(alcGetString(device, ALC_CAPTURE_DEVICE_SPECIFIER))); 51 52 Stdout.formatln("\nAL:"); 53 Stdout.formatln("{}", fromStringz(alGetString(AL_VERSION))); 54 Stdout.formatln("{}", fromStringz(alGetString(AL_RENDERER))); 55 Stdout.formatln("{}", fromStringz(alGetString(AL_VENDOR))); 56 Stdout.formatln("{}", fromStringz(alGetString(AL_EXTENSIONS))); 57 24 58 while(!quit) 25 59 Window.update(); 60 61 alcDestroyContext(context); 62 alcCloseDevice(device); 26 63 } 64 65 import tango.stdc.stringz;
