/* * NAME: hfs->nparts() * DESCRIPTION: return the number of HFS partitions in the medium */ int hfs_nparts(const char *path) { hfsvol vol; int nparts, found; Partition map; unsigned long bnum = 0; v_init(&vol, HFS_OPT_NOCACHE); if (v_open(&vol, path, HFS_MODE_RDONLY) == -1) goto fail; nparts = 0; while (1) { found = m_findpmentry(&vol, "Apple_HFS", &map, &bnum); if (found == -1) goto fail; if (! found) break; ++nparts; } if (v_close(&vol) == -1) goto fail; return nparts; fail: v_close(&vol); return -1; }
/* * create array */ void v_toarray1(var_t *v, dword r) { var_t *e; dword i; v_free(v); v->type = V_ARRAY; if (r > 0) { // create data v->v.a.size = r; v->v.a.ptr = malloc(sizeof(var_t) * (v->v.a.size + ARR_ALLOC)); for (i = 0; i < r; i++) { e = (var_t *)(v->v.a.ptr + (sizeof(var_t) * i)); v_init(e); } // array info v->v.a.maxdim = 1; v->v.a.lbound[0] = opt_base; v->v.a.ubound[0] = opt_base + (r - 1); } else { v->v.a.size = 0; v->v.a.ptr = NULL; v->v.a.lbound[0] = v->v.a.ubound[0] = opt_base; v->v.a.maxdim = 1; } }
void D3DApp::v_run() { bool ret = init_window(); v_init(); #ifdef USE_CAMERA D3DSphereCamera::getInstance()->init(m_hWnd); D3DEulerCamera::getInstance()->init(m_hInstance, m_hWnd); #endif MSG msg; ZeroMemory(&msg, sizeof(MSG)); while (ret) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) { ret = false; } else { v_update(); v_render(); ret = true; } } v_shutdown(); }
// assign error to variable or match with next expression int err_throw_catch(const char *err) { var_t *arg; var_t v_catch; int caught = 1; switch (code_peek()) { case kwTYPE_VAR: arg = code_getvarptr(); v_setstr(arg, err); break; case kwTYPE_STR: v_init(&v_catch); eval(&v_catch); // catch is conditional on matching error caught = (v_catch.type == V_STR && strstr(err, v_catch.v.p.ptr) != NULL); v_free(&v_catch); break; case kwTYPE_EOC: case kwTYPE_LINE: break; default: rt_raise(ERR_INVALID_CATCH); break; } return caught; }
void Win32App::v_run() { bool ret = init_window(); v_init(); MSG msg; ZeroMemory(&msg, sizeof(MSG)); while (ret) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) { ret = false; } else { v_update(); v_render(); ret = true; } } v_shutdown(); }
/* *release variable */ void v_free(var_t *v) { int i; var_t *elem; switch (v->type) { case V_STR: if (v->v.p.ptr) { tmp_free(v->v.p.ptr); } v->v.p.ptr = NULL; v->v.p.size = 0; break; case V_ARRAY: if (v->v.a.size) { if (v->v.a.ptr) { for (i = 0; i < v->v.a.size; i++) { elem = (var_t *) (v->v.a.ptr + (sizeof(var_t) *i)); v_free(elem); } tmp_free(v->v.a.ptr); v->v.a.ptr = NULL; v->v.a.size = 0; } } break; case V_UDS: break; } v_init(v); }
/* * creates and returns a new variable */ var_t *v_new() { var_t *ptr; ptr = (var_t *) tmp_alloc(sizeof(var_t)); v_init(ptr); return ptr; }
/* * return a full copy of the 'source' */ var_t *v_clone(const var_t *source) { var_t *vnew; vnew = (var_t *) tmp_alloc(sizeof(var_t)); v_init(vnew); v_set(vnew, source); return vnew; }
/* init application functions and structures and widgets All widgets are created, but not visible. functions can now communicate with widgets */ static void InitializeApplication( Widget top ) { trace_level = CONFIG.traceLevel; CONFIG.vset = v_init(); XtAppContext app = XtWidgetToApplicationContext(top); (void) app; }
/****************************************************************************** * MAIN function ******************************************************************************/ int main ( int argc, char **argv ) { Widget appShell = init_application(&argc, argv ); catch_sigterm(); trace_main = TRACE_MAIN; signal(SIGPIPE, SIG_IGN); /* ignore broken pipe on write */ /* -- Register all application specific callbacks and widget classes */ RegisterApplication ( appShell ); add_winmove_translations(appShell); /* -- Create widget tree below toplevel shell using Xrm database register callbacks,actions, widget classe before */ WcWidgetCreation ( appShell ); /* get application resources and widget ptr */ XtGetApplicationResources( appShell, (XtPointer)&SETTINGS, basicSettingRes, XtNumber(basicSettingRes), (ArgList)0, 0 ); SETTINGS.app = XtWidgetToApplicationContext(appShell); SETTINGS.vset = v_init(); /* init widgets */ trace_level = SETTINGS.traceLevel; TRACE(1,"Thermal1 %s\nThermal2 %s", SETTINGS.p[0], SETTINGS.p[1] ); /* init application functions All widgets are created, but not visible. functions can now communicate with widgets */ update_cb(0,0); /* start timer */ /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget ( appShell ); grab_window_quit( appShell ); make_borderless_window(appShell); make_stay_above(appShell); int x0,y0; if( load_window_position(&x0,&y0) == 0 ) XMoveWindow(XtDisplay(appShell),XtWindow(appShell), x0, y0 ); XtAppMainLoop(XtWidgetToApplicationContext(appShell)); /* use XtAppSetExitFlag */ Dimension x,y; XtVaGetValues( appShell, "x", &x, "y", &y, NULL ); save_window_position(x,y); XtDestroyWidget(appShell); v_free( SETTINGS.vset ); m_destruct(); return EXIT_SUCCESS; }
void v_init_pool() { int i; next_pool_free = 0; for (i = 0; i < VAR_POOL_SIZE; i++) { v_init(&var_pool[i]); var_pool[i].pooled = 1; var_pool[i].attached = 0; } }
/* * NAME: hfs->mount() * DESCRIPTION: open an HFS volume; return volume descriptor or 0 (error) */ hfsvol *hfs_mount( int os_fd, int pnum) { hfsvol *vol, *check; int mode = HFS_MODE_RDONLY; /* see if the volume is already mounted */ for (check = hfs_mounts; check; check = check->next) { if (check->pnum == pnum && v_same(check, os_fd) == 1) { vol = check; goto done; } } vol = ALLOC(hfsvol, 1); if (vol == NULL) ERROR(ENOMEM, NULL); v_init(vol, mode); vol->flags |= HFS_VOL_READONLY; if( v_open(vol, os_fd) == -1 ) goto fail; /* mount the volume */ if (v_geometry(vol, pnum) == -1 || v_mount(vol) == -1) goto fail; /* add to linked list of volumes */ vol->prev = NULL; vol->next = hfs_mounts; if (hfs_mounts) hfs_mounts->prev = vol; hfs_mounts = vol; done: ++vol->refs; curvol = vol; return vol; fail: if (vol) { v_close(vol); FREE(vol); } return NULL; }
void v_new_array(var_t *var, unsigned size) { var->type = V_ARRAY; var->v.a.size = size; var->v.a.data = (var_t *)malloc(sizeof(var_t) * size); int i = 0; for (i = 0; i < size; i++) { var_t *e = v_elem(var, i); v_init(e); } }
/* * assign (dest = src) */ void v_set(var_t *dest, const var_t *src) { int i; var_t *dest_vp, *src_vp; if (src->type == V_UDS) { uds_set(dest, (const var_p_t) src); return; } else if (dest->type == V_UDS) { // lvalue struct assigned to non-struct rvalue uds_clear(dest); return; } else if (src->type == V_HASH) { hash_set(dest, (const var_p_t) src); return; } else if (dest->type == V_HASH) { // lvalue struct assigned to non-struct rvalue hash_clear(dest); return; } v_free(dest); *dest = *src; dest->const_flag = 0; switch (src->type) { case V_STR: dest->v.p.ptr = (byte *) tmp_alloc(strlen((char *)src->v.p.ptr) + 1); strcpy((char *) dest->v.p.ptr, (char *) src->v.p.ptr); break; case V_ARRAY: if (src->v.a.size) { dest->v.a.ptr = tmp_alloc(src->v.a.size * sizeof(var_t)); // copy each element for (i = 0; i < src->v.a.size; i++) { src_vp = (var_t *) (src->v.a.ptr + (sizeof(var_t) * i)); dest_vp = (var_t *) (dest->v.a.ptr + (sizeof(var_t) * i)); v_init(dest_vp); v_set(dest_vp, src_vp); } } else { dest->v.a.size = 0; dest->v.a.ptr = NULL; dest->v.a.ubound[0] = dest->v.a.lbound[0] = opt_base; dest->v.a.maxdim = 1; } break; case V_PTR: dest->v.ap = src->v.ap; dest->type = src->type; break; } }
/* * assign (dest = src) */ void v_set(var_t *dest, const var_t *src) { v_free(dest); dest->const_flag = 0; dest->type = src->type; switch (src->type) { case V_INT: dest->v.i = src->v.i; break; case V_STR: dest->v.p.size = strlen(src->v.p.ptr) + 1; dest->v.p.ptr = (char *)malloc(dest->v.p.size); strcpy(dest->v.p.ptr, src->v.p.ptr); break; case V_NUM: dest->v.n = src->v.n; break; case V_MAP: map_set(dest, (const var_p_t)src); break; case V_PTR: dest->v.ap.p = src->v.ap.p; dest->v.ap.v = src->v.ap.v; break; case V_REF: dest->v.ref = src->v.ref; break; case V_FUNC: dest->v.fn.cb = src->v.fn.cb; dest->v.fn.self = src->v.fn.self; break; case V_ARRAY: if (src->v.a.size) { memcpy(&dest->v.a, &src->v.a, sizeof(src->v.a)); dest->v.a.ptr = malloc(src->v.a.size * sizeof(var_t)); // copy each element int i; var_t *dest_vp, *src_vp; for (i = 0; i < src->v.a.size; i++) { src_vp = (var_t *)(src->v.a.ptr + (sizeof(var_t) * i)); dest_vp = (var_t *)(dest->v.a.ptr + (sizeof(var_t) * i)); v_init(dest_vp); v_set(dest_vp, src_vp); } } else { dest->v.a.size = 0; dest->v.a.ptr = NULL; dest->v.a.ubound[0] = dest->v.a.lbound[0] = opt_base; dest->v.a.maxdim = 1; } break; } }
/* * resize an existing array */ void v_resize_array(var_t *v, dword size) { if (v->type == V_ARRAY) { if ((int)size < 0) { err_evargerr(); return; } int i; if (size == 0) { v_free(v); v->type = V_ARRAY; v->v.a.size = 0; v->v.a.data = NULL; v->v.a.ubound[0] = v->v.a.lbound[0] = opt_base; v->v.a.maxdim = 1; } else if (v->v.a.size > size) { // resize down // free vars for (i = size; i < v->v.a.size; i++) { var_t *elem = v_elem(v, i); v_free(elem); } // array data v->v.a.size = size; v->v.a.ubound[0] = v->v.a.lbound[0] + (size - 1); v->v.a.maxdim = 1; } else if (v->v.a.size < size) { // resize up, if there is space do not resize int prev_size = v->v.a.size; if (prev_size == 0) { v_new_array(v, size); } else if (prev_size < size) { // resize & copy v->v.a.data = (var_t *)realloc(v->v.a.data, sizeof(var_t) * size); v->v.a.size = size; } // init vars for (i = prev_size; i < size; i++) { var_t *elem = v_elem(v, i); v_init(elem); } // array data v->v.a.size = size; v->v.a.ubound[0] = v->v.a.lbound[0] + (size - 1); v->v.a.maxdim = 1; } } else { err_varisnotarray(); } }
/** * execute a procedure */ int sblmgr_procexec(int lib_id, int index) { #if defined(LNX_EXTLIB) || defined(WIN_EXTLIB) slib_t *lib; var_t ret; slib_par_t *ptable = NULL; int (*pexec) (int, int, slib_par_t *, var_t *); int pcount = 0; int success = 0; if (lib_id < 0 || lib_id >= slib_count) { return 0; } lib = &slib_table[lib_id]; pexec = slib_getoptptr(lib, "sblib_proc_exec"); if (pexec == NULL) { return 0; } // build parameter table ptable = malloc(sizeof(slib_par_t) * MAX_PARAM); pcount = slib_build_ptable(ptable); if (prog_error) { slib_free_ptable(ptable, pcount); free(ptable); return 0; } // exec v_init(&ret); success = pexec(index - lib->first_proc, pcount, ptable, &ret); // error if (!success) { if (ret.type == V_STR) { err_throw("lib:%s: %s\n", lib->name, ret.v.p.ptr); } else { err_throw("lib:%s: Unspecified error\n", lib->name); } } // clean-up if (ptable) { slib_free_ptable(ptable, pcount); free(ptable); } v_free(&ret); return success; #else return 0; #endif }
//inicializacao basica. inline void init() { Core::Vector3 v_init(0); setDirection(v_init); setSpeed(0); setPos(v_init); m_iLifes = 1; m_iImage = -1; m_bVisible = true; }
/* * NAME: hfs_callback_open() * DESCRIPTION: open an HFS volume; return volume descriptor or 0 (error) */ hfsvol* hfs_callback_open(oscallback func, void* cookie, int mode) { hfsvol *vol; vol = ALLOC(hfsvol, 1); if (vol == 0) ERROR(ENOMEM, 0); v_init(vol, mode); /* open the medium */ switch (mode & HFS_MODE_MASK) { case HFS_MODE_RDWR: case HFS_MODE_ANY: break; case HFS_MODE_RDONLY: default: vol->flags |= HFS_VOL_READONLY; } /* set up vol->priv */ v_callback_open(vol, func, cookie); /* mount the volume */ if (v_geometry(vol, 0 /*we don't see partition map*/) == -1 || v_mount(vol) == -1) goto fail; assert(func != 0); assert(cookie != 0); /*done*/ ++vol->refs; return vol; fail: if (vol) { v_close(vol); FREE(vol); } return 0; }
/* * EMX initialization */ static void Term_init_emx(term *t) { struct _KBDINFO kbdinfo; /* see structure description ?somewhere? */ v_init(); v_getctype(&curs_start, &curs_end); /* hide cursor (?) XXX XXX XXX */ v_clear(); /* the documentation I (SWD) have implies, in passing, that setting */ /* "binary mode" on the keyboard device will prevent the O/S from */ /* acting on keys such as ^S (pause) and ^P (printer echo). */ /* note also that "KbdSetStatus is ignored for a Vio-windowed application." */ /* so there may well be problems with running this in a window. Damnit. */ /* this is kind of a nasty structure, as you can't just flip a bit */ /* to change binary/ASCII mode, or echo on/off mode... nor can you */ /* clear the whole thing -- certain bits need to be preserved. */ KbdGetStatus(&kbdinfo, (HKBD)0); kbdinfo.fsMask &= ~ (KEYBOARD_ECHO_ON| /* clear lowest four bits */ KEYBOARD_ECHO_OFF|KEYBOARD_BINARY_MODE|KEYBOARD_ASCII_MODE); kbdinfo.fsMask |= (KEYBOARD_BINARY_MODE); /* set bit two */ KbdSetStatus(&kbdinfo, (HKBD)0); #if 1 /* turn off for debug */ signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); /* signal(SIGILL,SIG_IGN); */ /* signal(SIGTRAP,SIG_IGN); */ /* signal(SIGABRT,SIG_IGN); */ /* signal(SIGEMT,SIG_IGN); */ /* signal(SIGFPE,SIG_IGN); */ /* signal(SIGBUS,SIG_IGN); */ /* signal(SIGSEGV,SIG_IGN); */ /* signal(SIGSYS,SIG_IGN); */ signal(SIGPIPE, SIG_IGN); signal(SIGALRM, SIG_IGN); /* signal(SIGTERM,SIG_IGN); */ signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); signal(SIGCHLD, SIG_IGN); signal(SIGBREAK, SIG_IGN); #endif }
// throw user error void cmd_throw() { if (!gsb_last_error) { var_t v_throw; v_init(&v_throw); const char *err = ""; byte code = code_peek(); if (code != kwTYPE_EOC && code != kwTYPE_LINE) { eval(&v_throw); if (v_throw.type == V_STR) { err = v_throw.v.p.ptr; } } err_throw_str(err); v_free(&v_throw); } }
/* * creates and returns a new variable */ var_t *v_new() { var_t *result = NULL; int i; for (i = 0; i < VAR_POOL_SIZE; i++) { if (!var_pool[next_pool_free].attached) { result = &var_pool[next_pool_free]; result->attached = 1; break; } next_pool_free = (next_pool_free + 1) % VAR_POOL_SIZE; } if (!result) { result = (var_t *)malloc(sizeof(var_t)); result->pooled = 0; } v_init(result); return result; }
int main(int argc, char** argv) { Vector* v = (Vector*) malloc(sizeof(Vector)); v_init(v, 0); int i; printf("[test-1] push 10 closures to bottom\n"); for (i = 0; i < 10; i++) { Closure* c = (Closure*) malloc(sizeof(Closure)); cl_init(c); c->level = i; v_push_closure(v, c); } v_print(v); printf("[test-2] push 10 closures next to their roots\n"); for (i = 0; i < 10; i++) { Closure* c = (Closure*) malloc(sizeof(Closure)); cl_init(c); c->level = i; v_push_closure(v, c); } v_print(v); printf("[test-3] pop 10 closures from top\n"); for (i = 0; i < 10; i++) { Closure* c = v_pop_top(v); cl_free(c); } v_print(v); printf("[test-4] pop 10 closures from bot\n"); for (i = 0; i < 10; i++) { Closure* c = v_pop_bottom(v); cl_free(c); } v_print(v); v_free(v); return 0; }
/* * NAME: hfs->zero() * DESCRIPTION: initialize medium with new/empty DDR and partition map */ int hfs_zero(const char *path, unsigned int maxparts, unsigned long *blocks) { hfsvol vol; v_init(&vol, HFS_OPT_NOCACHE); if (maxparts < 1) ERROR(EINVAL, "must allow at least 1 partition"); if (v_open(&vol, path, HFS_MODE_RDWR) == -1 || v_geometry(&vol, 0) == -1) goto fail; if (m_zeroddr(&vol) == -1 || m_zeropm(&vol, 1 + maxparts) == -1) goto fail; if (blocks) { Partition map; int found; found = m_findpmentry(&vol, "Apple_Free", &map, 0); if (found == -1) goto fail; if (! found) ERROR(EIO, "unable to determine free partition space"); *blocks = map.pmPartBlkCnt; } if (v_close(&vol) == -1) goto fail; return 0; fail: v_close(&vol); return -1; }
/* *create RxC array */ void v_tomatrix(var_t *v, int r, int c) { var_t *e; int i; v_free(v); v->type = V_ARRAY; // create data v->v.a.size = r *c; v->v.a.ptr = tmp_alloc(sizeof(var_t) *v->v.a.size); for (i = 0; i < r *c; i++) { e = (var_t *) (v->v.a.ptr + (sizeof(var_t) *i)); v_init(e); } // array info v->v.a.lbound[0] = v->v.a.lbound[1] = opt_base; v->v.a.ubound[0] = opt_base + (r - 1); v->v.a.ubound[1] = opt_base + (c - 1); v->v.a.maxdim = 2; }
/* * NAME: hfs->mkpart() * DESCRIPTION: create a new HFS partition */ int hfs_mkpart(const char *path, unsigned long len) { hfsvol vol; v_init(&vol, HFS_OPT_NOCACHE); if (v_open(&vol, path, HFS_MODE_RDWR) == -1) goto fail; if (m_mkpart(&vol, "MacOS", "Apple_HFS", len) == -1) goto fail; if (v_close(&vol) == -1) goto fail; return 0; fail: v_close(&vol); return -1; }
void VulkanApp::v_run() { setupWindow(); v_init(); MSG msg; ZeroMemory(&msg, sizeof(MSG)); while (TRUE) { auto tStart = std::chrono::high_resolution_clock::now(); if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) { break; } v_update(); v_render(); auto tEnd = std::chrono::high_resolution_clock::now(); auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count(); frameTimer = (float)tDiff / 1000.0f; // Convert to clamped timer value if (!paused) { timer += timerSpeed * frameTimer; if (timer > 1.0) { timer -= 1.0f; } } } }
void v_toarray1(var_t *v, dword r) #endif { var_t *e; #if defined(OS_ADDR16) word i; #else dword i; #endif v_free(v); v->type = V_ARRAY; if (r > 0) { // create data v->v.a.size = r; #if defined(OS_ADDR32) v->v.a.ptr = tmp_alloc(sizeof(var_t) * (v->v.a.size + ARR_ALLOC)); #else v->v.a.ptr = tmp_alloc(sizeof(var_t) * v->v.a.size); #endif for (i = 0; i < r; i++) { e = (var_t *) (v->v.a.ptr + (sizeof(var_t) * i)); v_init(e); } // array info v->v.a.maxdim = 1; v->v.a.lbound[0] = opt_base; v->v.a.ubound[0] = opt_base + (r - 1); } else { v->v.a.size = 0; v->v.a.ptr = NULL; v->v.a.lbound[0] = v->v.a.ubound[0] = opt_base; v->v.a.maxdim = 1; } }
void OGLApp::v_run() { app = std::make_shared<OGLApp>(*this); std::cout << "Starting GLFW context" << std::endl; if (!glfwInit()) { std::cerr << "Failed to initialize GLFW" << std::endl; return; } sw = WindowInfo::getInstance()->getWidth(); sh = WindowInfo::getInstance()->getHeight(); int MonitorCount; GLFWmonitor ** monitors = glfwGetMonitors(&MonitorCount); #ifdef _DEBUG glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true); #endif //glfwGetPrimaryMonitor(), pWindow = glfwCreateWindow(sw, sh, WindowInfo::getInstance()->getTitle().c_str(), nullptr, nullptr); glfwSetWindowPos(pWindow, WindowInfo::getInstance()->getPosX() - 100, WindowInfo::getInstance()->getPosY() - 100); glfwMakeContextCurrent(pWindow); glfwSetCursorPosCallback(pWindow, glfw_mouse); // - Directly redirect GLFW mouse position events to AntTweakBar glfwSetScrollCallback(pWindow, glfw_scroll); // - Directly redirect GLFW mouse wheel events to AntTweakBar glfwSetKeyCallback(pWindow, glfw_key); // - Directly redirect GLFW key events to AntTweakBar #ifdef USE_ANT glfwSetMouseButtonCallback(pWindow, glfw_mouseButton); // - Directly redirect GLFW mouse button events to AntTweakBar glfwSetCharCallback(pWindow, glfw_char); // - Directly redirect GLFW char events to AntTweakBar #endif glfwSetWindowSizeCallback(pWindow, glfw_resize); //glfwSetInputMode(pWindow, GLFW_STICKY_KEYS, GL_TRUE); // GLFW Options //glfwSetInputMode(pWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED); if (pWindow == NULL) { std::cerr << "Failed to create GLFW pWindow" << std::endl; glfwTerminate(); return; } glewExperimental = GL_TRUE; //Check the GLSL and OpenGL status if (glewInit() != GLEW_OK) { std::cerr << "Failed to initialize GLEW" << std::endl; return; } const GLubyte *renderer = glGetString(GL_RENDERER); const GLubyte *vendor = glGetString(GL_VENDOR); const GLubyte *version = glGetString(GL_VERSION); const GLubyte *glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION); m_GLRenderer = (const char *)renderer; m_GLVersion = (const char *)version; m_GLSLVersion = (const char *)glslVersion; GLint major, minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); std::cout << "GL Vendor :" << vendor << std::endl; std::cout << "GL Renderer : " << renderer << std::endl; std::cout << "GL Version (std::string) : " << version << std::endl; std::cout << "GL Version (integer) : " << major << "." << minor << std::endl; std::cout << "GLSL Version : " << glslVersion << std::endl; std::cout << "--------------------------------------------------------------------------------" << std::endl; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); #ifdef USE_FONT m_pFont.init(); #endif #ifdef USE_CEGUI OGLCEGUI::getInstance()->init(); OGLCEGUI::getInstance()->setupCallbacks(pWindow); #endif v_init(); while (!glfwWindowShouldClose(pWindow)) { glfwPollEvents(); v_movement(pWindow); countFps(); static GLfloat lastFrame = static_cast<float>(glfwGetTime()); GLfloat currentFrame = static_cast<float>(glfwGetTime()); GLfloat deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; v_update(); v_render(); #ifdef USE_FONT glDisable(GL_DEPTH_TEST); m_pFont.render("Graphics card: " + m_GLRenderer, 10, sh - 40); m_pFont.render("GL Version: " + m_GLVersion, 10, sh - 70); m_pFont.render("GLSL Version: " + m_GLSLVersion, 10, sh - 100); m_pFont.render("FPS: " + std::to_string(m_fps), 10, 30); //glEnable(GL_DEPTH_TEST); #endif #ifdef USE_CEGUI OGLCEGUI::getInstance()->render(); #endif glfwSwapBuffers(pWindow); } v_shutdown(); glfwTerminate(); }
Vector v_dinit (int siz) { return v_init (siz, V_DEFAULT_LENGTH); }