Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [win32] VR double buffering ?

[win32] VR double buffering ?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bluatigro
    wrote on last edited by
    #1

    i m trying as coding exersise a verry simple VR system error : the picture isn't Always right

    // bluatigro 31 okt 2017
    // win triangle
    #if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
    #elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
    #endif

    #include
    #include
    #include
    #include
    int winx , winy ;
    class d3d
    {
    public :
    double x , y , z ;
    d3d()
    {
    x = 0.0 ;
    y = 0.0 ;
    z = 0.0 ;
    }
    d3d( double a , double b , double c )
    {
    x = a ;
    y = b ;
    z = c ;
    }
    } ;
    d3d operator + ( d3d a , d3d b )
    {
    return d3d( a.x+b.x,a.y+b.y,a.z+b.z) ;
    }
    d3d operator / ( d3d a , double b )
    {
    return d3d( a.x/b,a.y/b,a.z/b) ;
    }
    d3d pnt[256] ;
    void setpoint( int no ,
    double a ,
    double b ,
    double c )
    {
    pnt[ no ] = d3d(a,b,c) ;
    }
    class triangle
    {
    public :
    d3d punt[ 3 ] , mid ;
    COLORREF color ;
    triangle()
    {
    ;
    }
    triangle( d3d p1 , d3d p2 , d3d p3 ,
    COLORREF kl )
    {
    punt[ 0 ] = p1 ;
    punt[ 1 ] = p2 ;
    punt[ 2 ] = p3 ;
    mid = ( p1 + p2 + p3 ) / 3 ;
    color = kl ;
    }
    void show( HDC hdc )
    {
    POINT p[ 3 ] ;
    int i ;
    if ( mid.z > -900)
    {
    for ( i = 0 ; i < 3 ; i++ )
    {

        p\[i\].x=(LONG)(winx/2+punt\[i\].x/
                    (punt\[i\].z+1000.0)\*1000) ;
        p\[i\].y=(LONG)(winy/2-punt\[i\].y/
                    (punt\[i\].z+1000.0)\*1000) ;
      }
      HBRUSH brush = CreateSolidBrush( color ) ;
      HPEN pen = CreatePen( PS\_SOLID , 0 , color ) ;
      SelectObject( hdc , pen ) ;
      SelectObject( hdc , brush ) ;
    
      Polygon( hdc , p , 3 ) ;
    
      SelectObject( hdc , pen ) ;
      DeleteObject( pen ) ;
      SelectObject( hdc , brush ) ;
      DeleteObject( brush ) ;
    } // end if mid.z > -900
    

    }
    } ;
    const COLORREF red = RGB( 255 , 0 , 0 ) ;
    const COLORREF green = RGB( 0 , 255 , 0 ) ;
    const COLORREF yellow = RGB( 255 , 255 , 0 ) ;
    const COLORREF blue = RGB( 0 , 0 , 255 ) ;
    const COLORREF magenta = RGB( 255 , 0 , 255 ) ;
    const COLORREF cyan = RGB( 0 , 255 , 255 ) ;

    bool key[ 256 ] ;
    triangle triangles[100] ;
    int tritel ;
    #define FRAME_TIMER 1
    void show_al( HDC hdc )
    {
    int i , j ;
    triangle h ;
    for ( i = 1 ; i < tritel ; i++ )
    {
    for ( j = 0 ; j < i - 1 ; j++ )
    {
    if ( triangles[i].mid.z
    > triangles[j].mid.z )
    {
    h = triangles[i] ;
    triangles[i] = triangles

    D L 2 Replies Last reply
    0
    • B bluatigro

      i m trying as coding exersise a verry simple VR system error : the picture isn't Always right

      // bluatigro 31 okt 2017
      // win triangle
      #if defined(UNICODE) && !defined(_UNICODE)
      #define _UNICODE
      #elif defined(_UNICODE) && !defined(UNICODE)
      #define UNICODE
      #endif

      #include
      #include
      #include
      #include
      int winx , winy ;
      class d3d
      {
      public :
      double x , y , z ;
      d3d()
      {
      x = 0.0 ;
      y = 0.0 ;
      z = 0.0 ;
      }
      d3d( double a , double b , double c )
      {
      x = a ;
      y = b ;
      z = c ;
      }
      } ;
      d3d operator + ( d3d a , d3d b )
      {
      return d3d( a.x+b.x,a.y+b.y,a.z+b.z) ;
      }
      d3d operator / ( d3d a , double b )
      {
      return d3d( a.x/b,a.y/b,a.z/b) ;
      }
      d3d pnt[256] ;
      void setpoint( int no ,
      double a ,
      double b ,
      double c )
      {
      pnt[ no ] = d3d(a,b,c) ;
      }
      class triangle
      {
      public :
      d3d punt[ 3 ] , mid ;
      COLORREF color ;
      triangle()
      {
      ;
      }
      triangle( d3d p1 , d3d p2 , d3d p3 ,
      COLORREF kl )
      {
      punt[ 0 ] = p1 ;
      punt[ 1 ] = p2 ;
      punt[ 2 ] = p3 ;
      mid = ( p1 + p2 + p3 ) / 3 ;
      color = kl ;
      }
      void show( HDC hdc )
      {
      POINT p[ 3 ] ;
      int i ;
      if ( mid.z > -900)
      {
      for ( i = 0 ; i < 3 ; i++ )
      {

          p\[i\].x=(LONG)(winx/2+punt\[i\].x/
                      (punt\[i\].z+1000.0)\*1000) ;
          p\[i\].y=(LONG)(winy/2-punt\[i\].y/
                      (punt\[i\].z+1000.0)\*1000) ;
        }
        HBRUSH brush = CreateSolidBrush( color ) ;
        HPEN pen = CreatePen( PS\_SOLID , 0 , color ) ;
        SelectObject( hdc , pen ) ;
        SelectObject( hdc , brush ) ;
      
        Polygon( hdc , p , 3 ) ;
      
        SelectObject( hdc , pen ) ;
        DeleteObject( pen ) ;
        SelectObject( hdc , brush ) ;
        DeleteObject( brush ) ;
      } // end if mid.z > -900
      

      }
      } ;
      const COLORREF red = RGB( 255 , 0 , 0 ) ;
      const COLORREF green = RGB( 0 , 255 , 0 ) ;
      const COLORREF yellow = RGB( 255 , 255 , 0 ) ;
      const COLORREF blue = RGB( 0 , 0 , 255 ) ;
      const COLORREF magenta = RGB( 255 , 0 , 255 ) ;
      const COLORREF cyan = RGB( 0 , 255 , 255 ) ;

      bool key[ 256 ] ;
      triangle triangles[100] ;
      int tritel ;
      #define FRAME_TIMER 1
      void show_al( HDC hdc )
      {
      int i , j ;
      triangle h ;
      for ( i = 1 ; i < tritel ; i++ )
      {
      for ( j = 0 ; j < i - 1 ; j++ )
      {
      if ( triangles[i].mid.z
      > triangles[j].mid.z )
      {
      h = triangles[i] ;
      triangles[i] = triangles

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      bluatigro wrote:

      the picture isn't Always right

      And that means what exactly? :confused:

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • B bluatigro

        i m trying as coding exersise a verry simple VR system error : the picture isn't Always right

        // bluatigro 31 okt 2017
        // win triangle
        #if defined(UNICODE) && !defined(_UNICODE)
        #define _UNICODE
        #elif defined(_UNICODE) && !defined(UNICODE)
        #define UNICODE
        #endif

        #include
        #include
        #include
        #include
        int winx , winy ;
        class d3d
        {
        public :
        double x , y , z ;
        d3d()
        {
        x = 0.0 ;
        y = 0.0 ;
        z = 0.0 ;
        }
        d3d( double a , double b , double c )
        {
        x = a ;
        y = b ;
        z = c ;
        }
        } ;
        d3d operator + ( d3d a , d3d b )
        {
        return d3d( a.x+b.x,a.y+b.y,a.z+b.z) ;
        }
        d3d operator / ( d3d a , double b )
        {
        return d3d( a.x/b,a.y/b,a.z/b) ;
        }
        d3d pnt[256] ;
        void setpoint( int no ,
        double a ,
        double b ,
        double c )
        {
        pnt[ no ] = d3d(a,b,c) ;
        }
        class triangle
        {
        public :
        d3d punt[ 3 ] , mid ;
        COLORREF color ;
        triangle()
        {
        ;
        }
        triangle( d3d p1 , d3d p2 , d3d p3 ,
        COLORREF kl )
        {
        punt[ 0 ] = p1 ;
        punt[ 1 ] = p2 ;
        punt[ 2 ] = p3 ;
        mid = ( p1 + p2 + p3 ) / 3 ;
        color = kl ;
        }
        void show( HDC hdc )
        {
        POINT p[ 3 ] ;
        int i ;
        if ( mid.z > -900)
        {
        for ( i = 0 ; i < 3 ; i++ )
        {

            p\[i\].x=(LONG)(winx/2+punt\[i\].x/
                        (punt\[i\].z+1000.0)\*1000) ;
            p\[i\].y=(LONG)(winy/2-punt\[i\].y/
                        (punt\[i\].z+1000.0)\*1000) ;
          }
          HBRUSH brush = CreateSolidBrush( color ) ;
          HPEN pen = CreatePen( PS\_SOLID , 0 , color ) ;
          SelectObject( hdc , pen ) ;
          SelectObject( hdc , brush ) ;
        
          Polygon( hdc , p , 3 ) ;
        
          SelectObject( hdc , pen ) ;
          DeleteObject( pen ) ;
          SelectObject( hdc , brush ) ;
          DeleteObject( brush ) ;
        } // end if mid.z > -900
        

        }
        } ;
        const COLORREF red = RGB( 255 , 0 , 0 ) ;
        const COLORREF green = RGB( 0 , 255 , 0 ) ;
        const COLORREF yellow = RGB( 255 , 255 , 0 ) ;
        const COLORREF blue = RGB( 0 , 0 , 255 ) ;
        const COLORREF magenta = RGB( 255 , 0 , 255 ) ;
        const COLORREF cyan = RGB( 0 , 255 , 255 ) ;

        bool key[ 256 ] ;
        triangle triangles[100] ;
        int tritel ;
        #define FRAME_TIMER 1
        void show_al( HDC hdc )
        {
        int i , j ;
        triangle h ;
        for ( i = 1 ; i < tritel ; i++ )
        {
        for ( j = 0 ; j < i - 1 ; j++ )
        {
        if ( triangles[i].mid.z
        > triangles[j].mid.z )
        {
        h = triangles[i] ;
        triangles[i] = triangles

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        And you think we can guess what all that code is supposed to do, and what it isn't doing right?

        B 1 Reply Last reply
        0
        • L Lost User

          And you think we can guess what all that code is supposed to do, and what it isn't doing right?

          B Offline
          B Offline
          bluatigro
          wrote on last edited by
          #4

          the code shoot show a colored rotating cube i want to get rid of showing drawing it gives ugly effects i want double buffering i have no idea where / what i have to change in the code to that effect i got now : WS_POPUP | WS_MAXIMIZE how do i get fulscreen ?

          L D 2 Replies Last reply
          0
          • B bluatigro

            the code shoot show a colored rotating cube i want to get rid of showing drawing it gives ugly effects i want double buffering i have no idea where / what i have to change in the code to that effect i got now : WS_POPUP | WS_MAXIMIZE how do i get fulscreen ?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            bluatigro wrote:

            i have no idea where / what i have to change

            Well you cannot expect anyone here to understand all that code in a few minutes. You need to narrow down where the problem is and gather some more information about what is happening. Your Window style should be based on WS_OVERLAPPEDWINDOW, not WS_POPUP. Google for "set Window full screen".

            1 Reply Last reply
            0
            • B bluatigro

              the code shoot show a colored rotating cube i want to get rid of showing drawing it gives ugly effects i want double buffering i have no idea where / what i have to change in the code to that effect i got now : WS_POPUP | WS_MAXIMIZE how do i get fulscreen ?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              If you wrote the code to display the cube, then surely you can also remove it. If not, can you ask on the site where you procured the code from? Grabbing code from other sites, blindly throwing it into a compiler, and then wondering why it doesn't work hardly defines the software development process.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              B 1 Reply Last reply
              0
              • D David Crow

                If you wrote the code to display the cube, then surely you can also remove it. If not, can you ask on the site where you procured the code from? Grabbing code from other sites, blindly throwing it into a compiler, and then wondering why it doesn't work hardly defines the software development process.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                B Offline
                B Offline
                bluatigro
                wrote on last edited by
                #7

                i use the mdsn site + goolge for info yes its a lot of code i wrote it myself and i don't expect the error's to be fount fast the problem whit my code is that you see the drawing of the triangles over eatch other i think i have to change somthing in WM_PAINT but i m not sure

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups