Example #1
0
void main()
{
	coreLoad(Window);
	coreLoad(Time);
	coreLoad(Input);
	coreLoad(Camera);
 	coreLoad(Factory);
	coreLoad(Asset);
	
	systemLoad(TransformUpdate);
	systemLoad(Rendering);
	
	initCore();



	// Safe to load assets and make dudes.
	core(Asset).loadShader("Flat","./shaders/simpleShader.vert", "./shaders/simpleShader.frag");
	
	Vertex verts[3] = { { {   0,  30, 0, 1 }, { 0, 1, 1, 1 } },
						{ { -30, -30, 0, 1 }, { 1, 1, 0, 1 } }, { {  30, -30, 0, 1 }, { 1, 0, 1, 1 } } };
	Triangle tris[1] = { 0, 1, 2 };

	core(Asset).loadMesh("Triangle", verts, 3, tris, 1);


	core(Factory).MakeTriangle();

	runGame();
}
Example #2
0
void
Meta::setElapsedTime(int time) {
    if (time < 0) {
        throw std::runtime_error("Incorrect elapsed time value");
    }
    initCore();
    meta_data_->core_->setElapsedTime(time);
}
Example #3
0
bool
CKLBUISimpleItem::initUI(CLuaState& lua)
{
	int argc = lua.numArgs();
    if(argc < ARG_REQUIRE || argc > ARG_NUMS) { return false; }

	float x = lua.getFloat(ARG_X);
	float y = lua.getFloat(ARG_Y);

	return initCore(lua.getInt(ARG_ORDER),x,y,lua.getString(ARG_ASSET));
} 
Example #4
0
JBlockerMainWindow::JBlockerMainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags), p_tabW(0), p_inboxW(0), p_junkListW(0), p_messageCore(0), p_messageBox(0), p_progressBar(0),
    p_refresh(0), p_addToBlackList(0), p_switchAccount(0)
{
    qDebug() << "+ " << __PRETTY_FUNCTION__;
    /* Initialization */
    initUI();
    initCore();
    initConnections();
    QTimer::singleShot(1000, this, SLOT(slt_loadingStart()));
}
Example #5
0
bool
CKLBUISimpleItem::init(CKLBUITask* pParent, CKLBNode* pNode, u32 order, float x, float y, const char* asset) 
{
    if(!setupNode()) { return false; }
	bool bResult = initCore(order,x,y,asset);
	bResult = registUI(pParent, bResult);
	if(pNode) {
		pParent->getNode()->removeNode(getNode());
		pNode->addNode(getNode());
	}
	return bResult;
}
Example #6
0
void
Meta::setTypedValue(const std::string &name, const TypedValue &value) {
    if (!allowKey(name)) {
        throw std::runtime_error(name + " key is not allowed");
    }
    if (meta_data_->core_writable_) {
        initCore();
        meta_data_->core_->insert(name, value);
    }
    else {
        meta_data_->child_.insert(name, value);
    }
}
Example #7
0
bool
CKLBUIScore::initUI(CLuaState& lua)
{
	int argc = lua.numArgs();

	// 引数の数が合わない場合
    if(argc < ARG_REQUIRE || argc > ARG_NUMS) { return false; }

	float   x            = lua.getFloat(ARG_X);
	float   y            = lua.getFloat(ARG_Y);
	u32     order        = lua.getInt(ARG_ORDER);
	s32     order_offset = lua.getInt(ARG_ODOFF);
	float   stepX        = lua.getFloat(ARG_STEP_X);
	float   stepY        = lua.getFloat(ARG_STEP_Y);
	int     column       = lua.getInt(ARG_COLS);
	bool    fillzero     = lua.getBool(ARG_FILLZERO);
	bool    anim_flag    = lua.getBool(ARG_ANIM);
	int     align        = (argc >= ARG_ALIGN)     ? lua.getInt(ARG_ALIGN)      : ALIGN_RIGHT;
	bool    countclip    = (argc >= ARG_COUNTCLIP) ? lua.getBool(ARG_COUNTCLIP) : false;

	const char * tex_list[10];
	lua.retValue(ARG_TEXTBL);	// 対象となる配列をスタックトップに積む
	lua.retNil();				// nil をスタックトップに積む
	int tex_cnt = 0;
	while(lua.tableNext()) {
		lua.retValue(-2);
		int idx = lua.getInt(-1) - 1;			// Lua配列の添え字は1からなので、-1する。
		const char * str = lua.getString(-1);

		// 与えられた配列のindexに整数以外が使われているときや、
		// 範囲を超えたものがある場合はエラー扱いとする。
		klb_assert((idx >= 0 && idx <= 9), "BAD INDEX [%s] in texture array.", str);
		if(idx < 0 || idx > 9) {	// 数値以外のインデックスが指定されていたり、範囲を超えている場合
			return false;
		}
		const char * texname = lua.getString(-2);	// テクスチャ名称が格納されている。
		tex_list[idx] = texname;
		tex_cnt++;
		lua.pop(2);
	}
	lua.pop(1);
	// テクスチャの数が足りなければエラーとする。
	if(tex_cnt != 10) {
		klb_assert(tex_cnt == 10, "%s(%d): The number of textures is insufficient. ", lua.getScriptName(), lua.getNumLine()); 
		return false;
	}

	return initCore(order, order_offset, x, y, tex_list, stepX, stepY, column, fillzero, anim_flag, align, countclip);
}
Example #8
0
NewFilePage_4::NewFilePage_4(QWidget* parent) : QWidget(parent)
{
    titlePtr = new QLabel("<b>Name and location</b>");
    
    fileNameLePtr = new QLineEdit();
    fileNameLePtr->setText("newfile");
    fileExtsStrLstPtr = new QStringList();
    fileExtCbPtr = new QComboBox();
    defaultFileExtChbPtr = new QCheckBox();
    projectLePtr = new QLineEdit();
    locCbPtr = new QComboBox();
    //locCbPtr->addItems(new QStringList() )
    folderLePtr = new QLineEdit();
    folderDialogPtr = new QFileDialog();
    folderPbPtr = new QPushButton("Browse...");
    createdFileLePtr = new QLineEdit();
    
    fileNameStrPtr = new QString("NewFile");
    projectStrPtr = new QString("ProjectName");
    //locStrPtr = new QString(RosEnv::imagesInstallLoc + "rqt_ide/");
    locStrPtr = new QString(RosEnv::rideInstallLoc + "rqt_ide/ide");
    folderStrPtr = new QString(RosEnv::imagesInstallLoc + "NewFile.cpp");
    createdFileStrPtr = new QString("");
    
    folderLayoutPtr = new QGridLayout();
    folderLayoutPtr->addWidget(folderLePtr, 0, 0);
    folderLayoutPtr->addWidget(folderPbPtr, 0, 1);
    
    formLayoutPtr = new QFormLayout();
    formLayoutPtr->addRow(tr("File &Name:"), fileNameLePtr);
    formLayoutPtr->addRow(tr("&Extension:"), fileExtCbPtr);
    formLayoutPtr->addRow(tr(""), defaultFileExtChbPtr);
    formLayoutPtr->addRow(tr("&Project:"), projectLePtr);
    formLayoutPtr->addRow(tr("Loca&tion"), locCbPtr);
    formLayoutPtr->addRow(tr("Folder"), folderLayoutPtr);
    formLayoutPtr->addRow(tr("&Created File:"), createdFileLePtr);
    
    initCore();
    
    outerLayoutPtr = new QGridLayout();
    outerLayoutPtr->addWidget(titlePtr, 0, 0, Qt::AlignHCenter);
    outerLayoutPtr->addLayout(formLayoutPtr, 1, 0);
    
    this->setLayout(outerLayoutPtr);
}
Example #9
0
bool CKLBUIMultiImgItem::init(CKLBUITask* pParent, CKLBNode* pNode, u32 order, float x, float y, u32 idx, const char** pArrayAsset, u32* pArrayIndexes, u32 assetCount) {
	if(!setupNode()) return false;

	//
	// Create array and load resources.
	//
	u32 max = 0;
	for(u32 i = 0; i < assetCount; i++) {
		u32 idxImg = pArrayIndexes[i];
        if(max < idxImg) { max = idxImg; }
	}
	
	max++;

	IMGITEM* items = KLBNEWA(IMGITEM, max);
	if(!items) { return false; }

	// Reset all handle to NULL
	for(u32 i=0; i < max; i++) {
		items[i].handle	= 0;
		items[i].sprite = NULL;
	}

	CKLBRenderingManager& rdr = CKLBRenderingManager::getInstance();
	for(u32 i = 0; i < assetCount; i++) {
		const char* name = pArrayAsset[i];
		u32 idxImg = pArrayIndexes[i];
		u32 handle;
		CKLBAsset * pAsset = CKLBUtility::loadAsset(name, &handle, NULL);
		if(pAsset->getAssetType() == ASSET_IMAGE) {
			CKLBSprite*	pRender	= rdr.allocateCommandSprite((CKLBImageAsset*)pAsset,order);

			items[idxImg].handle = handle;
			items[idxImg].sprite = pRender;
		}
	}

	bool bResult = initCore(order,x,y,idx,items,max);
	bResult = registUI(pParent, bResult);
	if(pNode) {
		pParent->getNode()->removeNode(getNode());
		pNode->addNode(getNode());
	}
	return bResult;
}
MasterGui::MasterGui(QWidget* parent) : QWidget(parent)
{
    this->setWindowIcon(QIcon("./src/Software_Engineer_91.411_2/2_DataAggregator/Code/kinect_app/app_node/share/se_logo.xpm") );
    this->setWindowTitle("Software Engineering I");
    
    AppStyles::loadStyle(this, AppStyles::CLASSIC);
    //AppStyles::loadStyle<int>(5);
    
    QDesktopWidget desktop;
    int desktopHeight = desktop.geometry().height();
    int desktopWidth = desktop.geometry().width();
    cout << "Desktop is: " << desktopHeight << " high and " << desktopWidth << " wide.";
    //this->resize(desktopWidth, desktopHeight);
    
    initCore();
    
    this->setLayout(outerLayout);
}
Example #11
0
bool
CKLBUIScore::init(CKLBUITask * pParent, CKLBNode * pNode,
                  u32 order, s32 order_offset, float x, float y, 
                  const char ** tex_table, float stepX, float stepY, int column, 
                  bool fillzero, bool anim_flag, u32 align, bool countclip)
{
    if(!setupNode()) { return false; }

	// ユーザ定義初期化を呼び、初期化に失敗したら終了。
	bool bResult = initCore(order, order_offset, x, y, tex_table, stepX, stepY, column, fillzero, anim_flag, align, countclip);

	// 初期化処理終了後の登録。失敗時の処理も適切に行う。
	bResult = registUI(pParent, bResult);
	if(pNode) {
		pParent->getNode()->removeNode(getNode());
		pNode->addNode(getNode());
	}

	return bResult;
}
Example #12
0
bool
CKLBUIMultiImgItem::initUI(CLuaState& lua)
{
	int argc = lua.numArgs();
	if(argc < ARG_REQUIRE || argc > ARG_NUMS) return false;

	float x     = lua.getFloat(ARG_X);
	float y     = lua.getFloat(ARG_Y);
	u32 order   = lua.getInt(ARG_ORDER);
	u32 idxImg  = (argc >= ARG_INDEX) ? lua.getInt(ARG_INDEX) : 0;
	
	// asset list を取得
	lua.retValue(ARG_ASSET_LIST);

	// 要素の数を数える
	int max = 0;
	lua.retNil();

	// Read indexes and count entries.
	while(lua.tableNext()) {
		lua.retValue(-2);
		int idx = lua.getInt(-1);
		if(max < idx) max = idx;
		lua.pop(2);
	}

	IMGITEM* items = KLBNEWA(IMGITEM, max);

    if(!items) { return false; }

	// Reset all handle to NULL
	for(int idx = 0; idx < max; idx++) {
		items[idx].handle = 0;
		items[idx].sprite = NULL;
	}

	m_order = order; // Needed for getImgList
    if(!getImgList(lua,items,max)) { return false; }
	return initCore(order, x,y,idxImg,items,max);
}
Example #13
0
int main(int argc, char *argv[])
{
    Core *core;
    int option;
    bool enableMemoryDump = false;
    uint32_t memDumpBase = 0;
    uint32_t memDumpLength = 0;
    char *memDumpFilename = NULL;
    size_t memDumpFilenameLen = 0;
    bool verbose = false;
    uint32_t fbWidth = 640;
    uint32_t fbHeight = 480;
    bool blockDeviceOpen = false;
    bool enableFbWindow = false;
    uint32_t totalThreads = 4;
    char *separator;
    uint32_t memorySize = 0x1000000;
    const char *sharedMemoryFile = NULL;
    struct stat st;

    enum
    {
        MODE_NORMAL,
        MODE_COSIMULATION,
        MODE_GDB_REMOTE_DEBUG
    } mode = MODE_NORMAL;

    while ((option = getopt(argc, argv, "f:d:vm:b:t:c:r:s:i:o:")) != -1)
    {
        switch (option)
        {
            case 'v':
                verbose = true;
                break;

            case 'r':
                gScreenRefreshRate = parseNumArg(optarg);
                break;

            case 'f':
                enableFbWindow = true;
                separator = strchr(optarg, 'x');
                if (!separator)
                {
                    fprintf(stderr, "Invalid framebuffer size %s\n", optarg);
                    return 1;
                }

                fbWidth = parseNumArg(optarg);
                fbHeight = parseNumArg(separator + 1);
                break;

            case 'm':
                if (strcmp(optarg, "normal") == 0)
                    mode = MODE_NORMAL;
                else if (strcmp(optarg, "cosim") == 0)
                    mode = MODE_COSIMULATION;
                else if (strcmp(optarg, "gdb") == 0)
                    mode = MODE_GDB_REMOTE_DEBUG;
                else
                {
                    fprintf(stderr, "Unkown execution mode %s\n", optarg);
                    return 1;
                }

                break;

            case 'd':
                // Memory dump, of the form: filename,start,length
                separator = strchr(optarg, ',');
                if (separator == NULL)
                {
                    fprintf(stderr, "bad format for memory dump\n");
                    usage();
                    return 1;
                }

                memDumpFilenameLen = (size_t)(separator - optarg);
                memDumpFilename = (char*) malloc(memDumpFilenameLen + 1);
                strncpy(memDumpFilename, optarg, memDumpFilenameLen);
                memDumpFilename[memDumpFilenameLen] = '\0';
                memDumpBase = parseNumArg(separator + 1);

                separator = strchr(separator + 1, ',');
                if (separator == NULL)
                {
                    fprintf(stderr, "bad format for memory dump\n");
                    usage();
                    return 1;
                }

                memDumpLength = parseNumArg(separator + 1);
                enableMemoryDump = true;
                break;

            case 'b':
                if (openBlockDevice(optarg) < 0)
                    return 1;

                blockDeviceOpen = true;
                break;

            case 'c':
                memorySize = parseNumArg(optarg);
                break;

            case 't':
                totalThreads = parseNumArg(optarg);
                if (totalThreads < 1 || totalThreads > 32)
                {
                    fprintf(stderr, "Total threads must be between 1 and 32\n");
                    return 1;
                }

                break;

            case 's':
                sharedMemoryFile = optarg;
                break;

            case 'i':
                recvInterruptFd = open(optarg, O_RDWR);
                if (recvInterruptFd < 0)
                {
                    perror("main: failed to open receive interrupt pipe");
                    return 1;
                }

                if (fstat(recvInterruptFd, &st) < 0)
                {
                    perror("main: stat failed on receive interrupt pipe");
                    return 1;
                }

                if ((st.st_mode & S_IFMT) != S_IFIFO)
                {
                    fprintf(stderr, "%s is not a pipe\n", optarg);
                    return 1;
                }

                break;

            case 'o':
                sendInterruptFd = open(optarg, O_RDWR);
                if (sendInterruptFd < 0)
                {
                    perror("main: failed to open send interrupt pipe");
                    return 1;
                }

                if (fstat(sendInterruptFd, &st) < 0)
                {
                    perror("main: stat failed on send interrupt pipe");
                    return 1;
                }

                if ((st.st_mode & S_IFMT) != S_IFIFO)
                {
                    fprintf(stderr, "%s is not a pipe\n", optarg);
                    return 1;
                }

                break;

            case '?':
                usage();
                return 1;
        }
    }

    if (optind == argc)
    {
        fprintf(stderr, "No image filename specified\n");
        usage();
        return 1;
    }

    // Don't randomize memory for cosimulation mode, because
    // memory is checked against the hardware model to ensure a match

    core = initCore(memorySize, totalThreads, mode != MODE_COSIMULATION,
                    sharedMemoryFile);
    if (core == NULL)
        return 1;

    if (loadHexFile(core, argv[optind]) < 0)
    {
        fprintf(stderr, "Error reading image %s\n", argv[optind]);
        return 1;
    }

    if (enableFbWindow)
    {
        if (initFramebuffer(fbWidth, fbHeight) < 0)
            return 1;
    }

    switch (mode)
    {
        case MODE_NORMAL:
            if (verbose)
                enableTracing(core);

            setStopOnFault(core, false);
            if (enableFbWindow)
            {
                while (executeInstructions(core, ALL_THREADS, gScreenRefreshRate))
                {
                    updateFramebuffer(core);
                    pollFbWindowEvent();
                    checkInterruptPipe(core);
                }
            }
            else
            {
                while (executeInstructions(core, ALL_THREADS, 1000000))
                    checkInterruptPipe(core);
            }

            break;

        case MODE_COSIMULATION:
            setStopOnFault(core, false);
            if (runCosimulation(core, verbose) < 0)
                return 1;	// Failed

            break;

        case MODE_GDB_REMOTE_DEBUG:
            setStopOnFault(core, true);
            remoteGdbMainLoop(core, enableFbWindow);
            break;
    }

    if (enableMemoryDump)
        writeMemoryToFile(core, memDumpFilename, memDumpBase, memDumpLength);

    dumpInstructionStats(core);
    if (blockDeviceOpen)
        closeBlockDevice();

    if (stoppedOnFault(core))
        return 1;

    return 0;
}
Example #14
0
int
main (int argc, char **argv)
{
    CompIOCtx ctx;
    char      *displayName = 0;
    char      *plugin[256];
    int	      i, nPlugin = 0;
    Bool      disableSm = FALSE;
    char      *clientId = NULL;
    char      *refreshRateArg = NULL;

    programName = argv[0];
    programArgc = argc;
    programArgv = argv;

    signal (SIGHUP, signalHandler);
    signal (SIGCHLD, signalHandler);
    signal (SIGINT, signalHandler);
    signal (SIGTERM, signalHandler);
    signal (SIGSEGV, signalHandler);

    emptyRegion.rects = &emptyRegion.extents;
    emptyRegion.numRects = 0;
    emptyRegion.extents.x1 = 0;
    emptyRegion.extents.y1 = 0;
    emptyRegion.extents.x2 = 0;
    emptyRegion.extents.y2 = 0;
    emptyRegion.size = 0;

    infiniteRegion.rects = &infiniteRegion.extents;
    infiniteRegion.numRects = 1;
    infiniteRegion.extents.x1 = MINSHORT;
    infiniteRegion.extents.y1 = MINSHORT;
    infiniteRegion.extents.x2 = MAXSHORT;
    infiniteRegion.extents.y2 = MAXSHORT;

    memset (&ctx, 0, sizeof (ctx));

    for (i = 1; i < argc; i++)
    {
	if (!strcmp (argv[i], "--help"))
	{
	    usage ();
	    return 0;
	}
	else if (!strcmp (argv[i], "--version"))
	{
	    printf (PACKAGE_STRING "\n");
	    return 0;
	}
	else if (!strcmp (argv[i], "--debug"))
	{
	    debugOutput = TRUE;
	}
	else if (!strcmp (argv[i], "--display"))
	{
	    if (i + 1 < argc)
		displayName = argv[++i];
	}
	else if (!strcmp (argv[i], "--refresh-rate"))
	{
	    if (i + 1 < argc)
	    {
		refreshRateArg = programArgv[++i];
		defaultRefreshRate = atoi (refreshRateArg);
		defaultRefreshRate = RESTRICT_VALUE (defaultRefreshRate,
						     1, 1000);
	    }
	}
	else if (!strcmp (argv[i], "--fast-filter"))
	{
	    ctx.textureFilterData = "<default>Fast</default>";
	    defaultTextureFilter = "Fast";
	}
	else if (!strcmp (argv[i], "--indirect-rendering"))
	{
	    /* force Mesa libGL into indirect rendering mode, because
	       glXQueryExtensionsString is context-independant */
	    setenv ("LIBGL_ALWAYS_INDIRECT", "1", True);
	    indirectRendering = TRUE;
	}
	else if (!strcmp (argv[i], "--loose-binding"))
	{
	    strictBinding = FALSE;
	}
	else if (!strcmp (argv[i], "--ignore-desktop-hints"))
	{
	    /* keep command line parameter for backward compatibility */
	    useDesktopHints = FALSE;
	}
	else if (!strcmp (argv[i], "--keep-desktop-hints"))
	{
	    useDesktopHints = TRUE;
	}
	else if (!strcmp (argv[i], "--only-current-screen"))
	{
	    onlyCurrentScreen = TRUE;
	}
	else if (!strcmp (argv[i], "--no-fbo"))
	{
		noFBO = TRUE;
	}

#ifdef USE_COW
	else if (!strcmp (argv[i], "--use-root-window"))
	{
	    useCow = FALSE;
	}
#endif

	else if (!strcmp (argv[i], "--replace"))
	{
	    replaceCurrentWm = TRUE;
	}
	else if (!strcmp (argv[i], "--sm-disable"))
	{
	    disableSm = TRUE;
	}
	else if (!strcmp (argv[i], "--sm-client-id"))
	{
	    if (i + 1 < argc)
		clientId = argv[++i];
	}
	else if (!strcmp (argv[i], "--no-detection"))
	{
	    noDetection = TRUE;
	}
	else if (!strcmp (argv[i], "--bg-image"))
	{
	    if (i + 1 < argc)
		backgroundImage = argv[++i];
	}
	else if (*argv[i] == '-')
	{
	    compLogMessage ("core", CompLogLevelWarn,
			    "Unknown option '%s'\n", argv[i]);
	}
	else
	{
	    if (nPlugin < 256)
		plugin[nPlugin++] = argv[i];
	}
    }

    /* add in default plugins if none are given */
    if (nPlugin == 0)
    {
        plugin[nPlugin++] = "ccp";
        plugin[nPlugin++] = "move";
        plugin[nPlugin++] = "resize";
        plugin[nPlugin++] = "place";
        plugin[nPlugin++] = "decoration";
    }

    if (refreshRateArg)
    {
	ctx.refreshRateData = malloc (strlen (refreshRateArg) + 256);
	if (ctx.refreshRateData)
	    sprintf (ctx.refreshRateData,
		     "<min>1</min><default>%s</default>",
		     refreshRateArg);
    }

    if (nPlugin)
    {
	int size = 256;

	for (i = 0; i < nPlugin; i++)
	    size += strlen (plugin[i]) + 16;

	ctx.pluginData = malloc (size);
	if (ctx.pluginData)
	{
	    char *ptr = ctx.pluginData;

	    ptr += sprintf (ptr, "<type>string</type><default>");

	    for (i = 0; i < nPlugin; i++)
		ptr += sprintf (ptr, "<value>%s</value>", plugin[i]);

	    ptr += sprintf (ptr, "</default>");
	}

	initialPlugins = malloc (nPlugin * sizeof (char *));
	if (initialPlugins)
	{
	    memcpy (initialPlugins, plugin, nPlugin * sizeof (char *));
	    nInitialPlugins = nPlugin;
	}
	else
	{
	    nInitialPlugins = 0;
	}
    }

    xmlInitParser ();

    LIBXML_TEST_VERSION;

    if (!compInitMetadata (&coreMetadata))
    {
	compLogMessage ("core", CompLogLevelFatal,
			"Couldn't initialize core metadata");
	return 1;
    }

    if (!compAddMetadataFromIO (&coreMetadata,
				readCoreXmlCallback, NULL,
				&ctx))
	return 1;

    if (ctx.refreshRateData)
	free (ctx.refreshRateData);

    if (ctx.pluginData)
	free (ctx.pluginData);

    compAddMetadataFromFile (&coreMetadata, "core");

    if (!initCore ())
	return 1;

    coreInitialized = TRUE;

    if (!disableSm)
    {
	if (clientId == NULL)
	{
	    char *desktop_autostart_id = getenv ("DESKTOP_AUTOSTART_ID");
	    if (desktop_autostart_id != NULL)
		clientId = strdup (desktop_autostart_id);
	    unsetenv ("DESKTOP_AUTOSTART_ID");
	}

	initSession (clientId);
    }

    if (!addDisplay (displayName))
	return 1;

    eventLoop ();

    if (!disableSm)
	closeSession ();

    coreInitialized = FALSE;

    finiCore ();
    compFiniMetadata (&coreMetadata);

    xmlCleanupParser ();

    if (initialPlugins)
        free (initialPlugins);

    if (restartSignal)
    {
	execvp (programName, programArgv);
	return 1;
    }

    return 0;
}
Example #15
0
File: main.c Project: zmike/compiz
EINTERN int
compiz_main(void)
{
   CompIOCtx ctx;
   char *displayName = 0;
   char *plugin[256];
   int i, nPlugin = 0;
   Bool disableSm = FALSE;
   char *clientId = NULL;
   char *refreshRateArg = NULL;

   ecore_app_args_get(&programArgc, &programArgv);
   programName = programArgv[0];

   emptyRegion.rects = &emptyRegion.extents;
   emptyRegion.numRects = 0;
   emptyRegion.extents.x1 = 0;
   emptyRegion.extents.y1 = 0;
   emptyRegion.extents.x2 = 0;
   emptyRegion.extents.y2 = 0;
   emptyRegion.size = 0;

   infiniteRegion.rects = &infiniteRegion.extents;
   infiniteRegion.numRects = 1;
   infiniteRegion.extents.x1 = MINSHORT;
   infiniteRegion.extents.y1 = MINSHORT;
   infiniteRegion.extents.x2 = MAXSHORT;
   infiniteRegion.extents.y2 = MAXSHORT;

   memset(&ctx, 0, sizeof (ctx));

   if (!clientId)
     {
        clientId = getenv("DESKTOP_AUTOSTART_ID");
     }

   if (refreshRateArg)
     {
        ctx.refreshRateData = malloc(strlen(refreshRateArg) + 256);
        if (ctx.refreshRateData)
          sprintf(ctx.refreshRateData,
                  "<min>1</min><default>%s</default>",
                  refreshRateArg);
     }

   plugin[nPlugin++] = "ccp";
   if (nPlugin)
     {
        int size = 256;

        for (i = 0; i < nPlugin; i++)
          size += strlen(plugin[i]) + 16;

        ctx.pluginData = malloc(size);
        if (ctx.pluginData)
          {
             char *ptr = ctx.pluginData;

             ptr += sprintf(ptr, "<type>string</type><default>");

             for (i = 0; i < nPlugin; i++)
               ptr += sprintf(ptr, "<value>%s</value>", plugin[i]);

             ptr += sprintf(ptr, "</default>");
          }

        initialPlugins = malloc(nPlugin * sizeof (char *));
        if (initialPlugins)
          {
             memcpy(initialPlugins, plugin, nPlugin * sizeof (char *));
             nInitialPlugins = nPlugin;
          }
        else
          {
             nInitialPlugins = 0;
          }
     }

   xmlInitParser();

   LIBXML_TEST_VERSION;

   if (!compInitMetadata(&coreMetadata))
     {
        compLogMessage("core", CompLogLevelFatal,
                       "Couldn't initialize core metadata");
        return 1;
     }

   if (!compAddMetadataFromIO(&coreMetadata,
                              readCoreXmlCallback, NULL,
                              &ctx))
     return 1;

   if (ctx.refreshRateData)
     free(ctx.refreshRateData);

   if (ctx.pluginData)
     free(ctx.pluginData);

   compAddMetadataFromFile(&coreMetadata, "core");

   if (!initCore())
     return 1;

   coreInitialized = TRUE;

   if (!addDisplay(displayName))
     return 1;
   return 0;
}
Example #16
0
/**
 * Input:
 * {
 *   "admin": {
 *     "core": "/path/to/core/binary",
 *     "bind": "127.0.0.1:12345",
 *     "pass": "******",
 *     "user": "******"
 *   }
 * }
 * for example:
 * d5:admind4:core30:./build/admin/angel/cjdns-core4:bind15:127.0.0.1:123454:pass4:abcdee
 *
 * Pre-existing core mode:
 * {
 *   "admin": {
 *     "core": {
 *       "fromCore": 12,
 *       "toCore": 14
 *     },
 *     "bind": "127.0.0.1:12345",
 *     "pass": "******",
 *     "user": "******"
 *   }
 * }
 *
 * If "core" is a dictionary, the angel will behave as though the core is already spawned and
 * it will read from the core on the file descriptor given by "fromCore" and write to the file
 * given by "toCore".
 *
 * "user" is optional, if set the angel will setuid() that user's uid.
 */
int AngelInit_main(int argc, char** argv)
{
    struct Except* eh = NULL;

    struct Allocator* alloc = MallocAllocator_new(1<<21);
    struct Writer* logWriter = FileWriter_new(stdout, alloc);
    struct Log* logger = WriterLog_new(logWriter, alloc);
    struct Random* rand = Random_new(alloc, logger, eh);
    MallocAllocator_setCanary(alloc, (long)Random_int64(rand));
    struct Allocator* tempAlloc = Allocator_child(alloc);
    struct EventBase* eventBase = EventBase_new(alloc);

    struct Pipe* clientPipe = getClientPipe(argc, argv, eventBase, eh, alloc);
    clientPipe->logger = logger;

    Log_debug(logger, "Getting pre-configuration from client");

    struct Message* preConf = InterfaceWaiter_waitForData(&clientPipe->iface, eventBase, alloc, eh);

    Log_debug(logger, "Finished getting pre-configuration from client");

    struct Reader* reader = ArrayReader_new(preConf->bytes, preConf->length, tempAlloc);
    Dict config;
    if (StandardBencSerializer_get()->parseDictionary(reader, tempAlloc, &config)) {
        Except_raise(eh, -1, "Failed to parse configuration.");
    }

    Dict* admin = Dict_getDict(&config, String_CONST("admin"));
    String* core = Dict_getString(admin, String_CONST("core"));
    String* bind = Dict_getString(admin, String_CONST("bind"));
    String* pass = Dict_getString(admin, String_CONST("pass"));
    String* user = Dict_getString(admin, String_CONST("user"));
    String* corePipeName = Dict_getString(admin, String_CONST("corePipeName"));

    if (!bind || !pass || (!core && !corePipeName)) {
        Except_raise(eh, -1, "missing configuration params in preconfig. [%s]", preConf->bytes);
    }

    if (!corePipeName) {
        char name[32] = {0};
        Random_base32(rand, (uint8_t*)name, 31);
        corePipeName = String_new(name, tempAlloc);
    }

    struct Pipe* corePipe = Pipe_named(corePipeName->bytes, eventBase, eh, alloc);
    corePipe->logger = logger;
    corePipe->onClose = coreDied;
    struct Interface* coreIface = FramingInterface_new(65535, &corePipe->iface, alloc);

    if (core) {
        Log_info(logger, "Initializing core [%s]", core->bytes);
        initCore(core->bytes, corePipeName, eventBase, alloc, eh);
    }

    Log_debug(logger, "Sending pre-configuration to core.");


    sendConfToCore(coreIface, tempAlloc, &config, eh, logger);

    struct Message* coreResponse = InterfaceWaiter_waitForData(coreIface, eventBase, tempAlloc, eh);

    Interface_sendMessage(&clientPipe->iface, coreResponse);

    #ifdef Log_KEYS
        uint8_t lastChar = coreResponse->bytes[coreResponse->length-1];
        coreResponse->bytes[coreResponse->length-1] = 0;
        Log_keys(logger, "Sent [%s%c] to client.", coreResponse->bytes, lastChar);
        coreResponse->bytes[coreResponse->length-1] = lastChar;
    #endif

    if (user) {
        setUser(user->bytes, logger, eh);
    }

    Allocator_free(tempAlloc);
    Angel_start(coreIface, eventBase, logger, alloc);
    return 0;
}
Example #17
0
static void sendConfToCore(struct Interface* toCoreInterface,
                           struct Allocator* alloc,
                           Dict* config,
                           struct Except* eh,
                           struct Log* logger)
{
    #define CONFIG_BUFF_SIZE 1024
    uint8_t buff[CONFIG_BUFF_SIZE + 32] = {0};
    uint8_t* start = buff + 32;

    struct Writer* writer = ArrayWriter_new(start, CONFIG_BUFF_SIZE - 33, alloc);
    if (StandardBencSerializer_get()->serializeDictionary(writer, config)) {
        Except_raise(eh, -1, "Failed to serialize pre-configuration for core.");
    }
    struct Message m = {
        .bytes = start,
        .length = writer->bytesWritten(writer),
        .padding = 32
    };
    Log_keys(logger, "Sent [%d] bytes to core [%s].", m.length, m.bytes);
    toCoreInterface->sendMessage(&m, toCoreInterface);
}

static void setUser(char* user, struct Log* logger, struct Except* eh)
{
    struct Jmp jmp;
    Jmp_try(jmp) {
        Security_setUser(user, logger, &jmp.handler);
    } Jmp_catch {
        if (jmp.code == Security_setUser_PERMISSION) {
            return;
        }
        Except_raise(eh, jmp.code, "%s", jmp.message);
    }
}

/**
 * Input:
 * {
 *   "admin": {
 *     "core": "/path/to/core/binary",
 *     "bind": "127.0.0.1:12345",
 *     "pass": "******",
 *     "user": "******"
 *   }
 * }
 * for example:
 * d5:admind4:core30:./build/admin/angel/cjdns-core4:bind15:127.0.0.1:123454:pass4:abcdee
 *
 * Pre-existing core mode:
 * {
 *   "admin": {
 *     "core": {
 *       "fromCore": 12,
 *       "toCore": 14
 *     },
 *     "bind": "127.0.0.1:12345",
 *     "pass": "******",
 *     "user": "******"
 *   }
 * }
 *
 * If "core" is a dictionary, the angel will behave as though the core is already spawned and
 * it will read from the core on the file descriptor given by "fromCore" and write to the file
 * given by "toCore".
 *
 * "user" is optional, if set the angel will setuid() that user's uid.
 */
int AngelInit_main(int argc, char** argv)
{
    struct Except* eh = NULL;

    int inFromClientNo;
    int outToClientNo;
    if (argc < 3 || (inFromClientNo = atoi(argv[2])) == 0) {
        inFromClientNo = STDIN_FILENO;
    }
    if (argc < 4 || (outToClientNo = atoi(argv[3])) == 0) {
        outToClientNo = STDOUT_FILENO;
    }

    struct Allocator* alloc = MallocAllocator_new(1<<21);
    struct Writer* logWriter = FileWriter_new(stdout, alloc);
    struct Log* logger = WriterLog_new(logWriter, alloc);
    struct Random* rand = Random_new(alloc, logger, eh);
    alloc = CanaryAllocator_new(alloc, rand);
    struct Allocator* tempAlloc = Allocator_child(alloc);
    struct EventBase* eventBase = EventBase_new(alloc);


    Log_debug(logger, "Initializing angel with input [%d] and output [%d]",
              inFromClientNo, outToClientNo);
    Log_debug(logger, "Getting pre-configuration from client");

    #define CONFIG_BUFF_SIZE 1024
    uint8_t buff[CONFIG_BUFF_SIZE] = {0};
    Waiter_getData(buff, CONFIG_BUFF_SIZE, inFromClientNo, eventBase, eh);

    Log_debug(logger, "Finished getting pre-configuration from client");

    struct Reader* reader = ArrayReader_new(buff, CONFIG_BUFF_SIZE, tempAlloc);
    Dict config;
    if (StandardBencSerializer_get()->parseDictionary(reader, tempAlloc, &config)) {
        Except_raise(eh, -1, "Failed to parse configuration.");
    }

    Dict* admin = Dict_getDict(&config, String_CONST("admin"));
    String* core = Dict_getString(admin, String_CONST("core"));
    String* bind = Dict_getString(admin, String_CONST("bind"));
    String* pass = Dict_getString(admin, String_CONST("pass"));
    String* user = Dict_getString(admin, String_CONST("user"));

    int toCore = -1;
    int fromCore = -1;
    if (!core) {
        Dict* coreDict = Dict_getDict(admin, String_CONST("core"));
        int64_t* toCorePtr = Dict_getInt(coreDict, String_CONST("toCore"));
        int64_t* fromCorePtr = Dict_getInt(coreDict, String_CONST("fromCore"));
        toCore = (toCorePtr) ? *toCorePtr : -1;
        fromCore = (fromCorePtr) ? *fromCorePtr : -1;
    }

    if (!bind || !pass || (!core && (toCore == -1 || fromCore == -1))) {
        Except_raise(eh, -1, "missing configuration params in preconfig. [%s]", buff);
    }

    if (core) {
        Log_info(logger, "Initializing core [%s]", core->bytes);
        initCore(core->bytes, &toCore, &fromCore, eh);
    }

    Log_debug(logger, "Sending pre-configuration to core.");
    struct PipeInterface* pif =
        PipeInterface_new(fromCore, toCore, eventBase, logger, alloc, rand);
    struct Interface* coreIface = &pif->generic;
    PipeInterface_waitUntilReady(pif);

    sendConfToCore(coreIface, tempAlloc, &config, eh, logger);

    struct Message* coreResponse = InterfaceWaiter_waitForData(coreIface, eventBase, tempAlloc, eh);
    if (write(outToClientNo, coreResponse->bytes, coreResponse->length)) {
        // Ignore the result of write() without the compiler complaining.
    }

    #ifdef Log_KEYS
        uint8_t lastChar = coreResponse->bytes[coreResponse->length-1];
        coreResponse->bytes[coreResponse->length-1] = 0;
        Log_keys(logger, "Sent [%s%c] to client.", coreResponse->bytes, lastChar);
        coreResponse->bytes[coreResponse->length-1] = lastChar;
    #endif

    if (user) {
        setUser(user->bytes, logger, eh);
    }

    Allocator_free(tempAlloc);
    Angel_start(coreIface, eventBase, logger, alloc);
    return 0;
}
void ExportCoreTypes()
{
	initCore();
}
Example #19
0
int main()
{
	//////////////////////////////////////////////////////////////////
	////Loads core files in for game processes
	coreLoad(Window);
	coreLoad(Time);
	coreLoad(Input);
	coreLoad(Camera);
	coreLoad(Factory);
	coreLoad(Asset);
	//////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////
	////Loads system files in
	systemLoad(TransformUpdate);
	systemLoad(Rendering);
	systemLoad(textRenderSys);
	systemLoad(trafficSys);
	systemLoad(collisionPrep);
	systemLoad(CollisionDetection);
	systemLoad(StaticCollision);
	systemLoad(collisionResponse);
	systemLoad(RigidbodyDynamics);
	systemLoad(TankDynamics);
	systemLoad(LifeTimeDynamics);
	systemLoad(collisionRender);
	//////////////////////////////////////////////////////////////////
	
	initCore();//Main Game Loop
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	////////Files Loaded in for textures and shaders files
	///Shaders
	core(Asset).loadShader("Flat", "./shaders/simpleShader.vert", "./shaders/simpleShader.frag");
	core(Asset).loadShader("Texture", "./shaders/simpleShader.vert", "./shaders/textureShader.frag");
	core(Asset).loadShader("FontShader", "./shaders/simpleShader.vert", "./shaders/fontShader.frag");
	///Texture Files
	//Track
	core(Asset).loadTexture("Track", "./texture/Track.png");
	//Car Images
	core(Asset).loadTexture("Car1texture", "./texture/car.png");
	core(Asset).loadTexture("Car2texture", "./texture/car2.png");
	core(Asset).loadTexture("Car1Turret", "./texture/carTank.png");
	core(Asset).loadTexture("Car2Turret", "./texture/car2Tank.png");
	//Animations
	core(Asset).loadTexture("Walking", "./texture/WalkingAnimation.png", 4, 6);
	core(Asset).loadTexture("Raka", "./texture/Raka.png", 2, 5);
	core(Asset).loadTexture("Garren", "./texture/GARREN.bmp", 10, 12);
	core(Asset).loadTexture("Draven", "./texture/SPINNERS.bmp", 4, 4);
	core(Asset).loadTexture("Milk", "./texture/CANTMILK.bmp", 4, 6);
	core(Asset).loadTexture("Font", "./texture/font2.png", 8, 16);
	core(Asset).loadTexture("Light", "./texture/trafficLight.png", 1, 3);
	core(Asset).loadTexture("Flag", "./texture/FLAG.bmp", 2, 2);

	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	//////Vertex for game objects
	///Font
	Vertex font_vertexQ[4] = {  { {-.5, .5, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } },
								{ { .5, .5, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } },
								{ { .5,-.5, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } },
								{ {-.5,-.5, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } };

	///Walking
	Vertex Animation_vertQ[4] = { { { core(Window).width() / 2, core(Window).height() / 2, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } },
							      { {                        0, core(Window).height() / 2, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } },
								  { {                        0,							0, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } },
								  { { core(Window).width() / 2,							0, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } };

	///Track
	Vertex Track_vertQ[4] = { { { core(Window).width(), core(Window).height(), 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } },
							  { {					 0, core(Window).height(), 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } },
							  { {					 0,						0, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } },
							  { { core(Window).width(),					    0, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } };

	///Car
	Vertex Car_vertexQ[4] = { { { -15, 30, 0, 1 }, { 0, 1, 1, 0 }, { 0, 0 } },
	{ { 15, 30, 0, 1 }, { 0, 1, 1, 0 }, { 1, 0 } },
							   { { 15, -30, 0, 1 }, { 0, 1, 1, 0 }, { 1, 1 } },
							   { {-15,-30, 0, 1 }, { 0, 1, 1, 0 }, { 0, 1 } } };

	///Turret
	Vertex Turret[4] = { { {-10, 10, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } },
						 { { 10, 10, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } },
						 { { 10,-10, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } },
						 { {-10,-10, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } };

	///Bullet
	Vertex Bullet[4] = { { {-5, 5, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } },
						 { { 5, 5, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } },
						 { { 5,-5, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } },
						 { {-5,-5, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } };

	///Light
	Vertex Light[4] = { { { -30, 70, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } },
						{ { 30, 70, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } },
						{ { 30, -70, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } },
						{ { -30, -70, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } };

	///Flag
	Vertex Flag[4] = {  { {-290, 170, 0, 1 }, { 1, 0, 1, 0 }, { 0, 0 } },
						{ { 290, 170, 0, 1 }, { 0, 1, 0, 1 }, { 1, 0 } },
						{ { 290,-170, 0, 1 }, { 1, 0, 1, 0 }, { 1, 1 } },
						{ {-290,-170, 0, 1 }, { 0, 1, 0, 1 }, { 0, 1 } } };
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	///////Triangles for objects
	///font
	Triangle quad[2] = { { 0, 1, 2 }, { 0, 2, 3 } };

	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////
	
	//////Meshes
	core(Asset).loadMesh("Bullet", Bullet, 4, quad, 2);
	core(Asset).loadMesh("Turret", Turret, 4, quad, 2);
	core(Asset).loadMesh("Car", Car_vertexQ, 4, quad, 2);
	core(Asset).loadMesh("Anime", Animation_vertQ, 4, quad, 2);
	core(Asset).loadMesh("Quad", font_vertexQ, 4, quad, 2);
	core(Asset).loadMesh("TrackMesh", Track_vertQ, 4, quad, 2);
	core(Asset).loadMesh("lightMesh", Light, 4, quad, 2);
	core(Asset).loadMesh("flagMesh", Flag, 4, quad, 2);
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////

	//////Factory Entities Loading in
	////BackGround
	core(Factory).makeBG(0, 0);

	////Cars
	auto p1 = core(Factory).MakeTank(790, 620, 1); //Car1
	auto p2 = core(Factory).MakeTank(790, 560, 2, 'I', 'K', 'J', 'L', 'U', 'O', 'N'); //Car2
	////Car Names
	core(Factory).makeText(0, 0, "P1",16,24,p1->transform); //Car1 Name
	core(Factory).makeText(0, 0, "P2", 16, 24, p2->transform); //Car2 Name

	////Game borders
	core(Factory).MakeBorder(70, core(Window).height() - 65, vec3Make(1, 0, 0));
	core(Factory).MakeBorder(70, core(Window).height() - 65, vec3Make(0, -1, 0));
	core(Factory).MakeBorder(core(Window).width() - 45, 65, vec3Make(-1, 0, 0));
	core(Factory).MakeBorder(core(Window).width() - 45, 65, vec3Make(0, 1, 0));

	////track hit markers
	//core(Factory).makeLine(725, 590);
	core(Factory).makeCenter(core(Window).width()/2, core(Window).height() / 2);

	////Hud info
	core(Factory).makeLight(core(Window).width() / 2, core(Window).height() / 2,
		core(Factory).makeGate(760, 590, vec3Make(1, 0, 0)), core(Factory).makeGate(820, 590, vec3Make(-1, 0, 0)));
	//////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////

	runGame(); //end of game loop
}