コード例 #1
0
DLLEXPORT double MADX9_VertexBufferCreate(double length, double usage, double pool)
{
	try
	{
		return putInto(new VertexBuffer((uint) length, (uint) usage, (D3DPOOL) (uint) pool), mamain->VertexBuffers);
	}
	catch (std::exception)
	{
		return -1;
	}
}
コード例 #2
0
DLLEXPORT double MADX9_SurfaceCreateRenderTarget(double width, double height, double format, double ms, double msquality, double lockable)
{
	Surface* surf = new Surface();

	if (!surf->createRenderTarget((uint) width, (uint) height, (D3DFORMAT) (uint) format, (D3DMULTISAMPLE_TYPE) (uint) ms, (uint) msquality, lockable ? 1 : 0))
	{
		delete surf;
		return -1;
	}

	return putInto(surf, mamain->Surfaces);
}
コード例 #3
0
DLLEXPORT double MADX9_SurfaceCreateDepthStencil(double width, double height, double format, double ms, double msquality, double discard)
{
	Surface* surf = new Surface();

	if (!surf->createDepthStencil((uint) width, (uint) height, (D3DFORMAT) (uint) format, (D3DMULTISAMPLE_TYPE) (uint) ms, (uint) msquality, discard ? 1 : 0))
	{
		delete surf;
		return -1;
	}

	return putInto(surf, mamain->Surfaces);
}
コード例 #4
0
DLLEXPORT double MADX9_SurfaceCreateFromPointer(double ptr)
{
	Surface* surf = new Surface();

	if (!surf->createFromPointer(*(LPDIRECT3DSURFACE9*) &ptr))
	{
		delete surf;
		return -1;
	}

	return putInto(surf, mamain->Surfaces);
}
コード例 #5
0
ファイル: SymbolTable.c プロジェクト: tstellanova/samizdat
/**
 * Mutates an instance, putting a mapping into it, possibly reallocating it
 * (hence the pointer arguments). As a minor convenience, this function
 * returns early (doing nothing) if given `NULL` for `elem.key`.
 */
static void putInto(zvalue *result, SymbolTableInfo **info, zmapping elem) {
    if (elem.key == NULL) {
        return;
    }

    zint arraySize = (*info)->arraySize;
    zmapping *array = (*info)->array;
    zint index = symbolIndex(elem.key) % arraySize;

    for (int i = 0; i < DAT_SYMTAB_MAX_PROBES; i++) {
        zvalue foundKey = array[index].key;
        if (foundKey == NULL) {
            array[index] = elem;
            (*info)->size++;
            return;
        } else if (foundKey == elem.key) {
            // Update a pre-existing mapping for the key.
            array[index].value = elem.value;
            return;
        }

        index = (index + 1) % arraySize;
    }

    // Too many collisions! Reallocate, and then add the originally-requested
    // pair.

    zvalue newResult = allocInstance(arraySize);  // This grows `array`.
    SymbolTableInfo *newInfo = getInfo(newResult);

    for (int i = 0; i < arraySize; i++) {
        putInto(&newResult, &newInfo, array[i]);
    }

    putInto(&newResult, &newInfo, elem);

    *result = newResult;
    *info = newInfo;
}
コード例 #6
0
DLLEXPORT double MADX9_VertexBufferLock(double ind, double offset, double size, double flags)
{
	if (!isValidIndex((uint) ind, mamain->VertexBuffers))
		return 0;

	try
	{
		return putInto(new Buffer(mamain->VertexBuffers[(uint) ind]->createMemoryInterface((uint) offset, (uint) size, (uint) flags)), mamain->Buffers);
	}
	catch (std::exception)
	{
		return -1;
	}
}
コード例 #7
0
ファイル: SymbolTable.c プロジェクト: tstellanova/samizdat
// Documented in header.
zvalue symtabCatZassoc(zvalue symtab, zassoc ass) {
    assertHasClass(symtab, CLS_SymbolTable);

    if (ass.size == 0) {
        return symtab;
    }

    zvalue result = allocClone(symtab);
    SymbolTableInfo *info = getInfo(result);

    for (zint i = 0; i < ass.size; i++) {
        putInto(&result, &info, ass.elems[i]);
    }
    return result;
}
コード例 #8
0
DLLEXPORT double MADX9_SurfaceCreateFromTexture(double tex, double level)
{
	if (!isValidIndex((uint) tex, mamain->Textures))
		return -1;
	
	Surface* surf = new Surface();

	if (!mamain->Textures[(uint) tex]->getSurface((uint) level, *surf))
	{
		delete surf;
		return -1;
	}

	return putInto(surf, mamain->Surfaces);
}
コード例 #9
0
ファイル: SymbolTable.c プロジェクト: tstellanova/samizdat
// Documented in header.
zvalue symtabFromZassoc(zassoc ass) {
    if (DAT_CONSTRUCTION_PARANOIA) {
        for (zint i = 0; i < ass.size; i++) {
            assertValid(ass.elems[i].key);
            assertValid(ass.elems[i].value);
        }
    }

    if (ass.size == 0) {
        return EMPTY_SYMBOL_TABLE;
    }

    zvalue result = allocInstance(ass.size);
    SymbolTableInfo *info = getInfo(result);

    for (zint i = 0; i < ass.size; i++) {
        putInto(&result, &info, ass.elems[i]);
    }

    return result;
}
コード例 #10
0
ファイル: SymbolTable.c プロジェクト: tstellanova/samizdat
// Documented in header.
zvalue symtabFromZarray(zarray arr) {
    if (DAT_CONSTRUCTION_PARANOIA) {
        for (zint i = 0; i < arr.size; i++) {
            assertValid(arr.elems[i]);
        }
    }

    if (arr.size == 0) {
        return EMPTY_SYMBOL_TABLE;
    } else if ((arr.size & 1) != 0) {
        die("Odd argument count for symbol table construction.");
    }

    zvalue result = allocInstance(arr.size >> 1);
    SymbolTableInfo *info = getInfo(result);

    for (zint i = 0; i < arr.size; i += 2) {
        putInto(&result, &info, (zmapping) {arr.elems[i], arr.elems[i + 1]});
    }

    return result;
}
コード例 #11
0
DLLEXPORT double MADX9_MaterialCreate()
{
	return putInto((D3DMATERIAL9*) memset(new D3DMATERIAL9, 0, sizeof(D3DMATERIAL9)), mamain->Material);
}
コード例 #12
0
ファイル: Test.cpp プロジェクト: MattPD/Prog3
void makeSackFromInitializerList(){
	auto asack=makeSack({1,2,3,4});
	asack.putInto(5);
	ASSERT_EQUAL(5,asack.size());
}
コード例 #13
0
ファイル: MA_Buffer.cpp プロジェクト: gitter-badger/MA-Engine
DLLEXPORT double MADX9_BufferCreate()
{
	return putInto(new Buffer(new DynamicMemory()), mamain->Buffers);
}