/* ================= r_list_textures_f ================= */ static void r_list_textures_f (GNUC_UNUSED const struct cmd_s *cmd, int source, GNUC_UNUSED int argc, GNUC_UNUSED const char **argv) { struct sglib_r_texture_t_iterator it; const r_texture_t *tex; if (source == CMD_SRC_KEY_UP) return; sys_printf("----------- textures list -----------\n"); for (tex = sglib_r_texture_t_it_init(&it, textures); NULL != tex; tex = sglib_r_texture_t_it_next(&it)) { sys_printf("texture: %p name=%s type=%i ref=%i w=%i h=%i texw=%-2.2lf texh=%-2.2lf\n", tex, tex->name, tex->type, tex->ref, tex->w, tex->h, tex->texw, tex->texh); } }
/* ================= mem_debug ================= */ void mem_debug (void) { uint32_t pool_allocs; pool_t *p; alloc_t *a; for (p = pools; NULL != p ;p = p->next) { sys_printf(">>> pool \"%s\" (%s - %s:%i): size=%u, size_real=%u, max=%u\n", p->name, p->func, p->file, p->line, p->size, p->size_real, p->size_max); for (pool_allocs = 0, a = p->allocs; NULL != a ;a = a->next, pool_allocs++) { sys_printf(" alloc %p: size=%u\n", a, a->size); } sys_printf("<<< %u allocs in \"%s\"\n", pool_allocs, p->name); } }
int sar_CheckPacket(arp_Header *ap) { register arp_Header *op; if ( ap->hwType != wfix(arp_TypeEther) || /* have ethernet hardware, */ ap->protType != wfix(0x800) || /* and internet software, */ ap->opcode != wfix(ARP_REQUEST) || /* and be a resolution req. */ ap->dstIPAddr != lfix(sin_lclINAddr) /* for my addr. */ ) return ( 0 ); /* .... or we ignore it. */ #if CPMAC_DEBUG sys_printf("ARP REQUEST IS VALID\n"); #endif /* format response. */ op = (arp_Header *)sed_FormatPacket(ap->srcEthAddr, 0x806); op->hwType = wfix(arp_TypeEther); op->protType = wfix(0x800); op->hwProtAddrLen = wfix((sizeof(eth_HwAddress) << 8) + sizeof(in_HwAddress)); op->opcode = wfix(ARP_REPLY); op->srcIPAddr = lfix(sin_lclINAddr); MoveW(sed_lclEthAddr, op->srcEthAddr, sizeof(eth_HwAddress)); ap->dstIPAddr = op->srcIPAddr; MoveW(ap->srcEthAddr, op->dstEthAddr, sizeof(eth_HwAddress)); sed_Send(sizeof(arp_Header)); #if CPMAC_DEBUG sys_printf("ARP RESPONSE SENT\n"); #endif return ( 1 ); }
/* ================= fs_helpers_apple_init ================= */ erbool fs_helpers_apple_init (void) { CFURLRef url; if (NULL == (cg_main_bundle = CFBundleGetMainBundle())) { sys_printf("CFBundleGetMainBundle failed\n"); return false; } if (NULL == (url = CFBundleCopyResourcesDirectoryURL(cg_main_bundle))) { sys_printf("CFBundleCopyResourcesDirectoryURL failed\n"); CFRelease(cg_main_bundle); return false; } fs_get_documents_path(paths[0].path, sizeof(paths[0].path)); paths[0].valid = 1; paths[0].rdonly = 0; CFURLGetFileSystemRepresentation(url, true, (unsigned char *)paths[1].path, sizeof(paths[1].path)); CFRelease(url); paths[1].valid = 1; paths[1].rdonly = 1; paths[2].valid = paths[3].valid = 0; return true; }
/* ================= snd_wav_get_wav_info ================= */ GNUC_NONNULL static erbool snd_wav_get_wav_info (const uint8_t *buffer, int size, wav_info_t *wav) { const uint8_t *b = buffer; int s = size; const uint8_t *b2 = buffer; int s2 = size; if (size < 40) return false; if (!snd_wav_find_chunk(&b, &s, "RIFF") || !snd_wav_find_chunk(&b, &s, "WAVE") || !snd_wav_find_chunk(&b, &s, "fmt ")) { sys_printf("RIFF/WAVE/fmt chunks are missing\n"); return false; } if (s < 32) { sys_printf("invalid wav file\n"); return false; } b += 4; wav->format = LITTLESHORT2(b); wav->channels = LITTLESHORT2(b); wav->rate = LITTLELONG2(b); b += 6; wav->bps = LITTLESHORT2(b); if (!snd_wav_find_chunk(&b2, &s2, "data")) { sys_printf("data chunk is missing\n"); return false; } if (s2 < 8) { sys_printf("invalid wav file\n"); return false; } wav->data_size = LITTLELONG2(b2); wav->data_start = b2 - buffer; if (wav->data_size < 1) { sys_printf("wav data size < 1\n"); return false; } return true; }
/* ================= mem_free ================= */ void mem_free_real (void *m #ifdef ENGINE_MEM_DEBUG , const char *file, const char *func, int line #endif /* ENGINE_MEM_DEBUG */ ) { alloc_t *i; alloc_t *a = m - sizeof(alloc_t); if (SEN1_ALLOC != a->sen1) { sys_printf("broken sen1 in alloc (%p)\n", a); #ifdef ENGINE_MEM_DEBUG sys_printf("alloc was done at %s - %s:%i, t=%.5lf\n", a->func, a->file, a->line, a->time); sys_printf("tried to free memory at %s - %s:%i\n", func, file, line); #endif /* ENGINE_MEM_DEBUG */ return; } if (SEN2_ALLOC != *((uint32_t *)(a->data + a->size))) { sys_printf("broken sen2 in alloc (%p)\n", a); #ifdef ENGINE_MEM_DEBUG sys_printf("alloc was done at %s - %s:%i, t=%.5lf\n", a->func, a->file, a->line, a->time); sys_printf("tried to free memory at %s - %s:%i\n", func, file, line); #endif /* ENGINE_MEM_DEBUG */ return; } for (i = a->pool->allocs; NULL != i ;i = i->next) { if (a == i) { if (NULL == a->prev) a->pool->allocs = a->next; if (NULL != a->next) a->next->prev = a->prev; if (NULL != a->prev) a->prev->next = a->next; a->pool->size -= a->size; a->pool->size_real -= sizeof(*a) + a->size + sizeof(uint32_t); free(a); return; } } sys_printf("alloc (%p) wasn\'t found in pool \"%s\"\n", a, a->pool->name); #ifdef ENGINE_MEM_DEBUG sys_printf("alloc was done at %s - %s:%i, t=%.5lf\n", a->func, a->file, a->line, a->time); sys_printf("tried to free memory at %s - %s:%i\n", func, file, line); #endif /* ENGINE_MEM_DEBUG */ }
int main(void) { // uint32_t err_code; APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); ble_stack_init(); sys_Initialize(); sys_Timer_Handler_Init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); sec_params_init(); sys_printf("Gift Air Project Start\n\r"); advertising_start(); sys_Timer_Handler_Start(); NRF_WDT->RR[0] = WDT_RR_RR_Reload; //Reload watchdog register 0 // Enter main loop for (;;) { power_manage(); //2sec, 200ms } }
void append_signal (struct shim_thread * thread, int sig, siginfo_t * info) { struct shim_signal * signal = malloc(sizeof(struct shim_signal)); if (!signal) return; /* save in signal */ if (info) { __store_info(info, signal); signal->context_stored = false; } else { memset(signal, 0, sizeof(struct shim_signal)); } struct shim_signal ** signal_log = allocate_signal_log(thread, sig); if (signal_log) { *signal_log = signal; debug("resuming thread %u\n", thread->tid); DkThreadResume(thread->pal_handle); } else { sys_printf("signal queue is full (TID = %u, SIG = %d)\n", thread->tid, sig); free(signal); } }
void eeprom::init() { _if->getInterface()->select(); // first 2 uint8_ts is EEPROM checksum uint16_t stored_crc; _if->read(0x000, reinterpret_cast<uint8_t*>(&stored_crc), 2); // rest is data _if->read(0x002, eepBuf, EEPROM_SIZE); uint16_t calculated_crc = crc16(eepBuf, 0, EEPROM_SIZE); if (stored_crc != calculated_crc) { sys_printf("EEPROM reset\n"); reset(); } else sys_printf("EEPROM has valid CRC 0x%04X\n", calculated_crc); }
void sysjoy_init(void) { U8 i, jcount; if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { IFDEBUG_JOYSTICK( sys_printf("xrick/joystick: can not initialize joystick subsystem\n"); );
/*----------------------------------------------------------------------------*/ void sys_power_down(void) { sys_printf("---sys_power_down"); Mute_Ext_PA(MUTE); delay_10ms(2); EA = 0; power_ctl(0); while (1); }
/* ================= echo_f ================= */ static void echo_f (GNUC_UNUSED const struct cmd_s *cmd, GNUC_UNUSED int source, int argc, PUV const char **argv) { if (argc < 2) return; /* FIXME -- console printf should be used */ sys_printf("%s\n", argv[1]); }
// Context of calling process is in current_process // EAX always has the system call number void execute_0x94(void) { switch (current_process->cpu.eax) { case SYSCALL_GETC: _0x94_getc(); break; case SYSCALL_PRINTF: _0x94_printf(); break; default: sys_printf("No match"); break; } }
void eeprom::sync() { sys_printf("eeprom::sync();\n"); _if->getInterface()->select(); uint16_t stored_crc; _if->read(0x000, reinterpret_cast<uint8_t*>(&stored_crc), 2); uint16_t crc = crc16(eepBuf, 0, EEPROM_SIZE); if (crc != stored_crc) { // update if needed only _if->write(0x000, reinterpret_cast<uint8_t*>(&crc), 2); _if->write(0x002, eepBuf, EEPROM_SIZE); } }
int sys_setpermenv(const char *env_nm, const char *env_val) { if( ( !env_nm ) || ( !env_val ) ) return SBL_EFAILURE; #ifndef _STANDALONE if( IsReadOnlyVar( env_nm ) ) { sys_printf(envErrReadOnly, env_nm); return SBL_SUCCESS; } #endif return __sys_setpermenv(env_nm, env_val); }
/*----------------------------------------------------------------------------*/ void stop_decode(void) { Mute_Ext_PA(MUTE); play_status = MUSIC_STOP; //main_vol_set(0, CHANGE_VOL_NO_MEM);//digital_fade_out(); read_usb_remain_data(); disable_decode_isr(); disable_softint(); cfilenum = 0; #ifdef MP3_UART_ENABLE sys_printf(" STOP DECODE "); #endif }
/*----------------------------------------------------------------------------*/ void decode_play(void) { #ifdef MP3_UART_ENABLE sys_printf(" SYS GO IN DECODE MODE"); #endif Mute_Ext_PA(MUTE); disp_play_filenum_timer=10; folder_select=0; folder_mode_select=0; rtc_setting=0; disp_scenario = DISP_NORMAL; Disp_Con(DISP_SCAN_DISK); sysclock_div2(1); #ifndef NO_SD_DECODE_FUNC sd_speed_init(0, 50); #endif decodeclock_div2(DECODE_CLK_DIV2); //decoder分频,可以减少功耗 music_info_init(); dsp_hi_pro(); decodeint_hi_pro(); device_active = 0; put_msg_lifo(SEL_GIVEN_DEVICE_GIVEN_FILE); set_max_vol(MAX_ANALOG_VOL-DECODE_ANALOG_VOL_CUT, MAX_DIGITAL_VOL); //设置Music模式的音量上限 //suspend_sdmmc(); music_play(); Mute_Ext_PA(MUTE); #ifdef ADKEY_SELECT_MODE mode_switch_protect_bit=1; #endif disp_scenario = DISP_NORMAL; folder_select=0; folder_mode_select=0; stop_decode(); #ifdef USE_USB_PROG_PLAY_MODE usb_prog_mode_cls(); #endif #if(MEMORY_STYLE != USE_DEVICE) usb_suspend(); //Entered Suspend mode #endif write_playtime(&playpoint_time); //记录断点信息(EEPROM) main_vol_set(0, CHANGE_VOL_NO_MEM); }
/* ================= g_fields_set_default_values ================= */ void g_fields_set_default_values (void *data, const g_field_t *fields) { const g_field_t *f; for (f = fields; NULL != f->name ;f++) { void *field; if (G_FIELD_TYPE_CUSTOM_CALLBACK == f->type) continue; field = data + f->offset; switch (f->type) { case G_FIELD_TYPE_DOUBLE: *(double *)field = f->default_value.DOUBLE; break; case G_FIELD_TYPE_INTEGER: *(int *)field = f->default_value.INTEGER; break; case G_FIELD_TYPE_VECTOR: if (NULL != f->default_value.VECTOR) { ((double *)field)[0] = f->default_value.VECTOR[0]; ((double *)field)[1] = f->default_value.VECTOR[1]; ((double *)field)[2] = f->default_value.VECTOR[2]; } break; case G_FIELD_TYPE_STRING: case G_FIELD_TYPE_STRING_COPY: /* NULL by default */ break; case G_FIELD_TYPE_ERBOOL: *(erbool *)field = f->default_value.ERBOOL; break; default: sys_printf("unknown field type %i (%p->%i)\n", f->type, data, f->offset); break; } } }
/* ================= r_texture_unload ================= */ void r_texture_unload (r_texture_t *tex) { if (NULL == tex) { sys_printf("NULL tex\n"); return; } /* check the reference counter */ if (--tex->ref > 0) return; gl_texture_delete(tex->gltex); sglib_r_texture_t_delete(&textures, tex); mem_free(tex); }
void lcd_ht1621_init(void) { LCD_spi_gpio_Init(); lcd_backlight_ctrl(TRUE); Ht1621_Delay(HT1621_INI_DELAY); //延时使LCD工作电压稳定 Ht1621_Wr_Cmd(HT1621_BIAS); Ht1621_Wr_Cmd(HT1621_RC256); //使用内部振荡器 Ht1621_Wr_Cmd(HT1621_SYSDIS); Ht1621_Wr_Cmd(HT1621_WDTDIS); Ht1621_Wr_Cmd(HT1621_SYSEN); Ht1621_Wr_Cmd(HT1621_LCDON); //Ht1621_Wr_Cmd(HT1621_LCDOFF); disp_buf_clear(); sys_printf(" lcd_ht1621_init "); }
/* * Chain (sub)maps * * ASM 0c08 * return: TRUE/next submap OK, FALSE/map finished */ U8 map_chain(void) { U16 c, t; game_chsm = 0; e_sbonus_counting = FALSE; /* find connection */ c = map_submaps[game_submap].connect; t = 3; IFDEBUG_MAPS( sys_printf("xrick/maps: chain submap=%#04x frow=%#04x .connect=%#04x %s\n", game_submap, map_frow, c, (game_dir == LEFT ? "-> left" : "-> right")); );
int sys_setenv(const char *env_nm, const char *env_val) { if( ( !env_nm ) || ( !env_val ) ) return SBL_EFAILURE; /* * CPUFREQ and SYSFREQ should not be modified */ #ifndef _STANDALONE if( IsReadOnlyVar( env_nm ) ) { sys_printf(envErrReadOnly, env_nm); return SBL_SUCCESS; } #endif return __sys_setenv(env_nm, env_val, FALSE); }
void deliver_signal (siginfo_t * info, PAL_CONTEXT * context) { shim_tcb_t * tcb = SHIM_GET_TLS(); struct shim_thread * cur_thread = (struct shim_thread *) tcb->tp; int sig = info->si_signo; __disable_preempt(tcb); struct shim_signal * signal = __alloca(sizeof(struct shim_signal)); /* save in signal */ memset(signal, 0, sizeof(struct shim_signal)); __store_info(info, signal); __store_context(tcb, context, signal); if ((tcb->context.preempt & ~SIGNAL_DELAYED) > 1) goto delay; if (__sigismember(&cur_thread->signal_mask, sig)) goto delay; __handle_signal(tcb, sig, &signal->context); __handle_one_signal(tcb, sig, signal); goto out; delay: { if (!(signal = remalloc(signal,sizeof(struct shim_signal)))) goto out; struct shim_signal ** signal_log = allocate_signal_log(cur_thread, sig); if (!signal_log) { sys_printf("signal queue is full (TID = %u, SIG = %d)\n", tcb->tid, sig); free(signal); goto out; } *signal_log = signal; } out: __enable_preempt(tcb); }
static void suspend_upcall (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context) { if (IS_INTERNAL_TID(get_cur_tid())) goto ret_exception; if (ask_for_checkpoint) { int ans = message_confirm("checkpoint execution " "(\'k\' to kill the process)", "yk"); if (ans == 'K' || ans == 'k') goto kill; if (ans != 'Y' && ans != 'y') goto ret_exception; shim_tcb_t * tcb = SHIM_GET_TLS(); assert(tcb && tcb->tp); struct shim_signal signal; __store_context(tcb, context, &signal); IDTYPE session = 0; char cpdir[20]; if (create_dir("checkpoint-", cpdir, 20, NULL) < 0) goto ret_exception; sys_printf("creating checkpoint \"%s\"...\n", cpdir); if (create_checkpoint(cpdir, &session) < 0) goto ret_exception; ipc_checkpoint_send(cpdir, session); kill_all_threads(tcb->tp, CHECKPOINT_REQUESTED, SIGINT); join_checkpoint(tcb->tp, &signal.context); goto ret_exception; } kill: deliver_signal(ALLOC_SIGINFO(SIGINT, si_pid, 0), NULL); ret_exception: DkExceptionReturn(event); }
/*----------------------------------------------------------------------------*/ void music_decode(void) { sys_printf(" ------------------------------------>music_decode "); #ifdef AC_SLAVE_ENABLE DSA_init(); #endif dev_remov_timer=0; play_mode = REPEAT_OFF; disk_toc_ok=0; dev_invalid=0; input_number_en = 1; //允许数字输入功能 vol_change_en=1; key_voice_en=1; main_menu = MENU_MUSIC_MAIN; dec_msg = get_dec_msg_ptr(); fat_ptr1.buf = win_buffer; SYSTEM_CLK_DIV1(); //sd_speed_init(0, 100); key_table_sel(0); flush_all_msg(); music_info_init(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 if(DSA_SEL_DEV==DEVICE_SDMMC0){ given_device = DEVICE_SDMMC0; } else if(DSA_SEL_DEV==DEVICE_UDISK){ given_device = DEVICE_UDISK; } //put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); music_play(); //delay_10ms(3); stop_decode(); usb_suspend(); //Entered Suspend Mode key_voice_en=0; main_vol_set(0, CHANGE_VOL_NO_MEM); given_device = NO_DEVICE; }
/*** Process a command typed by the user ***/ uint8_t process_command(char *cmd_buffer, uint16_t cmd_length) { char *cmd = cmd_buffer; char *args = cmd_buffer; uint16_t i; uint8_t status = 0; // success // separate command and arguments (if any) for (i=0; args[0]!=' ' && args[0]!=0; i++,args++); *args = 0; // command word ends here in the buffer if (i<cmd_length) args++; // arguments start next, if any // help if (strcmp(cmd,"help")==0) { if (*args != 0) puts("No such help available.\n"); else puts("You are running a really Simple-OS.\n"); } // cls: clear the screen else if (strcmp(cmd,"cls")==0) { if (*args != 0) puts("cls: What to do with the arguments?\n"); else cls(); } // shutdown else if (strcmp(cmd,"shutdown")==0) { if (*args != 0) puts("shutdown: What to do with the arguments?\n"); else { puts("You really had to do that...SYSTEM HALTED!!\n"); status = 0xFF; // halt the system } } // diskdump: see disk content on screen else if (strcmp(cmd,"diskdump")==0) { command_diskdump(args); } // run: run a program sequentially else if (strcmp(cmd,"run")==0) { command_run(args); } // unknown command else if (cmd[0]!=0) { sys_printf("%s: Command not found.\n",cmd); } return status; }
/* ================= mem_alloc_pool ================= */ mem_pool_t mem_alloc_pool_real (const char *name, uint32_t max_size #ifdef ENGINE_MEM_DEBUG , const char *file, const char *func, int line #endif /* ENGINE_MEM_DEBUG */ ) { pool_t *p; if (NULL == (p = malloc(sizeof(*p)))) { sys_printf("no memory for pool\n"); return NULL; } memset(p, 0, sizeof(*p)); strlcpy(p->name, name, sizeof(p->name)); p->sen1 = SEN1_POOL; p->size_real = sizeof(*p); p->size_max = max_size; #ifdef ENGINE_MEM_DEBUG p->file = file; p->func = func; p->line = line; #endif /* ENGINE_MEM_DEBUG */ if (NULL != pools) { pools->prev = p; p->next = pools; } pools = p; return p; }
/*----------------------------------------------------------------------------*/ void disk_remove_deal_for_music(void) { // if ((device_check() == 0))//当前播放设备已经不在线,则自动选取下一个设备 { #if 1 //Set_Curr_Func(SYS_IDLE); // put_msg_lifo(MSG_CHANGE_WORK_MODE); #else given_device = DEVICE_AUTO_NEXT; given_file_method = PLAY_BREAK_POINT; put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); #endif sys_printf(" -------------------------------------> disk_remove_deal_for_music "); if ( (play_status == MAD_PAUSE) || (play_status == MAD_PLAY) ) backup_music_point(); //记录断点信息 } }
/* * Scroll up * */ U8 scroll_up(void) { U8 i, j; static U8 n = 0; /* last call: restore */ if (n == 8) { n = 0; game_period = period; return SCROLL_DONE; } /* first call: prepare */ if (n == 0) { period = game_period; game_period = SCROLL_PERIOD; } /* translate map */ for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++) for (j = 0x00; j < 0x20; j++) map_map[i][j] = map_map[i + 1][j]; /* translate entities */ for (i = 0; ent_ents[i].n != 0xFF; i++) { if (ent_ents[i].n) { ent_ents[i].ysave -= 8; ent_ents[i].trig_y -= 8; ent_ents[i].y -= 8; if (ent_ents[i].y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */ IFDEBUG_SCROLLER( sys_printf("xrick/scroller: entity %#04X is gone\n", i); ); ent_ents[i].n = 0; }
/* ================= gl_texture_create ================= */ erbool gl_texture_create (image_t *image, int flags, int *gltex, int *texw, int *texh) { int max, sw, sh, mip; GLuint tex; if (NULL == image || NULL == gltex || NULL == texw || NULL == texh) { sys_printf("bad args (image=%p, flags=%i, gltex=%p, texw=%p, texh=%p)\n", image, flags, gltex, texw, texh); return false; } if (flags & GL_TEX_FL_TEX3D) { max = gl_texture3d_size_max; } else if (flags & GL_TEX_FL_CUBEMAP) { max = gl_texture_cube_map_size_max; } else { max = gl_max_texture_size; } if (GL_TEX_FL_NOPICMIP) { sw = CLAMP(image->width, 1, max); sh = CLAMP(image->height, 1, max); } else { sw = CLAMP(image->width >> gl_picmip->i, 1, max); sh = CLAMP(image->height >> gl_picmip->i, 1, max); } if (!ext_gl_arb_texture_non_power_of_two || !gl_arb_texture_non_power_of_two->i) { sw = ceil_pwrov2(sw); sh = ceil_pwrov2(sh); } sw = CLAMP(sw, GL_MIN_TEXTURE_DIMENSION, max); sh = CLAMP(sh, GL_MIN_TEXTURE_DIMENSION, max); if (flags & GL_TEX_FL_NOSCALE) { *texw = sw; *texh = sh; if (!image_resize(image, sw, sh)) return false; } else { *texw = image->width; *texh = image->height; if (!image_scale(image, sw, sh)) return false; } glGenTextures(1, &tex); GLERROR(); eglBindTexture(GL_TEXTURE_2D, tex); GLERROR(); *gltex = tex; if (NULL != image->teximage2d) { image->teximage2d(image); } else { if (ext_gl_sgis_generate_mipmap && gl_sgis_generate_mipmap->i) { #ifdef ENGINE_OS_IPHONE glGenerateMipmapOES(GL_TEXTURE_2D); #else glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); #endif GLERROR(); GL_IMAGE_DATA2D(0, image); GLERROR(); } else { GL_IMAGE_DATA2D(0, image); GLERROR(); for (mip = 1; image->width > 1 || image->height > 1 ; mip++) { int status; if (0 > (status = image_mipmap(image))) { sys_printf("mipmap failed\n"); goto error; } else if (status > 0) { break; } GL_IMAGE_DATA2D(mip, image); GLERROR(); } } } if (flags & GL_TEX_FL_NOFILTER) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); GLERROR(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GLERROR(); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_trilinear->i ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR_MIPMAP_NEAREST); GLERROR(); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLERROR(); } if (!(flags & GL_TEX_FL_NOANISO) && ext_gl_ext_texture_filter_anisotropic && gl_ext_texture_filter_anisotropic->i) { GLfloat ani = CLAMP(gl_anisotropy_level->f, 1, gl_anisotropy_max); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, ani); GLERROR(); } if (!(flags & GL_TEX_FL_NOLOD) && ext_gl_ext_texture_lod_bias && gl_ext_texture_lod_bias->i) { GLfloat lod = CLAMP(gl_lod_bias->f, 0, gl_lod_bias_max); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS_EXT, lod); GLERROR(); } return true; error: glDeleteTextures(1, &tex); GLERROR(); return false; }