Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ...
- BYTE *pixels;
- void initGL(void) {
- /* init GLFW, GLEW...*/
- glEnable(GL_TEXTURE_2D);
- glGenTextures(1, &gltexture);
- glBindTexture(GL_TEXTURE_2D, gltexture);
- pixels = new BYTE[texW * texH * 3];
- memset(pixels, 0x90, texW * texH * 3);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texW, texH, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
- glBindTexture(GL_TEXTURE_2D, 0);
- /* generate framebuffer */
- /* THIS piece of code */
- /* vvvvvvvvvvvvvvvvvv */
- glGenFramebuffers(1, &fbo);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gltexture, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- /* ^^^^^^^^^^^^^^^^^^ */
- }
- /* It's standard usage */
- void draw(void) {
- ovrFrameTiming hmdFrameTiming = ovrHmd_BeginFrame(hmd, 0);
- for (int i = 0; i < 2; ++i) {
- ovrEyeType eye = hmdDesc.EyeRenderOrder[i];
- ovrPosef eyePose = ovrHmd_BeginEyeRender(hmd, eye);
- ovrHmd_EndEyeRender(hmd, eye, eyePose, &eyeTexture[i].Texture);
- }
- ovrHmd_EndFrame(hmd);
- }
- void initOR(void) {
- // creating ovrHmd, ... ovrHmdDesc
- ovrGLConfig cfg;
- memset(&cfg, 0, sizeof(cfg));
- memset(eyes, 0, sizeof(eyes));
- cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
- cfg.OGL.Header.RTSize = { screenW, screenH };
- cfg.OGL.Header.Multisample = 1;
- cfg.OGL.Window = 0;
- ovrFovPort fov[2];
- // setting fov...
- if (!ovrHmd_ConfigureRendering(hmd, &cfg.Config, ovrDistortionCap_TimeWarp | ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette, fov, eyes)) {
- MSG("Can't configure OculusRift rendering!");
- exit(EXIT_FAILURE);
- }
- for (int i = 0; i < 2; ++i) {
- eyeTexture[i].OGL.Header.API = ovrRenderAPI_OpenGL;
- eyeTexture[i].OGL.Header.TextureSize = { texW, texH };
- eyeTexture[i].OGL.Header.RenderViewport.Pos = { i*(screenW >> 1), 0 };
- eyeTexture[i].OGL.Header.RenderViewport.Size = { screenW >> 1, screenH };
- eyeTexture[i].OGL.TexId = gltexture;
- }
- }
- // ....
Advertisement
Add Comment
Please, Sign In to add comment