void init_screen() { void *host_addr = memalign(1024 * 1024, 1024 * 1024); assert(host_addr != NULL); context = realityInit(0x10000, 1024 * 1024, host_addr); assert(context != NULL); assert(videoGetState(0, 0, &state) == 0); assert(state.state == 0); assert(videoGetResolution(state.displayMode.resolution, &res) == 0); memset(&vconfig, 0, sizeof(VideoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = res.width * 4; assert(videoConfigure(0, &vconfig, NULL, 0) == 0); assert(videoGetState(0, 0, &state) == 0); s32 buffer_size = 4 * res.width * res.height; gcmSetFlipMode(GCM_FLIP_VSYNC); makeBuffer(0, buffer_size); makeBuffer(1, buffer_size); gcmResetFlipStatus(); flip(1); }
NoRSX::NoRSX(int id_type){ buffer_type = screen_type = id_type; currentBuffer = 0; switch(id_type){ case RESOLUTION_1920x1080: { width=1920;height=1080; } break; case RESOLUTION_1280x720: { width=1280;height=720; } break; case RESOLUTION_720x576: { width=720;height=576; } break; case RESOLUTION_720x480: { width=720;height=480; } break; default: width=720;height=480; break; } buffers[0].width=width;buffers[0].height=height; buffers[1].width=width;buffers[1].height=height; buffer = makeMemBuffer(width,height,&buffer_size); for(int i=0;i<2;i++) makeBuffer(&buffers[i],width,height,a); flip(); }
NoRSX::NoRSX(){ currentBuffer = 0; getResolution(&width,&height); for(int i=0;i<2;i++) makeBuffer(&buffers[i],width,height,a); flip(); }
/* internal engine routines */ static void * _output_setup(int w, int h) { Render_Engine *re; int i; u16 width, height; DATA32 *image_data = NULL; int image_size; printf ("_output_setup called : %dx%d\n", w, h); re = calloc(1, sizeof(Render_Engine)); if (!re) return NULL; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO memory with the RSX. */ re->host_addr = memalign (1024 * 1024, HOST_SIZE); if (re->host_addr == NULL) { free (re); return NULL; } re->context = initScreen (re->host_addr, HOST_SIZE); if (re->context == NULL) { free (re->host_addr); free (re); return NULL; } width = w; height = h; setResolution (re->context, &width, &height); re->currentBuffer = 0; re->width = width; re->height = height; for (i = 0; i < MAX_BUFFERS; i++) makeBuffer (&re->buffers[i], width, height, i); flipBuffer(re->context, MAX_BUFFERS - 1); re->tb = evas_common_tilebuf_new(w, h); /* in preliminary tests 16x16 gave highest framerates */ evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE); /* Allocate our memaligned backbuffer */ image_size = ((w * h * sizeof(u32)) + 0xfffff) & - 0x100000; image_data = memalign (1024 * 1024, image_size); re->rgba_image = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, 1, EVAS_COLORSPACE_ARGB8888); gcmMapMainMemory(image_data, image_size, &re->rgba_image_offset); return re; }
NoRSX::NoRSX() : EventHandler(){ currentBuffer = 0; buffer_type = screen_type = 0; host_addr = memalign(1024*1024, HOST_SIZE); getResolution(&width,&height); context = initScreen(host_addr, HOST_SIZE,0, width, height); for(int i=0;i<2;i++) makeBuffer(&buffers[i],width,height,i); buffer = makeMemBuffer(width,height,&buffer_size); flip(context, 0); setRenderTarget(context, &buffers[currentBuffer]); RegisterCallBack(EVENT_SLOT0); }
// Initilize everything. You can probally skip over this function. void init_screen() { // Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. void *host_addr = memalign(1024*1024, 1024*1024); assert(host_addr != NULL); // Initilise Reality, which sets up the command buffer and shared IO memory context = realityInit(0x10000, 1024*1024, host_addr); assert(context != NULL); VideoState state; assert(videoGetState(0, 0, &state) == 0); // Get the state of the display assert(state.state == 0); // Make sure display is enabled // Get the current resolution assert(videoGetResolution(state.displayMode.resolution, &res) == 0); // Configure the buffer format to xRGB VideoConfiguration vconfig; memset(&vconfig, 0, sizeof(VideoConfiguration)); vconfig.resolution = state.displayMode.resolution; vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; vconfig.pitch = res.width * 4; assert(videoConfigure(0, &vconfig, NULL, 0) == 0); assert(videoGetState(0, 0, &state) == 0); s32 buffer_size = 4 * res.width * res.height; // each pixel is 4 bytes printf("buffers will be 0x%x bytes\n", buffer_size); gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip // Allocate two buffers for the RSX to draw to the screen (double buffering) makeBuffer(0, buffer_size); makeBuffer(1, buffer_size); gcmResetFlipStatus(); flip(1); }
void writeMatch(refMatch match) { refBuffer buffer = makeBuffer(stdout, 0); writeFormat(buffer, "[Match"); writeBlank(buffer); writingObject(buffer, leftLayer(match)); writeBlank(buffer); writingObject(buffer, leftType(match)); writeBlank(buffer); writingObject(buffer, rightLayer(match)); writeBlank(buffer); writingObject(buffer, rightType(match)); writeChar(buffer, ']'); writeBuffer(buffer); free(buffer); }
static void setupBuffers(void){ GLfloat g_vertex_buffer_data[] = { -0.5f, -0.5f, 0.0f, 0.5, -0.5, 0.0f, 0.5f, 0.5f, 0.0f, 0.5f, 0.5f, 0.0f, -0.5f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f }; g_resources.vertex_buffer = makeBuffer( GL_ARRAY_BUFFER, g_vertex_buffer_data, sizeof(g_vertex_buffer_data) ); }
NoRSX::NoRSX(int id_type) : EventHandler(){ buffer_type = screen_type = id_type; currentBuffer = 0; host_addr = memalign(1024*1024, HOST_SIZE); switch(id_type){ case RESOLUTION_1920x1080: { width=1920;height=1080; buffers[0].width=1920;buffers[0].height=1080; buffers[1].width=1920;buffers[1].height=1080; } break; case RESOLUTION_1280x720: { width=1280;height=720; buffers[0].width=1280;buffers[0].height=720; buffers[1].width=1280;buffers[1].height=720; } break; case RESOLUTION_720x576: { width=720;height=576; buffers[0].width=720;buffers[0].height=576; buffers[1].width=720;buffers[1].height=576; } break; case RESOLUTION_720x480: { width=720;height=480; buffers[0].width=720;buffers[0].height=480; buffers[1].width=720;buffers[1].height=480; } break; default: getResolution(&width,&height); buffers[0].width=width;buffers[0].height=height; buffers[1].width=width;buffers[1].height=height; break; } context = initScreen(host_addr, HOST_SIZE, id_type, width, height); for(int i=0;i<2;i++) makeBuffer(&buffers[i],width,height,i); buffer = makeMemBuffer(width,height,&buffer_size); flip(context, 0); setRenderTarget(context, &buffers[0]); RegisterCallBack(EVENT_SLOT0); }
static void setupDynamicBuffers(){ GLfloat x_translation = sin(angle)/2.0f; GLfloat triangleVertices[] = { //left triangle -0.5 + x_translation, 0.5, 0.0, 0.0 + x_translation, 0.5, 0.0, -0.5 + x_translation, -0.5, 0.0, //right triangle 0.0 + x_translation, 0.5, 0.0, 0.0 + x_translation, -0.5, 0.0, -0.5 + x_translation, -0.5, 0.0 }; angle += 0.01; g_resources.vertex_buffer = makeBuffer( GL_ARRAY_BUFFER, triangleVertices, sizeof(triangleVertices) ); }
int startScreen () { int i; int ret; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO * memory with the RSX. */ host_addr = memalign (1024 * 1024, HOST_SIZE); ret = initScreen (host_addr, HOST_SIZE); if (ret) { return 0; } getResolution (&width, &height); for (i = 0; i < MAX_BUFFERS; i++) makeBuffer (&buffers[i], width, height, i); flip (context, MAX_BUFFERS - 1); return 1; }
//-------------------------------------------------------------- void testApp::setup(){ ofBackground(255,255,255); ofSetFrameRate(30); // video setup camWidth = 320; // try to grab at this size. camHeight = 240; //vidGrabber.videoSettings(); vidGrabber.listDevices(); vidGrabber.setVerbose(true); vidGrabber.initGrabber(camWidth,camHeight); //interp.reset(ofPoint(100, ofGetHeight()/2), ofPoint(ofGetWidth()-100, ofGetHeight()/2)); int fps = 30; currentBuffer = -1; makeBuffer(ofGetWidth()/2,ofGetHeight()/2); currentSource = 0; cam.execute("http://148.61.142.228/axis-cgi/mjpg/video.cgi?resolution="+ ofToString(camWidth) + "x" + ofToString(camHeight),camWidth,camHeight); videoTexture0.allocate(camWidth,camHeight, GL_RGBA) ;//GL_RGBA); //interp.insert(ofPoint(ofGetWidth()/2,0));//ofGetHeight()/2)); // frameByframe = false; /* fingerMovie.loadMovie("movies/fingers.mov"); fingerMovie.play(); */ }
//float color [] = {1.0f, 0.0f, 0.0f, 1.0f}; void setupVBO(){ //pVertices=makeBuffer(pvertices, platformVertexCount, sizeof(float)*4); //pColors=makeBuffer(color, 1, sizeof(float)); for(int i=0; i<loaded.size(); i++){ loaded[i].vertices=makeBuffer(&(loaded[i]).w[0], loaded[i].count*3, sizeof(float)*4); loaded[i].normals=makeBuffer(&(loaded[i]).n[0], loaded[i].count*3, sizeof(float)*4); loaded[i].texCoords=makeBuffer(&(loaded[i]).tc[0], loaded[i].count*3, sizeof(float)*2); } for(int i=0; i<model.size(); i++){ model[i].vertices=makeBuffer(&(model[i]).w[0], model[i].count*3, sizeof(float)*4); model[i].normals=makeBuffer(&(model[i]).n[0], model[i].count*3, sizeof(float)*4); model[i].texCoords=makeBuffer(&(model[i]).tc[0], model[i].count*3, sizeof(float)*2); } //cout<<"Size of loaded: "<<loaded.size()<<endl; }
/* The main function for running the ECG program. */ int runECG() { openFile(); //printf("Peak nr. Line R peak\n"); buffered_filtered_data = makeBuffer(SIZE_FILTERED_DATA); buffered_raw_data = makeBuffer(SIZE_RAW_DATA); buffered_LP_data = makeBuffer(SIZE_LP_DATA); buffered_HP_data = makeBuffer(SIZE_HP_DATA); buffered_derivative_square_data = makeBuffer(SIZE_DERIVATIVESQUARE_DATA); buffered_peak_lines = makeBuffer(SIZE_PEAKS); initQRS(); while (getFilePointer() != EOF) { insert(&buffered_filtered_data, filter()); detectPeaks(); line++; } freeBuffers(&buffered_raw_data, &buffered_LP_data, &buffered_HP_data, &buffered_derivative_square_data, &buffered_filtered_data, &buffered_peak_lines); return 0; }
int main (s32 argc, const char* argv[]) { gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; padInfo padinfo; padData paddata; u16 width; u16 height; int frame = 0; int i; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO memory with the RSX. */ host_addr = memalign (1024*1024, HOST_SIZE); context = initScreen (host_addr, HOST_SIZE); ioPadInit (7); getResolution(&width, &height); for (i = 0; i < MAX_BUFFERS; i++) makeBuffer (&buffers[i], width, height, i); flip(context, MAX_BUFFERS - 1); DEBUG ("Starting Cairo test\n"); while (1) { ioPadGetInfo (&padinfo); for(i = 0; i < MAX_PADS; i++) { if(padinfo.status[i]) { ioPadGetData (i, &paddata); if(paddata.BTN_START) { goto end; } } } setRenderTarget(context, &buffers[currentBuffer]); DEBUG ("Drawing frame %d\n", frame); waitFlip (); drawFrame (&buffers[currentBuffer], frame++); /* Draw into the unused buffer */ flip (context, buffers[currentBuffer].id); /* Flip buffer onto screen */ currentBuffer++; if (currentBuffer >= MAX_BUFFERS) currentBuffer = 0; } end: gcmSetWaitFlip(context); for (i = 0; i < MAX_BUFFERS; i++) rsxFree (buffers[i].ptr); rsxFinish (context, 1); free (host_addr); ioPadEnd(); return 0; }
//-------------------------------------------------------------- void testApp::keyPressed (int key){ if(key == '!' || key == '@' || key == '#' || key == '$') { thisKey = key; return; } if(key == 'o') { float o = xform[currentBuffer].getOpacity(); xform[currentBuffer].setOpacity(CLAMP(o+0.1,0,1)); return; } else if(key == 'O') { float o = xform[currentBuffer].getOpacity(); xform[currentBuffer].setOpacity(CLAMP(o-0.1,0,1)); return; } if(key == '\'') { currentSource ^= 1; } if (key == 's' || key == 'S'){ vidGrabber.videoSettings(); } if(key == 'Q') { int i = 120; buffers[currentBuffer]->resize(i); return; } if(key == 'q') { int r = 10; buffers[currentBuffer]->resize(r); return; } if(key == ' ') { buffers[currentBuffer]->setBufferMode(VB_BUFFERING); } if(key == 'p') { buffers[currentBuffer]->setBufferMode(VB_PASSTHROUGH); } if(key == 'R') { buffers[currentBuffer]->clear(); } if(key == '1') { buffers[currentBuffer]->setLoopState(OF_LOOP_NONE); } else if(key == '2') { buffers[currentBuffer]->setLoopState(OF_LOOP_NORMAL); } else if(key == '3') { buffers[currentBuffer]->setLoopState(OF_LOOP_PALINDROME); } if(key == 'q') { buffers[currentBuffer]->setLoopPointsStart( buffers[currentBuffer]->getLoopPointsStart()-1 ); } else if(key == 'w') { buffers[currentBuffer]->setLoopPointsStart( buffers[currentBuffer]->getLoopPointsStart()+1 ); } else if(key == 'e') { buffers[currentBuffer]->setLoopPointsEnd( buffers[currentBuffer]->getLoopPointsEnd()-1 ); } else if(key == 'r') { buffers[currentBuffer]->setLoopPointsEnd( buffers[currentBuffer]->getLoopPointsEnd()+1 ); } if(key == 'n') { makeBuffer(mouseX,mouseY); } if(key == '<') { currentBuffer = MAX(0, currentBuffer-1); } else if(key == '>') { currentBuffer = (currentBuffer + 1) % buffers.size(); } /* switch(key){ case 'f': frameByframe=!frameByframe; fingerMovie.setPaused(frameByframe); break; case OF_KEY_LEFT: fingerMovie.previousFrame(); break; case OF_KEY_RIGHT: fingerMovie.nextFrame(); break; case '0': fingerMovie.firstFrame(); break; } */ }
/* * Processes received authentication tokens as well as supplies the * response token. */ int ne_sspi_authenticate(void *context, const char *base64Token, char **responseToken) { SecBufferDesc outBufferDesc; SecBuffer outBuffer; int status; SECURITY_STATUS securityStatus; ULONG contextFlags; SSPIContext *sspiContext; if (initialized <= 0) { return -1; } status = getContext(context, &sspiContext); if (status) { return status; } /* TODO: Not sure what flags should be set. joe: this needs to be * driven by the ne_auth interface; the GSSAPI code needs similar * flags. */ contextFlags = ISC_REQ_CONFIDENTIALITY | ISC_REQ_MUTUAL_AUTH; initSingleEmptyBuffer(&outBufferDesc, &outBuffer); status = makeBuffer(&outBufferDesc, sspiContext->maxTokenSize); if (status) { return status; } if (base64Token) { SecBufferDesc inBufferDesc; SecBuffer inBuffer; if (!sspiContext->continueNeeded) { freeBuffer(&outBufferDesc); NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: Got an unexpected token.\n"); return -1; } initSingleEmptyBuffer(&inBufferDesc, &inBuffer); status = base64ToBuffer(base64Token, &inBufferDesc); if (status) { freeBuffer(&outBufferDesc); return status; } securityStatus = initializeSecurityContext(&sspiContext->credentials, &(sspiContext->context), sspiContext->serverName, contextFlags, &inBufferDesc, &(sspiContext->context), &outBufferDesc); if (securityStatus == SEC_E_OK) { sspiContext->authfinished = 1; } freeBuffer(&inBufferDesc); } else { if (sspiContext->continueNeeded) { freeBuffer(&outBufferDesc); NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: Expected a token from server.\n"); return -1; } if (sspiContext->authfinished && (sspiContext->credentials.dwLower || sspiContext->credentials.dwUpper)) { if (sspiContext->authfinished) { freeBuffer(&outBufferDesc); sspiContext->authfinished = 0; NE_DEBUG(NE_DBG_HTTPAUTH,"sspi: failing because starting over from failed try.\n"); return -1; } sspiContext->authfinished = 0; } /* Reset any existing context since we are starting over */ resetContext(sspiContext); if (acquireCredentialsHandle (&sspiContext->credentials, sspiContext->mechanism) != SEC_E_OK) { freeBuffer(&outBufferDesc); NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: acquireCredentialsHandle failed.\n"); return -1; } securityStatus = initializeSecurityContext(&sspiContext->credentials, NULL, sspiContext->serverName, contextFlags, NULL, &(sspiContext->context), &outBufferDesc); } if (securityStatus == SEC_I_COMPLETE_AND_CONTINUE || securityStatus == SEC_I_COMPLETE_NEEDED) { SECURITY_STATUS compleStatus = pSFT->CompleteAuthToken(&(sspiContext->context), &outBufferDesc); if (compleStatus != SEC_E_OK) { freeBuffer(&outBufferDesc); NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: CompleteAuthToken failed.\n"); return -1; } } if (securityStatus == SEC_I_COMPLETE_AND_CONTINUE || securityStatus == SEC_I_CONTINUE_NEEDED) { sspiContext->continueNeeded = 1; } else { sspiContext->continueNeeded = 0; } if (!(securityStatus == SEC_I_COMPLETE_AND_CONTINUE || securityStatus == SEC_I_COMPLETE_NEEDED || securityStatus == SEC_I_CONTINUE_NEEDED || securityStatus == SEC_E_OK)) { NE_DEBUG(NE_DBG_HTTPAUTH, "sspi: initializeSecurityContext [failed] [%x].\n", securityStatus); freeBuffer(&outBufferDesc); return -1; } *responseToken = ne_base64(outBufferDesc.pBuffers->pvBuffer, outBufferDesc.pBuffers->cbBuffer); freeBuffer(&outBufferDesc); return 0; }
//Procedura tworz¹ca bufory VBO zawieraj¹ce dane z tablic opisuj¹cych rysowany obiekt. void setupVBO() { bufTexCoords = makeBuffer(texCoords, vertexCount, sizeof(float)* 2); bufVertices = makeBuffer(vertices, vertexCount, sizeof(float)* 4); //Wspó³rzêdne wierzcho³ków bufColors = makeBuffer(colors, vertexCount, sizeof(float)* 4);//Kolory wierzcho³ków bufNormals = makeBuffer(normals, vertexCount, sizeof(float)* 4);//Wektory normalne wierzcho³ków }
s32 main(s32 argc, const char* argv[]) { gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; padInfo padinfo ; padData paddata ; u16 width; u16 height; int i; long frame = 0; /* to keep track of how many frames we have rendered */ atexit(unload_modules); if(sysModuleLoad(SYSMODULE_FS) != 0) return 0; else module_flag |= 1; if(sysModuleLoad(SYSMODULE_PNGDEC) != 0) return 0; else module_flag |= 2; /* Allocate a 1Mb buffer, alligned to a 1Mb boundary * to be our shared IO memory with the RSX. */ host_addr = memalign ( 1024*1024, HOST_SIZE ) ; context = screenInit ( host_addr, HOST_SIZE ) ; getResolution( &width, &height ) ; for (i = 0; i < MAX_BUFFERS; i++) makeBuffer( &buffers[i], width, height, i ) ; flip( context, MAX_BUFFERS - 1 ) ; setRenderTarget(context, &buffers[currentBuffer]) ; sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL); ioPadInit(7) ; /* png bitmap buffer */ pngData png1; #if USE_PNG_FROM_FILE == true const char *filename = PNG_FILE; /* load png from file */ pngLoadFromFile(filename, &png1); #endif #if USE_PNG_FROM_FILE == false /* load png from memory */ pngLoadFromBuffer((void *)psl1ght_png, psl1ght_png_size, &png1); #endif /* Ok, everything is setup. Now for the main loop. */ exitapp = 1; while(exitapp) { /* Check the pads. */ ioPadGetInfo(&padinfo); for(i=0; i<MAX_PADS; i++){ if(padinfo.status[i]){ ioPadGetData(i, &paddata); if(paddata.BTN_CROSS){ exitapp = 0; goto end; } } } waitFlip(); // Wait for the last flip to finish, so we can draw to the old buffer drawFrame(&buffers[currentBuffer], frame++); // Draw into the unused buffer if(png1.bmp_out) { static int x=0, y=0, dx=2, dy=2; u32 *scr = (u32 *)buffers[currentBuffer].ptr; u32 *png= (void *)png1.bmp_out; int n, m; /* update x, y coordinates */ x+=dx; y+=dy; /* */ if(x < 0) { x=0; dx=1; } /* screen width to png width */ if(x > (buffers[currentBuffer].width - png1.width)) { x=(buffers[currentBuffer].width - png1.width); dx=-2; } /* */ if(y < 0) { y=0; dy=1; } /* screen height to png height */ if(y > (buffers[currentBuffer].height - png1.height)) { y = (buffers[currentBuffer].height - png1.height); dy=-2; } /* update screen buffer from coordinates */ scr += y * buffers[currentBuffer].width + x; // draw PNG for(n=0;n<png1.height;n++) { if((y+n)>=buffers[currentBuffer].height) break; for(m=0;m<png1.width;m++) { if((x+m)>=buffers[currentBuffer].width) break; scr[m]=png[m]; } png+=png1.pitch>>2; scr+=buffers[currentBuffer].width; } } flip(context, buffers[currentBuffer].id); /* Flip buffer onto screen */ currentBuffer = !currentBuffer; setRenderTarget(context, &buffers[currentBuffer]) ; /* change buffer */ sysUtilCheckCallback(); /* check user attention span */ } end: gcmSetWaitFlip(context); for (i=0; i < MAX_BUFFERS; i++) rsxFree (buffers[i].ptr); rsxFinish (context, 1); free (host_addr); ioPadEnd(); return 0; }
void meshModels::cacheCylinder(float vertsX[], float vertsY[], float depth) { dir = TRUE; cacheEndCap( vertsX, vertsY, 0.0f); dir = FALSE; cacheEndCap( vertsX, vertsY, depth); dir = FALSE; // objects to build our vertices in vertex_t vertA, vertB, vertC; polygon_t poly; int i = 0; int j; int faceCount; // find out how many verts we have int vcount = model.verts.size(); int endGon = vcount; // and saving the starting vertice index for later //record all three points as a triangle in our structure poly.a = vcount; poly.b = vcount +1; poly.c = vcount +2; // we need to start with two verts because then //we only need to add 2 verts to get 2 new triangles in the for loop // build our first vertex vertA.x = vertsX[i]; vertA.y = vertsY[i]; vertA.z = 0.0f; // push it into our array model.verts.reserve(poly.a); model.verts.push_back(vertA); //build our third vertex vertB.x = vertsX[i]; vertB.y = vertsY[i]; vertB.z = depth; // push it into our array model.verts.reserve(poly.b); model.verts.push_back(vertB); i++; // build a cylinder 2 triangles at a time for( j = 0; j < 62; ++j) { // ensure our array iterator is not too large if(i>=32) i = 0; //record all three points as a triangle in our structure poly.a = vcount; poly.b = vcount +1; poly.c = vcount +2; //build our second vertex vertC.x = vertsX[i]; vertC.y = vertsY[i]; vertC.z = 0.0f; // push it into our array model.verts.reserve(poly.c); model.verts.push_back(vertC); // record the triangle model.polys.reserve(j); model.polys.push_back(poly); faceCount = model.polys.size()-1; calculateFaceNormal(faceCount); j++; // advance to the next polygon // vertex A is really the old vertex b so lets record the change here poly.a = poly.b; vertB.x = vertsX[i]; vertB.y = vertsY[i]; vertB.z = depth; poly.b = model.verts.size(); // set the iterator for the new vertex model.verts.reserve(poly.b); model.verts.push_back(vertB); // VertC is the same and remains unchanged // lets store our triangle model.polys.reserve(j); model.polys.push_back(poly); faceCount = model.polys.size()-1; calculateFaceNormal(faceCount); vcount = vcount +2; i++; } // add our last two triangles using existing verts poly.a = model.verts.size() - 2; poly.b = model.verts.size() - 1; poly.c = endGon; model.polys.reserve(vcount); model.polys.push_back(poly); faceCount = model.polys.size()-1; calculateFaceNormal(faceCount); // add our last two triangles using existing verts poly.a = model.verts.size() - 1; poly.b = endGon + 1; poly.c = endGon; model.polys.reserve(vcount + 1); model.polys.push_back(poly); faceCount = model.polys.size()-1; calculateFaceNormal(faceCount); normalizeVerts(); makeShader(); makeBuffer(); }
RecordBuffer* DbCreatorsList::getList(thread_db* tdbb, jrd_rel* relation) { fb_assert(relation); fb_assert(relation->rel_id == rel_sec_db_creators); RecordBuffer* buffer = getData(relation); if (buffer) { return buffer; } RefPtr<IAttachment> att; RefPtr<ITransaction> tra; const char* dbName = tdbb->getDatabase()->dbb_config->getSecurityDatabase(); if (!openDb(dbName, att, tra)) { // In embedded mode we are not raising any errors - silent return if (MasterInterfacePtr()->serverMode(-1) < 0) return makeBuffer(tdbb); (Arg::Gds(isc_crdb_nodb) << dbName).raise(); } Message gr; Field<ISC_SHORT> uType(gr); Field<Varying> u(gr, MAX_SQL_IDENTIFIER_LEN); FbLocalStatus st; RefPtr<IResultSet> curs(att->openCursor(&st, tra, 0, "select RDB$USER_TYPE, RDB$USER from RDB$DB_CREATORS", SQL_DIALECT_V6, NULL, NULL, gr.getMetadata(), NULL, 0)); if (st->getState() & IStatus::STATE_ERRORS) { if (!fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err)) check("IAttachment::openCursor", &st); // isc_dsql_relation_err when opening cursor - i.e. table // is missing due to non-FB3 security DB // In embedded mode we are not raising any errors - silent return if (MasterInterfacePtr()->serverMode(-1) < 0) return makeBuffer(tdbb); (Arg::Gds(isc_crdb_notable) << dbName).raise(); } try { buffer = makeBuffer(tdbb); while (curs->fetchNext(&st, gr.getBuffer()) == IStatus::RESULT_OK) { Record* record = buffer->getTempRecord(); record->nullify(); putField(tdbb, record, DumpField(f_sec_crt_user, VALUE_STRING, u->len, u->data)); SINT64 v = uType; putField(tdbb, record, DumpField(f_sec_crt_u_type, VALUE_INTEGER, sizeof(v), &v)); buffer->store(record); } check("IResultSet::fetchNext", &st); } catch (const Exception&) { clearSnapshot(); throw; } return getData(relation); }
int main(s32 argc, const char* argv[]) { //Mutex. sys_mutex_attr_t attr; memset(&attr, 0, sizeof(attr)); attr.attr_protocol = SYS_MUTEX_PROTOCOL_FIFO; attr.attr_recursive = SYS_MUTEX_ATTR_NOT_RECURSIVE; attr.attr_pshared = SYS_MUTEX_ATTR_PSHARED; attr.attr_adaptive = SYS_MUTEX_ATTR_NOT_ADAPTIVE; strcpy(attr.name, "mutex"); sysMutexCreate(&thread_mutex, &attr); //Threads. THREADS_RUNNING = 2; sys_ppu_thread_t pad_id, program_id; sysThreadCreate(&pad_id, pad_thread, (void*) &GLOBAL_EXIT, 1500, 0x400, 0, "pad"); sysThreadCreate(&program_id, program_thread, (void*) &GLOBAL_EXIT, 1337, 0x400, 0, "program"); //Create buffers. gcmContextData *context; void *host_addr = NULL; rsxBuffer buffers[MAX_BUFFERS]; int currentBuffer = 0; //Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. host_addr = memalign(1024*1024, HOST_SIZE); context = initScreen(host_addr, HOST_SIZE); //Get resolution. u16 width, height; getResolution(&width, &height); //Create buffers. int i; for(i = 0; i < MAX_BUFFERS; i++) { makeBuffer(&buffers[i], width, height, i); } flip(context, MAX_BUFFERS - 1); //Main loop. while(THREADS_RUNNING > 0) { //Prepare buffer. setRenderTarget(context, &buffers[currentBuffer]); waitFlip(); //Flip buffer onto screen. flip(context, buffers[currentBuffer].id); //Change buffer. currentBuffer++; if(currentBuffer >= MAX_BUFFERS) { currentBuffer = 0; } } //Free buffers. gcmSetWaitFlip(context); for(i = 0; i < MAX_BUFFERS; i++) { rsxFree(buffers[i].ptr); } rsxFinish(context, 1); free(host_addr); //Mutex destroy. sysMutexDestroy(thread_mutex); return 0; }
GLuint makeBuffer(const std::string &filePath){ GLuint bufferName; glGenBuffers(1, &bufferName); makeBuffer(bufferName, filePath); return bufferName; }
NoRSX::NoRSX(int real_screen_type, int buffer_screen_type) : EventHandler(){ screen_type = real_screen_type; buffer_type = buffer_screen_type; currentBuffer = 0; host_addr = memalign(1024*1024, HOST_SIZE); switch(real_screen_type){ case RESOLUTION_1920x1080: { width=1920;height=1080; buffers[0].width=1920;buffers[0].height=1080; buffers[1].width=1920;buffers[1].height=1080; } break; case RESOLUTION_1280x720: { width=1280;height=720; buffers[0].width=1280;buffers[0].height=720; buffers[1].width=1280;buffers[1].height=720; } break; case RESOLUTION_720x576: { width=720;height=576; buffers[0].width=720;buffers[0].height=576; buffers[1].width=720;buffers[1].height=576; } break; case RESOLUTION_720x480: { width=720;height=480; buffers[0].width=720;buffers[0].height=480; buffers[1].width=720;buffers[1].height=480; } break; default: getResolution(&width,&height); switch(real_screen_type){ default: case RESOLUTION_AUTO_LOWER_1080p: { if(height>=1080){ real_screen_type = RESOLUTION_1280x720; width=1280;height=720; buffers[0].width=1280;buffers[0].height=720; buffers[1].width=1280;buffers[1].height=720; }else real_screen_type = RESOLUTION_AUTO; } break; case RESOLUTION_AUTO_LOWER_720p: { if(height>=720){ real_screen_type = RESOLUTION_720x576; width=720;height=576; buffers[0].width=720;buffers[0].height=576; buffers[1].width=720;buffers[1].height=576; }else real_screen_type = RESOLUTION_AUTO; } break; case RESOLUTION_AUTO_LOWER_576p: { if(height>=576){ real_screen_type = RESOLUTION_720x480; width=720;height=480; buffers[0].width=720;buffers[0].height=480; buffers[1].width=720;buffers[1].height=480; }else real_screen_type = RESOLUTION_AUTO; } break; real_screen_type = RESOLUTION_AUTO; break; } break; } context = initScreen(host_addr, HOST_SIZE, real_screen_type, width, height); for(int i=0;i<2;i++) makeBuffer(&buffers[i],width,height,i); switch(buffer_screen_type){ case RESOLUTION_1920x1080: width=1920; height=1080; break; case RESOLUTION_1280x720: width=1280; height=720; break; case RESOLUTION_720x576: width=720; height=576; break; case RESOLUTION_720x480: width=720; height=480; break; default: getResolution(&width,&height); break; } buffer = makeMemBuffer(width,height,&buffer_size); buffer_size = buffers[0].width * buffers[0].height * sizeof(u32); flip(context, 0); setRenderTarget(context, &buffers[0]); RegisterCallBack(EVENT_SLOT0); }