 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
afatdog Guest
|
Posted: Mon Dec 18, 2006 9:10 am Post subject: Question about macro "sqrtf" (DriectX9) |
|
|
I want to use DriectX9 to capture the screen to a file, and the code is
here:
#include "d3d9.h"
#include "d3dx9tex.h"
IDirect3DDevice9* __fastcall CreateNULLRefDevice()
{
HRESULT hr;
IDirect3D9* pD3D = Direct3DCreate9( D3D_SDK_VERSION );
if( NULL == pD3D )
return NULL;
D3DDISPLAYMODE Mode;
pD3D->GetAdapterDisplayMode(0, &Mode);
D3DPRESENT_PARAMETERS pp;
ZeroMemory( &pp, sizeof(D3DPRESENT_PARAMETERS) );
pp.BackBufferWidth = 1;
pp.BackBufferHeight = 1;
pp.BackBufferFormat = Mode.Format;
pp.BackBufferCount = 1;
pp.SwapEffect = D3DSWAPEFFECT_COPY;
pp.Windowed = TRUE;
IDirect3DDevice9* pd3dDevice;
hr = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF,
GetDesktopWindow(),
D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp,
&pd3dDevice );
SAFE_RELEASE( pD3D );
if( FAILED(hr) || pd3dDevice == NULL )
return NULL;
return pd3dDevice;
}
void __fastcall TForm_xxxx::Button3Click(TObject *Sender)
{
IDirect3DSurface9* pSurface;
IDirect3DDevice9* g_pd3dDevice;
IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
g_pd3dDevice=CreateNULLRefDevice();
g_pd3dDevice->CreateOffscreenPlainSurface(1024, 768, D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM, &pSurface, NULL);
g_pd3dDevice->GetFrontBufferData(0, pSurface);
D3DXSaveSurfaceToFile("Desktop.bmp", D3DXIFF_BMP, pSurface, NULL, NULL);
pSurface->Release();
}
Question:
BCB5 return some errors:
[C++ Error] d3dx9math.inl(1578): E2268 Call to undefined function 'sqrtf'
[C++ Error] d3dx9math.inl(1710): E2268 Call to undefined function 'sqrtf'
[C++ Error] d3dx9math.inl(1855): E2268 Call to undefined function 'sqrtf'
[C++ Error] d3dx9math.inl(2025): E2268 Call to undefined function 'sqrtf'
I can find the macro "sqrtf" in VC6's VC6\Include\MATH.h, but not in
$(BCB)\Include\math.h
How to resolve this?
Thanks! |
|
| Back to top |
|
 |
afatdog Guest
|
Posted: Mon Dec 18, 2006 3:34 pm Post subject: Re: Question about macro "sqrtf" (DriectX9) |
|
|
I fixed that problem. Add two lines (copy the defination of "sqrtf" from
VC6\Include\MATH.h):
double __cdecl sqrt(double);
inline float sqrtf(float _X) {return ((float)sqrt((double)_X)); }
And it work. Is this the right way? |
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Mon Dec 18, 2006 9:04 pm Post subject: Re: Question about macro "sqrtf" (DriectX9) |
|
|
afatdog wrote:
| Quote: | And it work. Is this the right way?
|
It is one way, the other is to go into the Project Options -> Conditional
Defines, and enter sqrtf=sqrt; IIRC.
Jonathan |
|
| Back to top |
|
 |
Bruce Salzman Guest
|
Posted: Mon Dec 18, 2006 9:48 pm Post subject: Re: Question about macro "sqrtf" (DriectX9) |
|
|
"afatdog" <afatdog.hn (AT) yeah (DOT) net> wrote in message
news:4586628c (AT) newsgroups (DOT) borland.com...
| Quote: | I fixed that problem. Add two lines (copy the defination of "sqrtf"
from VC6\Include\MATH.h):
double __cdecl sqrt(double);
inline float sqrtf(float _X) {return ((float)sqrt((double)_X)); }
And it work. Is this the right way?
|
There is really no need to cast the result of sqrt() to a float. The
compiler will do that implicitly if you assign a double to a float.
--
Bruce |
|
| Back to top |
|
 |
afatdog Guest
|
Posted: Tue Dec 19, 2006 9:10 am Post subject: Re: Question about macro "sqrtf" (DriectX9) |
|
|
Thank you for your advice.
Other questions:
1. Is this the fastest way(DirectX) to get the screen shot? I only want to
read the screen in memory, not always need to save as a file.
2. How to get a specify windows scrren shot? Not the entire screen. Just
like ALT+PrintScreen.
3. If a window was minimized or hidden by another window, can I get the
screen shot all the same?
Thanks you ^_^ |
|
| Back to top |
|
 |
Michel Leunen Guest
|
Posted: Wed Dec 20, 2006 1:13 am Post subject: Re: Question about macro "sqrtf" (DriectX9) |
|
|
afatdog wrote:
| Quote: | Other questions:
1. Is this the fastest way(DirectX) to get the screen shot? I only want to
read the screen in memory, not always need to save as a file.
2. How to get a specify windows scrren shot? Not the entire screen. Just
like ALT+PrintScreen.
3. If a window was minimized or hidden by another window, can I get the
screen shot all the same?
|
Please, those questions were addressed many times before. Do a search on
google.
Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, BCC5.5.1 Web site:
http://www.leunen.com/
---------------------------------------- |
|
| Back to top |
|
 |
kutlu darılmaz Guest
|
Posted: Tue Apr 03, 2007 6:59 pm Post subject: opengl glut.h |
|
|
Where can I find glut.h for C++Builder 6?
Thanks. |
|
| Back to top |
|
 |
JF Jolin Guest
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|