Example #1
0
ApplicationDesktop::ApplicationDesktop(unsigned int newWidth, unsigned int newHeight)
    : Application(newWidth, newHeight)
    , mainwindow(nullptr)
    , maincontext(0)
{
    getAssetManager().setAssetLoader(new Assets::LoaderDesktop());
}
Example #2
0
//--------------------------------------------------------------
void PlayerAsset::processOscCommand(const string& command, const ofxOscMessage& m) {
    
    if(isMatch(command,"load")) {
        if(validateOscSignature("s", m)) {
            string assetAlias = getArgAsStringUnchecked(m, 0);
            
            if(hasAssetManager()) {
                BaseMediaAsset* asset = getAssetManager()->getAsset(assetAlias);
                
                if(asset != NULL) {
                    if(asset->isPlayable()) {
                        PlayableAsset* playableAsset = dynamic_cast<PlayableAsset*>(asset);
                        if(playableAsset != NULL) {
                            load(playableAsset);
                        } else {
                            ofLogError("PlayerAsset") << assetAlias << " could not be cast to a playable asset.";
                        }
                        
                    } else {
                        ofLogError("PlayerAsset") << assetAlias << " is not a playable asset.";
                    }
                } else {
                    ofLogError("PlayerAsset") << "no asset called " << assetAlias << " exists.";
                }
            }
            
            
            
        }
    } else if(isMatch(command,"start")) {
        player->start();
    } else if(isMatch(command,"stop")) {
        player->stop();
    } else if(isMatch(command,"pause")) {
        if(validateOscSignature("[sfi]", m)) {
            player->setPaused(getArgAsBoolUnchecked(m,0));
        }
    } else if(isMatch(command,"loopmode")) {
        if(validateOscSignature("s", m)) {
            string loopMode = getArgAsStringUnchecked(m,0);
            if(isMatch(loopMode,"NONE")) {
                player->setLoopType(OF_LOOP_NONE);
            } else if(isMatch(loopMode,"LOOP")) {
                player->setLoopType(OF_LOOP_NORMAL);
            } else if(isMatch(loopMode,"PALINDROME")) {
                player->setLoopType(OF_LOOP_PALINDROME);
            } else {
                ofLog(OF_LOG_WARNING, "FrameBufferPlayer: Unknown loop mode: " + loopMode);
            }
        }
    } else if(isMatch(command,"looppoints")) {
        if(validateOscSignature("[fi][fi]", m)) {
            player->setLoopPoints(getArgAsFloatUnchecked(m,0),getArgAsFloatUnchecked(m,1));
        }
    } else if(isMatch(command,"looppointstart")) {
        if(validateOscSignature("[fi]", m)) {
            player->setLoopPointStart(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"looppointend")) {
        if(validateOscSignature("[fi]", m)) {
            player->setLoopPointStart(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"looppointsn")) {
        if(validateOscSignature("[fi][fi]", m)) {
            player->setLoopPointsNorm(getArgAsFloatUnchecked(m,0),getArgAsFloatUnchecked(m,1));
        }
    } else if(isMatch(command,"looppointstartn")) {
        if(validateOscSignature("[fi]", m)) {
            player->setLoopPointStartNorm(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"looppointendn")) {
        if(validateOscSignature("[fi]", m)) {
            player->setLoopPointStartNorm(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"frame")) {
        if(validateOscSignature("[fi]", m)) {
            player->setFrame(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"framen")) {
        if(validateOscSignature("[fi]", m)) {
            player->setFrameNorm(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"speed")) {
        if(validateOscSignature("[fi]", m)) {
            player->setSpeed(getArgAsFloatUnchecked(m,0));
        }
    } else if(isMatch(command,"dump")) {
        dump();
    } else {
        // unknown command
    }
}
Example #3
0
GAE_File_t* GAE_File_open(GAE_File_t* file, const GAE_FILE_OPEN_MODE openMode, const GAE_FILE_MODE fileMode, GAE_FILE_STATUS* status) {
	GAE_PlatformFile_t* platform = (GAE_PlatformFile_t*)file->platformFile;
	char options[2];

	if (file->fileStatus != GAE_FILE_CLOSED) {
		if (0 != status)
			*status = GAE_FILE_ERROR;
		return file;
	}
	
	if (0 != platform->file) {
		if (0 != status)
			*status = GAE_FILE_ERROR;
		return file;
	}
	
	if (0 != file->buffer) {
		if (0 != status)
			*status = GAE_FILE_ERROR;
		return file;
	}
	
	switch (openMode) {
		case GAE_FILE_OPEN_READ:
			options[0] = 'r';
			file->owned = GAE_TRUE;
			break;
		case GAE_FILE_OPEN_WRITE:
			options[0] = 'w';
			file->owned = GAE_FALSE;
			break;
		case GAE_FILE_OPEN_APPEND:
			options[0] = 'a';
			file->owned = GAE_FALSE;
			break;
	};
	
	switch (fileMode) {
		case GAE_FILE_ASCII:
			options[1] = '\0';
			break;
		case GAE_FILE_BINARY:
			options[1] = 'b';
			break;
	};
	
	platform->file = fopen(file->filePath, options);
	
	if (0 == platform->file) /* not on sdcard, lets try the apk */
		platform->asset = AAssetManager_open(getAssetManager(), file->filePath, AASSET_MODE_UNKNOWN);

	if ((0 == platform->file) && (0 == platform->asset)) { /* nope, not found at all */
		if (0 != status)
			*status = GAE_FILE_NOT_FOUND;
		ANDROID_INFO("File Not Found: %s", file->filePath);
		return file;
	}
	
	file->fileStatus = GAE_FILE_OPEN;
	file->openMode = openMode;

	if (0 != platform->file) {	
		fseek(platform->file, 0, SEEK_END);
		file->fileSize = ftell(platform->file);
		rewind(platform->file);
	}
	else
		file->fileSize = AAsset_getLength(platform->asset);
	
	if (0 != status)
		*status = file->fileStatus;

	ANDROID_INFO("Found: %s of size %d", file->filePath, (unsigned int)file->fileSize);

	return file;
}
Example #4
0
/**
 * Initialize an EGL context for the current display.
 */
static int engine_init_display(struct engine_info_t* engine) {
	uchar engineParameters = 0;
	char cwd[256];
	char lpBuffer[256];
 
	engineParameters |= GL_11_RENDERER ;
  
	setenv( "RD", "assets", 1 ); 
	setenv( "WD", "mnt/sdcard/app-data/com.miadzin.shmup", 1 );

	assetManager = getAssetManager();
	
	renderer.materialQuality = MATERIAL_QUALITY_HIGH;
	renderer.glBuffersDimensions[WIDTH] = 480;
	renderer.glBuffersDimensions[HEIGHT] = 800;
	renderer.resolution = 1.5f;
	renderer.props |= PROP_FOG;
	renderer.props |= PROP_SHADOW ;
	renderer.props |= PROP_BUMP ;
	renderer.props |= PROP_SPEC ;
	
	int gameOn = 1;

	dEngine_Init();


	// initialize OpenGL ES and EGL

	/*
	 * Here specify the attributes of the desired configuration.
	 * Below, we select an EGLConfig with at least 8 bits per color
	 * component compatible with on-screen windows
	 */
	const EGLint attribs[] = {
			EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
			EGL_BLUE_SIZE, 8,
			EGL_GREEN_SIZE, 8,
			EGL_RED_SIZE, 8,
			EGL_NONE
	};
	EGLint w, h, dummy, format;
	EGLint numConfigs;
	EGLConfig config;
	EGLSurface surface;
	EGLContext context;

	EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

	eglInitialize(display, 0, 0);

	/* Here, the application chooses the configuration it desires. In this
	 * sample, we have a very simplified selection process, where we pick
	 * the first EGLConfig that matches our criteria */
	eglChooseConfig(display, attribs, &config, 1, &numConfigs);

	/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
	 * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
	 * As soon as we picked a EGLConfig, we can safely reconfigure the
	 * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
	eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);

	ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);

	surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
	context = eglCreateContext(display, config, NULL, NULL);

	if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
		LOGW("Unable to eglMakeCurrent");
		return -1;
	}

	eglQuerySurface(display, surface, EGL_WIDTH, &w);
	eglQuerySurface(display, surface, EGL_HEIGHT, &h);

	engine->display = display;
	engine->context = context;
	engine->surface = surface;
	engine->width = w;
	engine->height = h;
	//engine->state.angle = 0;

	// Initialize GL state.
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
	glEnable(GL_CULL_FACE);
	glShadeModel(GL_SMOOTH);
	glDisable(GL_DEPTH_TEST);

  	dEngine_InitDisplaySystem(engineParameters);

  	commScale[X] = commScale[Y] = renderer.resolution;
  	
	return 0;
}