Пример #1
0
ErrorCode Surface::createFromPointer(LPDIRECT3DSURFACE9 surf)
{
    if (this->surf != 0)
    {
        this->surf->Release();
        this->surf = 0;
    }

    if (surf == 0)
        return ErrorHandle(mamain->err, ErrorInv);

    D3DSURFACE_DESC desc;

    HRESULT res = surf->GetDesc(&desc);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "GetDesc");

    surfUsage  = desc.Usage;
    surfPool   = desc.Pool;
    surfWidth  = desc.Width;
    surfHeight = desc.Height;

    this->surf = surf;
    surf->AddRef();

    return ErrorOk;
}
Пример #2
0
ErrorCode Texture::setMipMapFilter(D3DTEXTUREFILTERTYPE filter)
{
    if ((flags & FlagMipMaps) == 0)
        return ErrorHandle(mamain->err, ErrorInv);

    HRESULT res = tex->SetAutoGenFilterType(filter);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetAutoGenFilterType");

    return ErrorOk;
}
Пример #3
0
DLLEXPORT double MADX9_SetRenderState(double state, double value)
{
	uint v;

	switch ((D3DRENDERSTATETYPE)(uint)state)
	{
	case D3DRS_FOGSTART:
	case D3DRS_FOGEND:
	case D3DRS_FOGDENSITY:
	case D3DRS_POINTSIZE:
	case D3DRS_POINTSIZE_MIN:
	case D3DRS_POINTSCALE_A:
	case D3DRS_POINTSCALE_B:
	case D3DRS_POINTSCALE_C:
	case D3DRS_PATCHEDGESTYLE:
	case D3DRS_POINTSIZE_MAX:
	case D3DRS_TWEENFACTOR:
	case D3DRS_DEPTHBIAS:
		*(float*)&v = (float)value;
		break;
	default:
		v = (uint)value;
		break;
	}

	HRESULT res = mamain->d3ddev->SetRenderState((D3DRENDERSTATETYPE) (uint) state, v);

	if (FAILED(res))
		return ErrorHandle(mamain->err, ErrorD3D9, res, "SetSamplerState");

	return ErrorOk;
}
OracleConnection::ObjectType OracleConnection::DescribeObjectByName(const String &command, DscHandleType &aDschp, OCIParam *&parmh)
{
	StartTrace(OracleConnection.DescribeObjectByName);
	text const *objptr = reinterpret_cast<const text *> ( (const char *) command );
	String strErr( "DescribeObjectByName: " );
	sword attrStat = OCIDescribeAny( SvcHandle(), ErrorHandle(), (dvoid *) objptr, (ub4) strlen( (char *) objptr ),
									 OCI_OTYPE_NAME, 0, OCI_PTYPE_UNK, aDschp.getHandle() );
	Trace("status after DESCRIBEANY::OCI_PTYPE_UNK: " << (long)attrStat)
	if ( checkError( attrStat, strErr ) ) {
		strErr << "{" << command << " is neither a stored procedure nor a function}";
		throw OracleException( *this, strErr );
	}

	Trace("get the parameter handle")
	attrStat = OCIAttrGet( aDschp.getHandle(), OCI_HTYPE_DESCRIBE, (dvoid *) &parmh, 0, OCI_ATTR_PARAM, ErrorHandle() );
	Trace("status after OCI_HTYPE_DESCRIBE::OCI_ATTR_PARAM: " << (long)attrStat);
	if ( checkError( attrStat ) ) {
		throw OracleException( *this, attrStat );
	}

	ObjectType aStmtType( TYPE_UNK );
	ub1 ubFuncType( 0 );
	attrStat = OCIAttrGet( parmh, OCI_DTYPE_PARAM, (dvoid *) &ubFuncType, 0, OCI_ATTR_PTYPE, ErrorHandle() );
	Trace("status after OCI_DTYPE_PARAM::OCI_ATTR_PTYPE: " << (long)attrStat << " funcType:" << (long)ubFuncType);
	if ( checkError( attrStat ) ) {
		throw OracleException( *this, attrStat );
	}
	aStmtType = (ObjectType)ubFuncType;
	return aStmtType;
}
Пример #5
0
ErrorCode Surface::update(Surface& surf)
{
    if (surfPool == D3DPOOL_DEFAULT && surf.surfPool == D3DPOOL_DEFAULT)
        return ErrorHandle(mamain->err, ErrorInv);

    HRESULT res;

    if (surfPool == D3DPOOL_DEFAULT)
        res = mamain->d3ddev->UpdateSurface(surf.surf, 0, this->surf, 0);
    else
        res = mamain->d3ddev->GetRenderTargetData(surf.surf, this->surf);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetDepthStencilSurface");

    return ErrorOk;
}
Пример #6
0
DLLEXPORT double MADX9_SetSamplerState(double stage, double type, double value)
{
	HRESULT res = mamain->d3ddev->SetSamplerState((uint) stage, (D3DSAMPLERSTATETYPE) (uint) type, (uint) value);

	if (FAILED(res))
		return ErrorHandle(mamain->err, ErrorD3D9, res, "SetSamplerState");

	return ErrorOk;
}
Пример #7
0
ErrorCode Texture::update(Texture& src)
{
    HRESULT res = mamain->d3ddev->UpdateTexture(src.tex, tex);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "UpdateTexture");

    return ErrorOk;
}
Пример #8
0
ErrorCode Texture::generateMipMaps()
{
    if ((flags & FlagMipMaps) == 0)
        return ErrorHandle(mamain->err, ErrorInv);

    tex->GenerateMipSubLevels();

    return ErrorOk;
}
Пример #9
0
ErrorCode Surface::resetDepthBuffer()
{
    if (DepthBuffers.empty())
        return ErrorHandle(mamain->err, ErrorInv);

    LPDIRECT3DSURFACE9 surf = DepthBuffers.top();

    DepthBuffers.pop();

    surf->Release();

    HRESULT res = mamain->d3ddev->SetDepthStencilSurface(surf);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetDepthStencilSurface");

    return ErrorOk;
}
Пример #10
0
KUSB_EXP HANDLE KUSB_API OvlK_GetEventHandle(
    _in KOVL_HANDLE OverlappedK)
{
	PKOVL_HANDLE_INTERNAL overlapped;
	Pub_To_Priv_OvlK(OverlappedK, overlapped, return NULL);
	ErrorHandle(!overlapped, Error, "OverlappedK");

	return overlapped->Overlapped.hEvent;
Error:
	return FALSE;
}
Пример #11
0
DLLEXPORT double MADX9_FreePointer(double p)
{
	LPUNKNOWN ptr = (LPUNKNOWN) DoubleToPtr(p);

	if (ptr == 0)
		return ErrorHandle(mamain->err, ErrorInv);

	ptr->Release();

	return ErrorOk;
}
Пример #12
0
ErrorCode Surface::resetRenderTarget(uint level)
{
    if (level > MaxRenderTargets || RenderTargets[level].empty())
        return ErrorHandle(mamain->err, ErrorInv);

    LPDIRECT3DSURFACE9 surf = RenderTargets[level].top();

    RenderTargets[level].pop();

    surf->Release();

    HRESULT res = mamain->d3ddev->SetRenderTarget(level, surf);

    mamain->d3ddev->SetViewport(&Viewports[level].top());
    Viewports[level].pop();

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetRenderTarget");

    return ErrorOk;
}
Пример #13
0
ErrorCode Surface::setDepthBuffer()
{
    if ((surfUsage & D3DUSAGE_DEPTHSTENCIL) == 0)
        return ErrorHandle(mamain->err, ErrorInv);

    LPDIRECT3DSURFACE9 surf;

    HRESULT res = mamain->d3ddev->GetDepthStencilSurface(&surf);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "GetDepthStencilSurface");

    DepthBuffers.push(surf);

    res = mamain->d3ddev->SetDepthStencilSurface(this->surf);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetDepthStencilSurface");

    return ErrorOk;
}
Пример #14
0
ErrorCode Surface::setRenderTarget(uint level)
{
    if ((surfUsage & D3DUSAGE_RENDERTARGET) == 0 || level > MaxRenderTargets)
        return ErrorHandle(mamain->err, ErrorInv);

    LPDIRECT3DSURFACE9 surf;

    HRESULT res = mamain->d3ddev->GetRenderTarget(level, &surf);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "GetRenderTarget");

    D3DVIEWPORT9 vp;

    mamain->d3ddev->GetViewport(&vp);

    Viewports[level].push(vp);

    RenderTargets[level].push(surf);

    vp.X      = 0;
    vp.Y      = 0;
    vp.Width  = surfWidth;
    vp.Height = surfHeight;
    vp.MinZ   = 0;
    vp.MaxZ   = 1;

    res = mamain->d3ddev->SetRenderTarget(level, this->surf);

    mamain->d3ddev->SetViewport(&vp);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "SetRenderTarget");

    return ErrorOk;
}
Пример #15
0
ErrorCode Texture::getSurface(uint level, Surface& surf)
{
    if (level >= tex->GetLevelCount())
        return ErrorHandle(mamain->err, ErrorInv);

    LPDIRECT3DSURFACE9 s;

    HRESULT res = tex->GetSurfaceLevel(level, &s);

    if (FAILED(res))
        return ErrorHandleCritical(mamain->err, mamain->errCrit, ErrorD3D9, res, "GetSurfaceLevel");

    ErrorCode ret = surf.createFromPointer(s);

    s->Release();

    return ret;
}
Пример #16
0
ErrorCode Surface::createRenderTarget(uint width, uint height, D3DFORMAT format, D3DMULTISAMPLE_TYPE ms, uint msquality, bool lockable)
{
    if (surf != 0)
    {
        surf->Release();
        surf = 0;
    }

    HRESULT res = mamain->d3ddev->CreateRenderTarget(width, height, format, ms, msquality, lockable, &surf, 0);

    if (FAILED(res))
        return ErrorHandle(mamain->err, ErrorD3D9, res, "CreateRenderTarget");

    surfUsage  = D3DUSAGE_RENDERTARGET;
    surfPool   = D3DPOOL_DEFAULT;
    surfWidth  = width;
    surfHeight = height;

    return ErrorOk;
}
Пример #17
0
int main(int argc, char *argv[])
{
	LinearFileReader k;

	// function prototype
	void ErrorHandle(string err);

	if(argc <= 1)  // no commandline arguments
	{
		// prompt for file
		string input = "";
		cout<<"Enter a filename: ";
		cin>>input;

		// now open the file
		try  {
			k.LoadFile(input);
		}
		catch(string e) { ErrorHandle(e); }
	}
Пример #18
0
logical Error :: GetDecision (void *error_source )
{
  static      RessourceLock   res_lock(NO);
  int32       loc_err = CheckError();
  logical     term = NO;
BEGINSEQ
  res_lock.ILock();

//  if ( !error || error >= 1000 )                     LEAVESEQ 18.8.99
  SetupErrText(error_source);
  
  if ( error_handle )
    term = error_handle->GetDecision(this);
  else
    ErrorHandle().GetDecision(this);
  

ENDSEQ
  ResetAllErrors();
  res_lock.IUnlock();
  return(term);
}
Пример #19
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow){
	WNDCLASSEX wndClass;
	
	MSG msg;
	//Регистрация оконного класса
	wndClass.cbSize = sizeof(wndClass);
	wndClass.style = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc = WndProc;
	wndClass.cbClsExtra = 0;
	wndClass.cbWndExtra = 0;
	wndClass.hInstance = hInst;
	wndClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = GetStockBrush(BLACK_BRUSH);
	wndClass.lpszMenuName = NULL;
	wndClass.lpszClassName = ClassName;
	wndClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

	RegisterClassEx(&wndClass);

	//Создание окна на основе класса
	hWnd = CreateWindowEx(
		0,  //Дополнит. стиль окна
		ClassName,	//Класс окна
		AppName,	//Текст заголовка
		WS_OVERLAPPEDWINDOW,	//Стиль окна
		50, 50,		//Координаты X и Y
		GetSystemMetrics(SM_CXSCREEN) / 2,
		GetSystemMetrics(SM_CYSCREEN) / 2,//Ширина и высота
		NULL,		//Дескриптор родит. окна
		NULL,		//Дескриптор меню
		hInst,		//Описатель экземпляра
		NULL);		//Доп. данные

	button = CreateWindow(
		"button", "Начать отправку", WS_VISIBLE | WS_CHILD, 500, 75, 180, 30, hWnd, NULL, NULL, NULL
		);
	button2 = CreateWindow(
		"button", "Остановить отправку", WS_VISIBLE | WS_CHILD, 500, 150, 180, 30, hWnd, NULL, NULL, NULL
		);
	EnableWindow(button2, 0);
	hEdit = CreateWindow("EDIT", "Введите IP", WS_CHILD | WS_VISIBLE, 40, 50, 200, 20, hWnd, NULL, hInst, NULL);

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	//Инициализация WinSock
	WSADATA ws;
	if (WSAStartup(MAKEWORD(2, 2), &ws)){
		ErrorHandle(hWnd);
	}

	//Инициализация сокета
	
	Client = socket(AF_INET, SOCK_DGRAM, 0);

	//задаем структуру
	//связь с сервером
	HOSTENT *hst;
	sockaddr_in dest_addr;

	dest_addr.sin_family = AF_INET;
	dest_addr.sin_port = htons(PORT);

	//Определение IP-адреса узла
	if (inet_addr(SERVERADDR))
		dest_addr.sin_addr.s_addr = inet_addr(SERVERADDR);
	else
	if (hst = (HOSTENT*)gethostbyname(SERVERADDR))
		dest_addr.sin_addr.s_addr = ((unsigned long**)hst->h_addr_list)[0][0];
	else{
		ErrorHandle(hWnd);
	}

	connect(Client, (sockaddr*)&dest_addr, sizeof(dest_addr));

	//LPWAVEFORMATEX Format;
	WAVEFORMATEX Format;
	/* высокое качество
	Format.nChannels = 1;
	Format.wFormatTag = WAVE_FORMAT_PCM;
	Format.nSamplesPerSec = 22050;
	Format.wBitsPerSample = 16;
	Format.nBlockAlign = 2;
	Format.cbSize = 0;
	Format.nAvgBytesPerSec = 44100;
	bufsize = 2*N;*/
	Format.nChannels = 1;
	Format.wFormatTag = WAVE_FORMAT_PCM;
	Format.nSamplesPerSec = 8000;
	Format.wBitsPerSample = 8;
	Format.nBlockAlign = 1;
	Format.cbSize = 0;
	Format.nAvgBytesPerSec = 8000;
	bufsize = (Format.nAvgBytesPerSec * 2) / 16;	
	
	waveInOpen(&waveIn, WAVE_MAPPER, &Format, (DWORD)OnWave, 0, CALLBACK_FUNCTION);

	waveHdr.lpData = PCHAR(GlobalAlloc(GMEM_FIXED, bufsize));
	waveHdr.dwBufferLength = bufsize;
	waveHdr.dwFlags = 0;

	//waveInClose(waveIn);
	//closesocket(Client);
	//WSACleanup();

	//Цикл обработки сообщений
	while (GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return (msg.wParam);

}
OracleConnection::ObjectType OracleConnection::ReadSPDescriptionFromDB( const String &command, Anything &desc )
{
	StartTrace(OracleConnection.ReadSPDescriptionFromDB);

	String strErr( "ReadSPDescriptionFromDB: " );

	MemChecker aCheckerLocal( "OracleConnection.ReadSPDescriptionFromDB", getEnvironment().getAllocator() );
	MemChecker aCheckerGlobal( "OracleConnection.ReadSPDescriptionFromDB", coast::storage::Global());

	sword attrStat;
	DscHandleType aDschp;
	if ( checkError( ( attrStat = OCIHandleAlloc( getEnvironment().EnvHandle(), aDschp.getVoidAddr(),
								  OCI_HTYPE_DESCRIBE, 0, 0 ) ) ) ) {
		throw OracleException( *this, attrStat );
	}
	Trace("after HandleAlloc, local allocator:" << reinterpret_cast<long>(getEnvironment().getAllocator()));
	Trace("after HandleAlloc, global allocator:" << reinterpret_cast<long>(coast::storage::Global()));

	OCIParam *parmh( 0 );
	ObjectType aStmtType = DescribeObjectByName(command, aDschp, parmh);
	if ( aStmtType == TYPE_SYN ) {
		Trace("as we identified a synonym, we need to collect the scheme name and the referenced object name to ask for description");
		text *name(0);
		ub4 namelen(0);
		String strSchemaName;
		attrStat = OCIAttrGet( (dvoid *) parmh, OCI_DTYPE_PARAM, (dvoid *) &name, (ub4 *) &namelen, OCI_ATTR_SCHEMA_NAME, ErrorHandle() );
		if ( checkError( ( attrStat ) ) ) {
			throw OracleException( *this, attrStat );
		}
		strSchemaName.Append(String( (char *) name, namelen ));
		Trace("SchemaName: " << strSchemaName);

		attrStat = OCIAttrGet( (dvoid *) parmh, OCI_DTYPE_PARAM, (dvoid *) &name, (ub4 *) &namelen, OCI_ATTR_NAME, ErrorHandle() );
		if ( checkError( ( attrStat ) ) ) {
			throw OracleException( *this, attrStat );
		}
		if ( strSchemaName.Length() ) {
			strSchemaName.Append('.');
		}
		strSchemaName.Append(String( (char *) name, namelen ));

		Trace("trying to get descriptions for " << strSchemaName);
		aStmtType = DescribeObjectByName(strSchemaName, aDschp, parmh);
	}
	bool bIsFunction = ( aStmtType == TYPE_FUNC );

	Trace("get the number of arguments and the arg list for stored " << (bIsFunction ? "function" : "procedure"))
	OCIParam *arglst( 0 );
	ub2 numargs = 0;
	if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) parmh, OCI_DTYPE_PARAM, (dvoid *) &arglst, (ub4 *) 0,
								  OCI_ATTR_LIST_ARGUMENTS, ErrorHandle() ) ) ) ) {
		throw OracleException( *this, attrStat );
	}
	if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) arglst, OCI_DTYPE_PARAM, (dvoid *) &numargs, (ub4 *) 0,
								  OCI_ATTR_NUM_PARAMS, ErrorHandle() ) ) ) ) {
		throw OracleException( *this, attrStat );
	}
	Trace(String("number of arguments: ") << numargs);

	OCIParam *arg( 0 );
	text *name;
	ub4 namelen;
	ub2 dtype;
	OCITypeParamMode iomode;
	ub4 data_len;

	// For a procedure, we begin with i = 1; for a function, we begin with i = 0.
	int start = 0;
	int end = numargs;
	if ( !bIsFunction ) {
		++start;
		++end;
	}

	for ( int i = start; i < end; ++i ) {
		if ( checkError( ( attrStat = OCIParamGet( (dvoid *) arglst, OCI_DTYPE_PARAM, ErrorHandle(), (dvoid **) &arg,
									  (ub4) i ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
		namelen = 0;
		name = 0;
		data_len = 0;

		if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) arg, OCI_DTYPE_PARAM, (dvoid *) &dtype, (ub4 *) 0,
									  OCI_ATTR_DATA_TYPE, ErrorHandle() ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
		Trace("Data type: " << dtype)

		if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) arg, OCI_DTYPE_PARAM, (dvoid *) &name, (ub4 *) &namelen,
									  OCI_ATTR_NAME, ErrorHandle() ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
		String strName( (char *) name, namelen );
		// the first param of a function is the return param
		if ( bIsFunction && i == start ) {
			strName = command;
			Trace("Name: " << strName)
		}

		// 0 = IN (OCI_TYPEPARAM_IN), 1 = OUT (OCI_TYPEPARAM_OUT), 2 = IN/OUT (OCI_TYPEPARAM_INOUT)
		if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) arg, OCI_DTYPE_PARAM, (dvoid *) &iomode, (ub4 *) 0,
									  OCI_ATTR_IOMODE, ErrorHandle() ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
		Trace("IO type: " << iomode)

		if ( checkError( ( attrStat = OCIAttrGet( (dvoid *) arg, OCI_DTYPE_PARAM, (dvoid *) &data_len, (ub4 *) 0,
									  OCI_ATTR_DATA_SIZE, ErrorHandle() ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
		Trace("Size: " << (int)data_len)

		Anything param( desc.GetAllocator() );
		param["Name"] = strName;
		param["Type"] = dtype;
		param["Length"] = (int) data_len;
		param["IoMode"] = iomode;
		param["Idx"] = (long) ( bIsFunction ? i + 1 : i );
		desc.Append( param );
		if ( checkError( ( attrStat = OCIDescriptorFree( arg, OCI_DTYPE_PARAM ) ) ) ) {
			throw OracleException( *this, attrStat );
		}
	}