void App::InitApp() { init_window(); v_Init(); }
FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { CPDF_Dictionary* pDict; if (pObj->GetType() == PDFOBJ_STREAM) { pDict = ((CPDF_Stream*)pObj)->GetDict(); } else { pDict = (CPDF_Dictionary*)pObj; } CPDF_Array* pDomains = pDict->GetArray(FX_BSTRC("Domain")); if (pDomains == NULL) { return FALSE; } m_nInputs = pDomains->GetCount() / 2; if (m_nInputs == 0) { return FALSE; } m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2); for (int i = 0; i < m_nInputs * 2; i++) { m_pDomains[i] = pDomains->GetFloat(i); } CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range")); m_nOutputs = 0; if (pRanges) { m_nOutputs = pRanges->GetCount() / 2; m_pRanges = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); for (int i = 0; i < m_nOutputs * 2; i++) { m_pRanges[i] = pRanges->GetFloat(i); } } FX_DWORD old_outputs = m_nOutputs; if (!v_Init(pObj)) { return FALSE; } if (m_pRanges && m_nOutputs > (int)old_outputs) { m_pRanges = FX_Realloc(FX_FLOAT, m_pRanges, m_nOutputs * 2); if (m_pRanges) { FXSYS_memset(m_pRanges + (old_outputs * 2), 0, sizeof(FX_FLOAT) * (m_nOutputs - old_outputs) * 2); } } return TRUE; }
FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) { CPDF_Stream* pStream = pObj->AsStream(); CPDF_Dictionary* pDict = pStream ? pStream->GetDict() : pObj->AsDictionary(); CPDF_Array* pDomains = pDict->GetArrayBy("Domain"); if (!pDomains) return FALSE; m_nInputs = pDomains->GetCount() / 2; if (m_nInputs == 0) return FALSE; m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2); for (uint32_t i = 0; i < m_nInputs * 2; i++) { m_pDomains[i] = pDomains->GetFloatAt(i); } CPDF_Array* pRanges = pDict->GetArrayBy("Range"); m_nOutputs = 0; if (pRanges) { m_nOutputs = pRanges->GetCount() / 2; m_pRanges = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); for (uint32_t i = 0; i < m_nOutputs * 2; i++) m_pRanges[i] = pRanges->GetFloatAt(i); } uint32_t old_outputs = m_nOutputs; if (!v_Init(pObj)) return FALSE; if (m_pRanges && m_nOutputs > old_outputs) { m_pRanges = FX_Realloc(FX_FLOAT, m_pRanges, m_nOutputs * 2); if (m_pRanges) { FXSYS_memset(m_pRanges + (old_outputs * 2), 0, sizeof(FX_FLOAT) * (m_nOutputs - old_outputs) * 2); } } return TRUE; }
void Application::Run(std::shared_ptr<Application> the_app) { app = the_app; std::cout << "Starting GLFW context" << std::endl; if (!glfwInit()) { std::cerr << "Failed to initialize GLFW" << std::endl; return; } v_InitInfo(); //Add this to use the debug output glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true); GLFWwindow *window = glfwCreateWindow(windowInfo.Width, windowInfo.Height, windowInfo.title.c_str(), nullptr, nullptr); glfwSetWindowPos(window, windowInfo.posX, windowInfo.posY); glfwMakeContextCurrent(window); glfwSetCursorPosCallback(window, glfw_mouse); // - Directly redirect GLFW mouse position events to AntTweakBar glfwSetScrollCallback(window, glfw_scroll); // - Directly redirect GLFW mouse wheel events to AntTweakBar glfwSetKeyCallback(window, glfw_key); // - Directly redirect GLFW key events to AntTweakBar //glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); // GLFW Options //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); if (window == NULL) { std::cerr << "Failed to create GLFW window" << 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); //opengl 4.3 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // Create a GLFWwindow object that we can use for GLFW's functions v_Init(); while (!glfwWindowShouldClose(window)) { int sw, sh; glfwGetWindowSize(window, &sw, &sh); glViewport(0, 0, sw, sh); glfwPollEvents(); v_Movement(window); v_Update(); //Render for the object v_Render(); glfwSwapBuffers(window); } v_Shutdown(); glfwTerminate(); }