void Renderer::onDraw(al::Graphics& gl) { int faceIndex = mOmni.face(); { // render cubemap if (cubemap && cubemap->getEyesCount() > 0) { Cubemap* eye = cubemap->getEye(0); if (eye->getFacesCount() > faceIndex) { CubemapFace* face = eye->getFace(faceIndex); glUseProgram(0); glDepthMask(GL_FALSE); // draw the background glDrawPixels(face->getWidth(), face->getHeight(), GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)face->getPixels()); glDepthMask(GL_TRUE); if(newCubemap) { if (onDisplayedCubemapFace) onDisplayedCubemapFace(this, faceIndex); } } } } light(); mShader.begin(); mOmni.uniforms(mShader); gl.pushMatrix(); //gl.draw(cube); gl.pushMatrix(); // rotate over time: gl.rotate(now*30., 0.707, 0.707, 0.); gl.translate(1., 1., 1.); //gl.draw(sphere); gl.popMatrix(); gl.popMatrix(); mShader.end(); }
void addFaceSubstreams0(void*) { int portCounter = 0; for (int j = 0; j < cubemap->getEyesCount(); j++) { Cubemap* eye = cubemap->getEye(j); for (int i = 0; i < eye->getFacesCount(); i++) { faceStreams.push_back(FrameStreamState()); FrameStreamState* state = &faceStreams.back(); state->content = eye->getFace(i)->getContent(); Port rtpPort(FACE0_RTP_PORT_NUM + portCounter); portCounter += 2; Groupsock* rtpGroupsock = new Groupsock(*env, destinationAddress, rtpPort, TTL); //rtpGroupsock->multicastSendOnly(); // we're a SSM source setReceiveBufferTo(*env, rtpGroupsock->socketNum(), bufferSize); // Create a 'H264 Video RTP' sink from the RTP 'groupsock': state->sink = H264VideoRTPSink::createNew(*env, rtpGroupsock, 96); ServerMediaSubsession* subsession = PassiveServerMediaSubsession::createNew(*state->sink); cubemapSMS->addSubsession(subsession); RawPixelSource* source = RawPixelSource::createNew(*env, state->content, avgBitRate); source->setOnSentNALU (boost::bind(&onSentNALU, _1, _2, _3, j, i)); source->setOnEncodedFrame(boost::bind(&onEncodedFrame, _1, j, i)); state->source = H264VideoStreamDiscreteFramer::createNew(*env, source); state->sink->startPlaying(*state->source, NULL, NULL); std::cout << "Streaming face " << i << " (" << ((j == 0) ? "left" : "right") << ") on port " << ntohs(rtpPort.num()) << " ..." << std::endl; } } announceStream(rtspServer, cubemapSMS, cubemapStreamName); }
extern "C" void EXPORT_API UnityRenderEvent (int eventID) { // When we use the RenderCubemap.cs and USeRenderingPlugin.cs scripts // This function will get called twice (with different eventIDs). // We have to make sure that the extraction only happens once for the cubemap // and binoculars respectively! if (eventID == 1) { // Allocate cubemap the first time we render a frame. // By doing so, we can make sure that both // the cubemap and the binoculars are fully configured. if (!thisProcess) { allocateSHM(cubemapConfig, binocularsConfig); } presentationTime = boost::chrono::system_clock::now(); std::vector<Frame*> frames; if (cubemap) { for (int j = 0; j < cubemap->getEyesCount(); j++) { Cubemap* eye = cubemap->getEye(j); for (int i = 0; i < eye->getFacesCount(); i++) { frames.push_back(eye->getFace(i)->getContent()); } } } if (binoculars) { frames.push_back(binoculars->getContent()); } copyFromGPUtoCPU(frames); } }
CubemapStereoFrame(StereoCubemap* cubemap) : cubemap_(cubemap) { Cubemap* left = cubemap_->getEye(0); Cubemap* right = cubemap_->getEye(1); if(cubemap_->getEyesCount() == 2) { faces[0][0] = new CubemapPixelData(left->getFace(0)); faces[0][1] = new CubemapPixelData(left->getFace(1)); faces[0][2] = new CubemapPixelData(left->getFace(2)); faces[0][3] = new CubemapPixelData(left->getFace(3)); faces[0][4] = new CubemapPixelData(left->getFace(4)); faces[0][5] = new CubemapPixelData(left->getFace(5)); faces[1][0] = new CubemapPixelData(right->getFace(0)); faces[1][1] = new CubemapPixelData(right->getFace(1)); faces[1][2] = new CubemapPixelData(right->getFace(2)); faces[1][3] = new CubemapPixelData(right->getFace(3)); faces[1][4] = new CubemapPixelData(right->getFace(4)); faces[1][5] = new CubemapPixelData(right->getFace(5)); } else { faces[0][0] = new CubemapPixelData(left->getFace(0)); faces[0][1] = new CubemapPixelData(left->getFace(1)); faces[0][2] = new CubemapPixelData(left->getFace(2)); faces[0][3] = new CubemapPixelData(left->getFace(3)); faces[0][4] = new CubemapPixelData(left->getFace(4)); faces[0][5] = new CubemapPixelData(left->getFace(5)); faces[1][0] = new CubemapPixelData(left->getFace(0)); faces[1][1] = new CubemapPixelData(left->getFace(1)); faces[1][2] = new CubemapPixelData(left->getFace(2)); faces[1][3] = new CubemapPixelData(left->getFace(3)); faces[1][4] = new CubemapPixelData(left->getFace(4)); faces[1][5] = new CubemapPixelData(left->getFace(5)); } }