[win32] VR double buffering ?
-
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 -
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] = trianglesbluatigro 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
-
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 -
And you think we can guess what all that code is supposed to do, and what it isn't doing right?
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 ?
-
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 ?
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
, notWS_POPUP
. Google for "set Window full screen". -
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 ?
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
-
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
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