Exemple #1
0
bool 
GfuiMenuCreateStaticControls(void* hscr, void* hparm)
{
	if (!hparm)
	{
		GfLogError("Failed to create static controls (XML menu descriptor not yet loaded)\n");
		return false;
	}

    char buf[32];

    for (int i = 1; i <= GfParmGetEltNb(hparm, GFMNU_SECT_STATIC_CONTROLS); i++)
    {
		snprintf(buf, sizeof(buf), GFMNU_SECT_STATIC_CONTROLS"/%d", i);
		const char* pszType = GfParmGetStr(hparm, buf, GFMNU_ATTR_TYPE, "");
    
		if (!strcmp(pszType, GFMNU_TYPE_LABEL))
		{
			createLabel(hscr, hparm, buf);
		}
		else if (!strcmp(pszType, GFMNU_TYPE_STATIC_IMAGE))
		{
			createStaticImage(hscr, hparm, buf);
		}
		else if (!strcmp(pszType, GFMNU_TYPE_BACKGROUND_IMAGE))
		{
			createBackgroundImage(hscr, hparm, buf);
		}
		else
		{
			GfLogWarning("Failed to create static control '%s' of unknown type '%s'\n",
						 buf, pszType);
		}
    }
	 
	 // while not truly a static control (visually), each menu/screen can have
	 // background music. As 'GfuiMenuCreateStaticControls()' is called on load
	 // of each menu, this was deemed the least intrusive place to add the
	 // music filename to the screen's struct.
	 createMusic(hscr,hparm);
    return true;
}
Exemple #2
0
/* the main function */
int main(int argc, char *argv[])
{

    AppState state;

    char *vconf = "";

    if (SDL_Init(SDL_INIT_EVERYTHING) == -1){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }

    SDL_RendererInfo displayRendererInfo;


    SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_OPENGL, &state.window, &state.renderer);
    SDL_GetRendererInfo(state.renderer, &displayRendererInfo);


    fprintf(stdout,"SDL Renderer accelerated %d\n",displayRendererInfo.flags & SDL_RENDERER_ACCELERATED);
    fprintf(stdout,"SDL Renderer target texture %d\n",displayRendererInfo.flags & SDL_RENDERER_TARGETTEXTURE);



    /* check support */
    if ((displayRendererInfo.flags & SDL_RENDERER_ACCELERATED) == 0 ||
            (displayRendererInfo.flags & SDL_RENDERER_TARGETTEXTURE) == 0)
    {
        fprintf(stderr,"SDL not fully supported\n");
        return -1;
    }

    if (state.window == 0L){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }


    // turn on double buffering set the depth buffer to 24 bits
    // you may need to change this to 16 or 32 for your system
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);

    state.context = SDL_GL_CreateContext(state.window);
    if (state.context == 0L){
        fprintf(stderr,"SDL error %s\n",SDL_GetError());
        return 1;
    }

    if (!setupCamera(cparam_name, vconf, &gARTCparam)) {
        fprintf(stderr, "main(): Unable to set up AR camera.\n");
        return -1;
    }

    // Load marker(s).
    if (!setupMarker(patt_name, &gPatt_id)) {
        fprintf(stderr, "main(): Unable to set up AR marker.\n");
        return -1;
    }

    // Poll for events, and handle the ones we care about.
    SDL_Event event;
    int running = 1;

    SDL_SetRenderDrawColor(state.renderer, 10, 30, 255, 255);

     glEnable(GL_DEPTH_TEST);

    createBackgroundImage(&state,gsARTImageWidth,gsARTImageHeight);

    while (running) {


        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_KEYDOWN:
                break;
            case SDL_KEYUP:
                // If escape is pressed, return (and thus, quit)
                if (event.key.keysym.sym == SDLK_ESCAPE)
                    return 0;
                break;
            case SDL_QUIT:
                goto cleanup;
            }
        }

        update(&state);

        SDL_GL_SwapWindow(state.window);

    }

cleanup:

    SDL_DestroyTexture(state.background);
    //    SDL_DestroyTexture(state.scene);

    SDL_GL_DeleteContext(state.context);

    SDL_DestroyRenderer(state.renderer);
    SDL_DestroyWindow(state.window);

    return 0;
}