int main(void) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, key_callback); // Initialize GLEW glewExperimental = true; // Needed for core profile if (glewInit() != GLEW_OK) { return -1; } buildBuffer(); while (!glfwWindowShouldClose(window)) { display(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }
//------------------------------------------------------ void DrawBuffer::update() { // let's update the queue! // We'll set isUpdating to true - _queueDrawQuad can then be used mIsUpdating = true; // now we call all the render ops to visit this buffer DrawOperationMap::iterator iend = mDrawOpMap.end(); // clear the quad list for this usage mQuadList.clear(); for (DrawOperationMap::iterator it = mDrawOpMap.begin(); it != iend; ++it) { DrawOperation* op = it->second; // rebuild the drawop if needed if (op->isDirty()) op->rebuild(); // visit! it->second->visitDrawBuffer(this); } mIsUpdating = false; // done. We now have the list full // sort with stable sort (to leave the order of draw quads the same draw op requested) std::stable_sort(mQuadList.begin(), mQuadList.end(), QuadLess()); // Sorted. Now (re)build the buffer buildBuffer(); mIsDirty = false; }
/** * Save N-Gram to binary file */ void SuffixModelTrieBinaryFileCreator::saveToBinaryFile(string _filePath) { wcout << "SuffixModelTrieBinaryFileCreator saveToBinaryFile ..." << endl; buildBuffer(); ofstream f(_filePath.c_str(), ios::out|ios::binary); f.write((char*)&buffer[0], bufferSize); f.close(); wcout << "SuffixModelTrieBinaryFileCreator saveToBinaryFile done!" << endl; }
int main (int argc, char **argv) { pwr_tStatus sts; unsigned int size; qcom_sQid myQId; alimsrv_sSupDataBuf *bp; qcom_sGet get; qcom_sPut put; alimsrv_sRequest request; XDR xdrs; qcom_sQattr qAttr; errh_Init("pwr_alim", errh_eAnix_alim); errh_SetStatus( PWR__SRVSTARTUP); if (!qcom_Init(&sts, 0, "pwr_alim")) { errh_Fatal("qcom_Init, %m", sts); exit(-1); } myQId.qix = alimsrv_cQix; myQId.nid = 0; qAttr.type = qcom_eQtype_private; qAttr.quota = 100; if (!qcom_CreateQ(&sts, &myQId, &qAttr, "pwr_alim")) { errh_Fatal("qcom_CreateQ, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(-1); } if (!qcom_Bind(&sts, &myQId, &qcom_cQini)) { errh_Fatal("qcom_Bind, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(-1); } sts = gdh_Init("pwr_alim"); if (EVEN(sts)) { errh_Fatal("gdh_Init, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(-1); } init(); errh_SetStatus( PWR__SRUN); /* Loop forever and receive objid's */ for (;;) { do { get.maxSize = sizeof(request); get.data = (char *)&request; qcom_Get(&sts, &myQId, &get, qcom_cTmoEternal); if (sts != QCOM__TMO && sts != QCOM__QEMPTY) { if (get.type.b == qcom_eBtype_event) { event(&get); } } } while (ODD(sts) && get.type.s != alimsrv_eSubType_Request && get.type.b != alimsrv_cMsgType); if (EVEN(sts)) { errh_Error("qcom_Get, %m",sts); continue; } if (request.Xdr) { xdrmem_create(&xdrs, (char *)&request, sizeof(request), XDR_DECODE); if (!xdr_alimsrv_sRequest(&xdrs, &request)) { errh_Error("XDR Decode failed"); continue; } } bp = buildBuffer(&request, &size); if (ODD(sts)) { bp->Xdr = TRUE; xdrmem_create(&xdrs, (char *)bp, size, XDR_ENCODE); if (!xdr_alimsrv_sSupDataBuf(&xdrs, bp)) { errh_Error("XDR Encode failed"); } else { put.type.b = alimsrv_cMsgType; put.type.s = alimsrv_eSubType_Answer; put.reply = myQId; put.data = (char *) bp; put.size = size; if (!qcom_Reply(&sts, &get, &put)) errh_Error("qcom_Respond, %m", sts); } free(bp); } } }