This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...MyDualFramebufferView _myView; | |
- (void)viewWillLayoutSubviews | |
{ | |
CGRect rc = self.view.bounds; | |
GLfloat scale=1; | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) | |
{ | |
scale = [[UIScreen mainScreen] scale] ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLsizei cxFBO; | |
GLsizei cyFBO; | |
GLuint _frameBufferID; | |
GLuint _colorRenderBuffer; | |
GLuint _depthRenderBuffer; | |
GLuint _fboTextureID; | |
void MyDualFramebufferView::Resize(GLfloat width, GLfloat height, GLfloat scale) | |
{ | |
_scale = scale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect | |
{ | |
_myView->DrawToBackbuffer(); // this will draw in 2nd FBO | |
[((GLKView *) self.view) bindDrawable]; // reset to main framebuffer | |
_myView->RenderToMainscreen(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MyDualFramebufferView::DrawToBackbuffer(IDrawable& drawable) | |
{ | |
// use off screen FBO | |
glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferID); | |
glViewport(0,0, cxFBO, cyFBO); | |
glClearColor(0, 0, 0, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MyDualFramebufferView::RenderToMainscreen(IDrawable& drawable) | |
{ | |
// switch back to main | |
glClearColor(1, 0, 0, 1.0f); | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
// trigger mipmaps generation explicitly | |
glBindTexture(GL_TEXTURE_2D, _fboTextureID); | |
glGenerateMipmap(GL_TEXTURE_2D); | |
glBindTexture(GL_TEXTURE_2D, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2014 Michael A. R. Duncan | |
// You are free to do whatever you want with this source | |
// | |
// File: Galaxy1Compute.compute | |
// Each #kernel tells which function to compile; you can have many kernels | |
#pragma kernel UpdateStars | |
#include "Galaxy.cginc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Copyright | |
// Copyright 2014 Michael A. R. Duncan | |
// You are free to do whatever you want with this source | |
// File: Galaxy1Controller.cs | |
#endregion | |
#region |