Пример #1
0
void component_texture_set_param(void* handle, unsigned int index, char* value) {
	if (!handle) {
		debug_warning("[component_texture_set_param] handle cannot be NULL");
		return;
	}

	component_texture* this = (component_texture*) handle;

	switch (index) {
	case COMPONENT_TEXTURE_INDEX_ANIMSETFILE:
		component_texture_load_animset(this, value);
		break;
	case COMPONENT_TEXTURE_INDEX_CURRENTANIM:
		{
			int located = -1;

			for (int i = 0; i < COMPONENT_TEXTURE_MAX_ANIM_COUNT; i++) {
				if (!this->texture_anim_names[i]) {
					continue;
				}

				if (!strcmp(this->texture_anim_names[i], value)) {
					located = i;
					break;
				}
			}

			if (located == -1) {
				debug_warning("[component_texture_set_param] no animation found in buffers with name %s", value);
			} else {
				if (this->current_animation != located) {
					this->current_animation = located;
					this->current_frame = 0;
				}
			}
		}

		break;
	case COMPONENT_TEXTURE_INDEX_R:
		this->r = atof(value);
		break;
	case COMPONENT_TEXTURE_INDEX_G:
		this->g = atof(value);
		break;
	case COMPONENT_TEXTURE_INDEX_B:
		this->b = atof(value);
		break;
	}

	for (unsigned int i = 0; i < COMPONENT_TEXTURE_MAX_ANIM_COUNT; i++) {
		if (!this->frame_count[i]) {
			break;
		}

		for (unsigned int frame = 0; frame < this->frame_count[i]; frame++) {
			texture_set_hue(this->texture_buffer[i][frame], this->r, this->g, this->b);
		}
	}
}
static void
streaming_set_buffer_percent(mm_player_streaming_t* streamer, gdouble low_percent, gdouble high_percent)
{
	gdouble buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT;
	gdouble buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT;

	debug_fenter();

	return_if_fail(streamer);

	if (low_percent <= MIN_BUFFER_PERCENT || low_percent >= MAX_BUFFER_PERCENT)
	{
		debug_warning("buffer low percent is out of range. use defaut value.");
		buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT;
	}
	else
	{
		buffer_low_percent = low_percent;
	}

	if (high_percent  <=  MIN_BUFFER_PERCENT || high_percent  >=  MAX_BUFFER_PERCENT)
	{
		debug_warning("buffer high percent is out of range. use defaut value.");
		buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT;
	}
	else
	{
		buffer_high_percent = high_percent;
	}

	if (buffer_high_percent <= buffer_low_percent)
		buffer_high_percent =  buffer_low_percent + 1.0;

	debug_log("set buffer percent to %2.3f ~ %2.3f.",  streamer->buffer_low_percent, streamer->buffer_high_percent);

	if (streamer->buffer)
	{
		if ( streamer->buffer_low_percent != buffer_low_percent )
			g_object_set (G_OBJECT(streamer->buffer), "low-percent", streamer->buffer_low_percent, NULL);

		if ( streamer->buffer_high_percent != buffer_high_percent )
			g_object_set (G_OBJECT(streamer->buffer), "high-percent", streamer->buffer_high_percent, NULL);
	}

	streamer->buffer_low_percent = buffer_low_percent;
	streamer->buffer_high_percent = buffer_high_percent;

	debug_fleave();

	return;
}
Пример #3
0
void sound_manager_free(sound_manager** target) {
	if (target == NULL) {
		debug_warning("[sound_manager_free] target cannot be NULL");
		return;
	}

	if (*target == NULL) {
		debug_warning("[sound_manager_free] target cannot point to NULL");
		return;
	}

	h_free(*target);
	*target = NULL;
}
Пример #4
0
void input_free(input** target) {
	if (target == NULL) {
		debug_warning("[input_free] target cannot be NULL");
		return;
	}

	if (*target == NULL) {
		debug_warning("[input_free] target cannot point to NULL");
		return;
	}

	h_free(*target);
	*target = NULL;
}
Пример #5
0
int sound_manager_alloc(sound_manager** target) {
	if (target == NULL) {
		debug_critical("[sound_manager_alloc] target cannot be NULL");
		return 0;
	}

	if (*target != NULL) {
		debug_warning("[sound_manager_alloc] target points to a non NULL handle, possible memory leak");
	}

	*target = h_malloc(sizeof(sound_manager));

	sound_manager* this = *target;

	this->system_handle = NULL;

	if (FMOD_System_Create(&this->system_handle) != FMOD_OK) {
		debug_critical("[sound_manager_alloc] FMOD failed to allocate sound system");
		h_free(*target);
		*target = NULL;
		return 0;
	}

	if (FMOD_System_Init(this->system_handle, HUNTER_SOUND_MANAGER_CHANNELS, 0, NULL) != FMOD_OK) {
		debug_critical("[sound_manager_alloc] failed to initialize sound system");
		h_free(*target);
		*target = NULL;
		return 0;
	}

	return 1;
}
Пример #6
0
void component_primitive_set_param(void* handle, unsigned int index, char* value) {
	if (!handle) {
		debug_warning("[component_primitive_set_param] handle cannot be NULL");
		return;
	}

	component_primitive* this = (component_primitive*) handle;

	/* We don't have much choice but to reconstruct the primitive upon changing parameters as we cannot dynamically modify GL buffers. */

	switch (index) {
	case COMPONENT_PRIMITIVE_INDEX_WIDTH:
		this->width = atof(value);
		break;
	case COMPONENT_PRIMITIVE_INDEX_HEIGHT:
		this->height = atof(value);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TEXWIDTH:
		this->texwidth = atof(value);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TEXHEIGHT:
		this->texheight = atof(value);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TYPE:
		this->primitive_type = atoi(value);
		break;
	}

	if (this->primitive_handle) {
		primitive_free(&this->primitive_handle);
	}

	primitive_alloc(&this->primitive_handle, this->primitive_type, this->width, this->height, this->texwidth, this->texheight);
}
Пример #7
0
void component_primitive_get_param(void* handle, unsigned int index, char* buffer, int buffer_size) {
	if (!handle) {
		debug_warning("[component_primitive_get_param] handle cannot be NULL");
		return;
	}

	component_primitive* this = (component_primitive*) handle;

	switch (index) {
	case COMPONENT_PRIMITIVE_INDEX_WIDTH:
		snprintf(buffer, buffer_size, "%f", this->width);
		break;
	case COMPONENT_PRIMITIVE_INDEX_HEIGHT:
		snprintf(buffer, buffer_size, "%f", this->height);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TEXWIDTH:
		snprintf(buffer, buffer_size, "%f", this->texwidth);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TEXHEIGHT:
		snprintf(buffer, buffer_size, "%f", this->texheight);
		break;
	case COMPONENT_PRIMITIVE_INDEX_TYPE:
		snprintf(buffer, buffer_size, "%d", this->primitive_type);
		break;
	}
}
int
mm_player_sound_filter_bypass (MMHandleType hplayer)
{
	mm_player_t* player = (mm_player_t*)hplayer;
	int result = MM_ERROR_NONE;
	GstElement *filter_element = NULL;
	debug_fenter();

	return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED);

	if ( !PLAYER_INI()->use_audio_filter_preset && !PLAYER_INI()->use_audio_filter_custom )
	{
		debug_error("sound filter(preset/custom) is not suppported\n");
		return MM_ERROR_NOT_SUPPORT_API;
	}
	if ( !player->pipeline || !player->pipeline->audiobin )
	{
		debug_warning("filter element is not created yet.\n");
	}
	else
	{
		return_val_if_fail( player->pipeline->audiobin, MM_ERROR_PLAYER_NOT_INITIALIZED );
		filter_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;

		/* order action to sound effect plugin */
		g_object_set(filter_element, "filter-action", MM_AUDIO_FILTER_TYPE_NONE, NULL);
		debug_log("filter-action = %d\n", MM_AUDIO_FILTER_TYPE_NONE);
	}

	debug_fleave();
	return result;
}
Пример #9
0
int input_alloc(input** target, window* window_target) {
	if (target == NULL) {
		debug_critical("[input_alloc] target cannot be NULL");
		return 0;
	}

	if (*target != NULL) {
		debug_warning("[input_alloc] target points to non NULL handle");
	}

	if (window_target == NULL) {
		debug_critical("[input_alloc] window_target cannot be NULL");
		return 0;

		/*
		 * NOTE : passing a window pointer is completely unnecessary and will never be used. we use this to force the user to have an existing window
		 * as a way of non-globally asserting that SDL has been initialized
		 */
	}

	*target = h_malloc(sizeof(input));

	input* this = *target;

	this->current_configuration_keyboard = INPUT_DEFAULT_KEYBOARD_CONFIG;
	this->current_configuration_controller = INPUT_DEFAULT_CONTROLLER_CONFIG;
	this->controller_deadzone = INPUT_DEFAULT_CONTROLLER_DEADZONE;
	this->controller_handle = NULL;
	this->controller_enabled = input_get_controller_connected(this);

	this->keyboard_state = SDL_GetKeyboardState(NULL);

	return 1;
}
Пример #10
0
void component_texture_get_param(void* handle, unsigned int index, char* buffer, int buffer_size) {
	if (!handle) {
		debug_warning("[component_texture_get_param] handle cannot be NULL");
		return;
	}

	component_texture* this = (component_texture*) handle;

	switch (index) {
	case COMPONENT_TEXTURE_INDEX_ANIMSETFILE:
		snprintf(buffer, buffer_size, "%s", this->texture_anim_setfile);
		break;
	case COMPONENT_TEXTURE_INDEX_CURRENTANIM:
		snprintf(buffer, buffer_size, "%s", this->texture_anim_names[this->current_animation]);
		break;
	case COMPONENT_TEXTURE_INDEX_R:
		snprintf(buffer, buffer_size, "%f", this->r);
		break;
	case COMPONENT_TEXTURE_INDEX_G:
		snprintf(buffer, buffer_size, "%f", this->g);
		break;
	case COMPONENT_TEXTURE_INDEX_B:
		snprintf(buffer, buffer_size, "%f", this->b);
		break;
	}
}
Пример #11
0
/**
 * Wait for the fence to expire, and remove it from the fenced list.
 *
 * This function will release and re-acquire the mutex, so any copy of mutable
 * state must be discarded after calling it.
 */
static inline enum pipe_error
fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr,
                            struct fenced_buffer *fenced_buf)
{
    struct pb_fence_ops *ops = fenced_mgr->ops;
    enum pipe_error ret = PIPE_ERROR;

#if 0
    debug_warning("waiting for GPU");
#endif

    assert(pipe_is_referenced(&fenced_buf->base.reference));
    assert(fenced_buf->fence);

    if(fenced_buf->fence) {
        struct pipe_fence_handle *fence = NULL;
        int finished;
        boolean proceed;

        ops->fence_reference(ops, &fence, fenced_buf->fence);

        pipe_mutex_unlock(fenced_mgr->mutex);

        finished = ops->fence_finish(ops, fenced_buf->fence, 0);

        pipe_mutex_lock(fenced_mgr->mutex);

        assert(pipe_is_referenced(&fenced_buf->base.reference));

        /*
         * Only proceed if the fence object didn't change in the meanwhile.
         * Otherwise assume the work has been already carried out by another
         * thread that re-aquired the lock before us.
         */
        proceed = fence == fenced_buf->fence ? TRUE : FALSE;

        ops->fence_reference(ops, &fence, NULL);

        if(proceed && finished == 0) {
            /*
             * Remove from the fenced list
             */

            boolean destroyed;

            destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf);

            /* TODO: remove consequents buffers with the same fence? */

            assert(!destroyed);
            (void) destroyed; /* silence unused var warning for non-debug build */

            fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE;

            ret = PIPE_OK;
        }
    }

    return ret;
}
Пример #12
0
void component_health_free(void* handle) {
	if (!handle) {
		debug_warning("[component_health_free] handle cannot be NULL");
		return;
	}

	h_free(handle);
}
Пример #13
0
void component_music_trigger_free(void* handle) {
	if (!handle) {
		debug_warning("[component_music_trigger_free] handle cannot be NULL");
		return;
	}

	h_free(handle);
}
Пример #14
0
int dbg_break(struct Trapframe *ctx)
{
	if (dbg.ctx != NULL)
	{
		debug_warning("nested debugging context not handled!\n");
		return 1;
	}
	if (ctx->tf_trapno == 1)
	{
		if (dbg.cur_bp != NULL)
		{ /* breakpoint fix! */
			*(uint8_t *)dbg.cur_bp->addr = 0xCC;
			dbg.cur_bp = NULL;
			ctx->tf_eflags &= ~FL_TF;
			// TODO unset msrs
		}
		if (dbg.step_trap)
		{
			_dbg_print_ctx(dbg.ctx = ctx);
			dbg.step_trap = 0;
			return dbg_console();
		}
		return 0;
	}
	if (ctx->tf_trapno == 3)
	{
		int n = _get_bpidx_by_addr(ctx->tf_eip - 1);
		if (n != MAX_DEBUGGER_BPS)
		{
			dbg.cur_bp = &dbg.bps[n];
		}
		else
		{
			debug_warning("unknown breakpoint encountered!\n");
			return 1;
		}
		ctx->tf_eflags |= FL_TF; /* set eeflag.tp for fix*/
		--ctx->tf_eip;
		*(uint8_t *)dbg.cur_bp->addr = dbg.cur_bp->origin;
		
		_dbg_print_ctx(dbg.ctx = ctx);
		return dbg_console();
	}
	debug_warning("debugger error!\n");
	return 1;
}
static void
streaming_set_buffer_type (mm_player_streaming_t* streamer, gboolean use_file, gchar * file_path, guint64 content_size)
{
	guint64 storage_available_size = 0L; //bytes
	guint64 file_buffer_size = 0L;  //bytes
	gchar file_buffer_name[MAX_FILE_BUFFER_NAME_LEN] = {0};
	struct statfs buf = {0};

	debug_fenter();

	return_if_fail(streamer && streamer->buffer);

	if (!use_file)
	{
		debug_log("use memory for buffering. streaming is played on push-based. \n"
				"buffering position would not be updated.\n"
				"buffered data would be flushed after played.\n"
				"seeking and getting duration could be failed due to file format.");
		return;
	}

	debug_log("use file for buffering. streaming is played on pull-based. \n");

	if (!file_path || strlen(file_path) <= 0)
		file_path = g_strdup(DEFAULT_FILE_BUFFER_PATH);

	sprintf( file_buffer_name, "%s/XXXXXX", file_path );
	debug_log("the buffering file name is %s.\n", file_buffer_name);

	if (statfs((const char *)file_path, &buf) < 0)
	{
		debug_warning ("fail to get availabe storage capacity. just use file buffer.\n");
		file_buffer_size = 0L;
	}
	else
	{
		storage_available_size = (guint64)buf.f_bavail * (guint64)buf.f_bsize; //bytes

		debug_log ("the number of available blocks : %"G_GUINT64_FORMAT", the block size is %"G_GUINT64_FORMAT".\n",
			(guint64)buf.f_bavail, (guint64)buf.f_bsize);
		debug_log ("calculated availabe storage size is %"G_GUINT64_FORMAT" Bytes.\n", storage_available_size);

		if (content_size <= 0 || content_size >= storage_available_size)
			file_buffer_size = storage_available_size;
		else
			file_buffer_size = 0L;
	}

	if (file_buffer_size>0)
		debug_log("use file ring buffer for buffering.");

	g_object_set (G_OBJECT(streamer->buffer), "temp-template", file_buffer_name, NULL);
	g_object_set (G_OBJECT(streamer->buffer), "file-buffer-max-size", file_buffer_size, NULL);

	debug_fleave();

	return;
}
Пример #16
0
/**
 * Called by the st manager to validate the framebuffer (allocate
 * its resources).
 */
static boolean
osmesa_st_framebuffer_validate(struct st_context_iface *stctx,
                               struct st_framebuffer_iface *stfbi,
                               const enum st_attachment_type *statts,
                               unsigned count,
                               struct pipe_resource **out)
{
    struct pipe_screen *screen = get_st_manager()->screen;
    enum st_attachment_type i;
    struct osmesa_buffer *osbuffer = stfbi_to_osbuffer(stfbi);
    struct pipe_resource templat;

    memset(&templat, 0, sizeof(templat));
    templat.target = PIPE_TEXTURE_RECT;
    templat.format = 0; /* setup below */
    templat.last_level = 0;
    templat.width0 = osbuffer->width;
    templat.height0 = osbuffer->height;
    templat.depth0 = 1;
    templat.array_size = 1;
    templat.usage = PIPE_USAGE_DEFAULT;
    templat.bind = 0; /* setup below */
    templat.flags = 0;

    for (i = 0; i < count; i++) {
        enum pipe_format format = PIPE_FORMAT_NONE;
        unsigned bind = 0;

        /*
         * At this time, we really only need to handle the front-left color
         * attachment, since that's all we specified for the visual in
         * osmesa_init_st_visual().
         */
        if (statts[i] == ST_ATTACHMENT_FRONT_LEFT) {
            format = osbuffer->visual.color_format;
            bind = PIPE_BIND_RENDER_TARGET;
        }
        else if (statts[i] == ST_ATTACHMENT_DEPTH_STENCIL) {
            format = osbuffer->visual.depth_stencil_format;
            bind = PIPE_BIND_DEPTH_STENCIL;
        }
        else if (statts[i] == ST_ATTACHMENT_ACCUM) {
            format = osbuffer->visual.accum_format;
            bind = PIPE_BIND_RENDER_TARGET;
        }
        else {
            debug_warning("Unexpected attachment type in "
                          "osmesa_st_framebuffer_validate()");
        }

        templat.format = format;
        templat.bind = bind;
        out[i] = osbuffer->textures[statts[i]] =
                     screen->resource_create(screen, &templat);
    }

    return TRUE;
}
Пример #17
0
void framebuffer_free(framebuffer** target) {
	if (!target) {
		debug_warning("[framebuffer_free] target cannot be NULL");
		return;
	}

	if (!*target) {
		debug_warning("[framebuffer_free] target cannot point to NULL");
		return;
	}

	glDeleteTextures(1, &(*target)->texture);
	glDeleteFramebuffers(1, &(*target)->fb);
	glDeleteRenderbuffers(1, &(*target)->renderbuffer);

	h_free(*target);
	*target = NULL;
}
Пример #18
0
static void _dbg_print_bp(int n, int print_empty)
{
	if (n >= MAX_DEBUGGER_BPS)
	{
		debug_warning("try printing breakpoint out of bound!\n");
	}
	else if (print_empty || dbg.bps[n].valid)
	{
		cprintf("breakpoint #%d(%s):0x%08x\n", n, dbg.bps[n].valid ? "active" : "inactive",dbg.bps[n].addr);
	}
}
Пример #19
0
GLAPI void GLAPIENTRY
OSMesaPostprocess(OSMesaContext osmesa, const char *filter,
                  unsigned enable_value)
{
    if (!osmesa->ever_used) {
        /* We can only enable/disable postprocess filters before a context
         * is made current for the first time.
         */
        unsigned i;

        for (i = 0; i < PP_FILTERS; i++) {
            if (strcmp(pp_filters[i].name, filter) == 0) {
                osmesa->pp_enabled[i] = enable_value;
                return;
            }
        }
        debug_warning("OSMesaPostprocess(unknown filter)\n");
    }
    else {
        debug_warning("Calling OSMesaPostprocess() after OSMesaMakeCurrent()\n");
    }
}
Пример #20
0
unsigned int component_type_get_param_index(const component_type* type, char* key) {
	unsigned int index = 0;
	const char* current_key = type->component_param_names[index];

	while (current_key) {
		if (!strcmp(type->component_param_names[index++], key)) {
			return index - 1;
		}
	}

	debug_warning("[component_type_get_param_index] no parameter %s found in component type %s", key, type->component_name);
	return 0;
}
/* check the given path is indicating sdp file */
bool 
util_is_sdp_file ( const char *path )
{
	gboolean ret = FALSE;
	gchar* uri = NULL;
	
	debug_fenter();
	
	return_val_if_fail ( path, FALSE );

	uri = g_ascii_strdown ( path, -1 );

	/* trimming */
	g_strstrip( uri );

	/* strlen(".sdp") == 4 */
	if ( strlen( uri ) <= 4 )
	{
		debug_warning ( "path is too short.\n" );
		return ret;
	}

	/* first, check extension name */
	ret = g_str_has_suffix ( uri, "sdp" );

	/* second, if no suffix is there, check it's contents */
	if ( ! ret )
	{
		/* FIXIT : do it soon */
		debug_warning("determining whether it's sdp or not with it's content is not implemented yet. ;)\n");
	}

	if ( uri )
		g_free( uri); 
	uri = NULL;

	return ret;
}
Пример #22
0
void component_music_trigger_get_param(void* handle, unsigned int index, char* buffer, int buffer_size) {
	if (!handle) {
		debug_warning("[component_music_trigger_get_param] handle cannot be NULL");
		return;
	}

	component_music_trigger* this = (component_music_trigger*) handle;

	switch (index) {
	case COMPONENT_MUSIC_TRIGGER_INDEX_TRACKNAME:
		snprintf(buffer, buffer_size, "%s", this->original_sound);
		break;
	}
}
Пример #23
0
void component_primitive_free(void* handle) {
	if (!handle) {
		debug_warning("[component_primitive_free] handle cannot be NULL");
		return;
	}

	component_primitive* this = (component_primitive*) handle;

	if (this->primitive_handle) {
		primitive_free(&this->primitive_handle);
	}

	h_free(handle);
}
Пример #24
0
void component_health_get_param(void* handle, unsigned int index, char* buffer, int buffer_size) {
	if (!handle) {
		debug_warning("[component_health_get_param] handle cannot be NULL");
		return;
	}

	component_health* this = (component_health*) handle;

	switch (index) {
	case COMPONENT_HEALTH_INDEX_HEALTH:
		snprintf(buffer, buffer_size, "%f", this->health);
		break;
	}
}
Пример #25
0
void component_health_set_param(void* handle, unsigned int index, char* buffer) {
	if (!handle) {
		debug_warning("[component_health_set_param] handle cannot be NULL");
		return;
	}

	component_health* this = (component_health*) handle;

	switch (index) {
	case COMPONENT_HEALTH_INDEX_HEALTH:
		this->health = atof(buffer);
		break;
	}
}
Пример #26
0
static void _dbg_print_ctx(struct Trapframe *ctx)
{
	t_disasm da;
	if (ctx->tf_trapno == 3)
	{
		cprintf("breakpoint #%d @ %08x\n",_get_bpidx_by_addr(dbg.cur_bp->addr), dbg.cur_bp->addr);
	}
	else if (ctx->tf_trapno == 1)
		;
	else
		debug_warning("why send it to debugger??\n");
	ideal=0; lowercase=1; putdefseg=0;
	Disasm((char *)ctx->tf_eip, ctx->tf_eip, 0,&da,DISASM_CODE);
	cprintf("%08x  %-24s  %-24s\n", ctx->tf_eip, da.dump, da.result);
}
Пример #27
0
void component_music_trigger_set_param(void* handle, unsigned int index, char* value) {
	if (!handle) {
		debug_warning("[component_music_trigger_set_param] handle cannot be NULL");
		return;
	}

	component_music_trigger* this = (component_music_trigger*) handle;
	sound_map* sound_map_handle = global_get(global_get_singleton(), GLOBAL_SOUND_MAP);

	switch (index) {
	case COMPONENT_MUSIC_TRIGGER_INDEX_TRACKNAME:
		{
			this->target_sound = sound_map_get(sound_map_handle, value);

			if (!this->target_sound) {
				debug_warning("[component_music_trigger_set_param] no sound located at index %s", value);
			} else {
				snprintf(this->original_sound, COMPONENT_MUSIC_TRIGGER_STORE_LENGTH, "%s", value);
			}
		}

		break;
	}
}
bool util_check_valid_url ( const char *proxy )
{
	struct in_addr proxy_addr;
	bool ret = TRUE;
	
	return_val_if_fail ( proxy, FALSE );
	return_val_if_fail ( strlen(proxy), FALSE );

       if ( inet_aton(proxy, &proxy_addr) != 0 )
	{
		debug_warning("invalid proxy is set. \n");
		ret = FALSE;
	}
	   
	return ret;
}
Пример #29
0
int framebuffer_alloc(framebuffer** target, unsigned int width, unsigned int height) {
	if (!target) {
		debug_critical("[framebuffer_alloc] target cannot be NULL");
		return 0;
	}

	if (*target) {
		debug_warning("[framebuffer_alloc] target points to non NULL handle, possible memory leak");
	}

	if (!width && !height) {
		width = window_get_width(global_get(global_get_singleton(), GLOBAL_WINDOW));
		height = window_get_height(global_get(global_get_singleton(), GLOBAL_WINDOW));
	}

	framebuffer* output = h_malloc(sizeof(framebuffer));

	glGenFramebuffers(1, &output->fb);
	glBindFramebuffer(GL_FRAMEBUFFER, output->fb);

	glGenTextures(1, &output->texture);
	glBindTexture(GL_TEXTURE_2D, output->texture);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glGenRenderbuffers(1, &output->renderbuffer);
	glBindRenderbuffer(GL_RENDERBUFFER, output->renderbuffer);

	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
	glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, output->renderbuffer);

	glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, output->texture, 0);

	GLenum buffers[] = {GL_COLOR_ATTACHMENT0};
	glDrawBuffers(1, buffers);

	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
		debug_critical("[framebuffer_alloc] failed to create framebuffer");
		return 0;
	}

	*target = output;

	return 1;
}
Пример #30
0
void controller::loadFromMemory(void *data, int size)
{
	int keysize=keys->keySize(); 
	int num,i;
	char *dataoffs=(char *)data;

	if (size%(keysize+4)!=0) debug_warning(0,"Controller can't load data (data size error)");
	num=size/(keysize+4);

	keys->keyClear();
	for (i=0;i<num;i++)
	{
		char *tmpdata=new char[keysize];
		memcpy(tmpdata,dataoffs+4,keysize);
		keys->keyAdd(*(int *)(dataoffs),tmpdata);
		dataoffs+=keysize+4;
	}
}