+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: G3P - The GPU General Graphing Project

  1. #21
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,662
    Blog Entries
    1

    Default Re: G3P - The GPU General Graphing Project

    Oh dear:

    Last edited by Drunkie; 04-28-2010 at 03:47 PM.

  2. #22
    That furred thing Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    3,565

    Default Re: G3P - The GPU General Graphing Project

    Okay, put it after Render.Start then
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5

  3. #23
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,662
    Blog Entries
    1

    Default Re: G3P - The GPU General Graphing Project

    Quote Originally Posted by Black Phoenix View Post
    Okay, put it after Render.Start then
    Nah, I got it working another way, I just moved around some things.



    Here's the working code:

    Code:
    //==============================================================================
    // 3D graph drawer
    //==============================================================================
    
    //Must divide by each other, or else it'll fuck up big time
    define WIDTH,50;
    define TRIS_IN_FRAME,10;
    define HEIGHT,50;
    
    mov #regHWClear,0;
    mov EDX,HEIGHT; mul EDX,WIDTH; div EDX,TRIS_IN_FRAME;
    cmp #Frame,EDX; jge @DrawExit; jmp Render.Start;
    @DrawExit: dexit;
    
    Render.Start:
    cmp #Frame,0; jne Render.SkipInitialization;
      dclrscr cBackgroundColor;
      //Apply aspect ratio correction
      mov #vPerspective.Y,1.6;
      //Initialize perspective transform matrix
      mperspective mProjectionMatrix,vPerspective;
    
    Render.SkipInitialization:
      dcvxpipe 3; //Set -1..1 coordinate system
      dvxpipe  5; //Use matrix projection routine
      call ApplyTransform;
      dcolor cDefaultColor;
      mloadproj mProjectionMatrix;
      dsetlight 0,lSun;//vPerspective
    
      denable 0; //Vertex buffer
      denable 2; //Lighting
    
    
    
      mov EDX,WIDTH;
      div EDX,TRIS_IN_FRAME;
    
      //set coordinates
      mov EBX,#Frame; div EBX,EDX; fint EBX;
      mov EAX,#Frame; mod EAX,EDX; fint EAX; mul EAX,TRIS_IN_FRAME;
    
      //draw triangle stripe
      mov EDX,TRIS_IN_FRAME;
      @DrawLoop:
        call DrawTriangle;
        inc EAX;
        loopd @DrawLoop;
      dvxflush;
    
      inc #Frame;
    dexit;
    
    
      
    
    
    //= Apply transformations ======================================================
    ApplyTransform:
      //Compute look-at matrix (for camera)
      mlookat mViewMatrix,vLookAt;
    
      //Rotate & translate target model
      mrotate mRotateMatrix,vRotate;
      mtranslate mTranslateMatrix,vTranslate;
      mscale mScaleMatrix,vScale;
    
      //Create Model matrix
      mmov mModelMatrix,mRotateMatrix;
      mmul mModelMatrix,mTranslateMatrix;
      mmul mModelMatrix,mScaleMatrix;
    
      //Compute and load ModelView matrix
      mmov mModelViewMatrix,mViewMatrix;
      mmul mModelViewMatrix,mModelMatrix;
      mload mModelViewMatrix;
    ret
    
    //EAX: X, EBX: Y, Z -> ECX
    GenerateHeight:
      push eax; push ebx;
        add EAX,#vTranslate.X;
        add EBX,#vTranslate.Y;
    
        mul EAX,EAX;
        mul EBX,EBX;
        add EAX,EBX; mul EAX,0.5;
        fpwr EAX,0.5;
        add EAX,0.1;
    
        fsin ECX,EAX;
        div ECX,EAX;
        mul ECX,10;
    //    fsin EAX,EAX;
    //    fcos ECX,EBX;
    //    mul ECX,EAX;
    
        //Z = Sin(R) / R
      pop ebx; pop eax;
    ret
    
    DrawTriangle:
      mov EBP,VertexData;
    
      //Face 1
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
    
      inc EAX;
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
    
      inc EBX;
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
    
      //Face 2
      dec EBX; dec EAX;
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
    
      inc EBX; inc EAX;
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
    
      dec EAX;
      call GenerateHeight;
      mov #EBP,EAX; inc EBP;
      mov #EBP,EBX; inc EBP;
      mov #EBP,ECX; inc EBP;
      dec EBX;
    
      dvxdata_3f VertexData,2;
    ret
    
    //= Rendering settings and parameters ==========================================
    matrix mRotateMatrix;       matrix mTranslateMatrix;    matrix mScaleMatrix;
    matrix mProjectionMatrix;   matrix mViewMatrix;         matrix mModelMatrix;
    matrix mPRotateMatrix;      matrix mPTranslateMatrix;   matrix mModelViewMatrix;
    //------------------------------------------------------------------------------
    
    vector4f vRotate,         0,    0,    1,    0; //<AXIS X Y Z> <ANGLE W>
    vector4f vTranslate,     -25,  -25,    0,    0; //<TRANLSATION X Y Z> <0>
    vector4f vScale,          1,    1,    1,    0; //<SCALE X Y Z> <0>
    vector4f vPerspective,   30,  1.6,    1,   20; //<FOV> <ASPECT RATIO> <ZNEAR> <ZFAR>
    
    vLookAt: vector3f vLookAt_Eye,     20,  20,  30; //Where our camera is
             vector3f vLookAt_Center,   0,   0,   0; //What we look at
             vector3f vLookAt_Up,       0,   0,  -1; //Where our head points
    
    color cBackgroundColor,     0,   0,   0;
    color cDefaultColor,      255, 255, 255;
    
    alloc Frame;
    
    lSun: vector4f Sun.Pos, 100, 100, 100,   0; //x y z <unused, will be falloff>
          color    Sun.Col, 255, 255, 255, 0.5; //R G B Brightness
    //==============================================================================
    
    VertexData:
      db 0,0,0; //Face1
      db 0,0,0;
      db 0,0,0;
      db 0,0,0; //Face2
      db 0,0,0;
      db 0,0,0;

  4. #24
    That furred thing Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    3,565

    Default Re: G3P - The GPU General Graphing Project

    Yeah, it's a bug I just found, didn't get to fixing it yet (it doesn't set default texture for some reason). Or rather it sets default texture for no reason, it shouldn't
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5

  5. #25
    Ursus maritimus Drunkie's Avatar
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    5,662
    Blog Entries
    1

    Default Re: G3P - The GPU General Graphing Project

    You still working on this? Any progress?

  6. #26
    Master of Mars Magos Mechanicus's Avatar
    Join Date
    May 2008
    Posts
    852

    Default Re: G3P - The GPU General Graphing Project

    Sorry, it's basically been at a standstill for a while. Spring came and there was suddenly a lot more work to do around the house, and my GPU skills proved to be even worse than I remembered.
    I can wire anything directly into anything! I'm the Professor!
    -Professor Hubert Farnsworth

+ Reply to Thread
Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots