Skip to content

Commit

Permalink
Drawing only 3D stuff into custom framebuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tsoj committed Aug 7, 2022
1 parent 3b70c92 commit cb61589
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/Core/Universe.m
Original file line number Diff line number Diff line change
Expand Up @@ -4537,15 +4537,16 @@ - (BOOL) viewFrustumIntersectsSphereAt:(Vector)position withRadius:(GLfloat)radi
- (void) drawUniverse
{
OOLog(@"universe.profile.draw", @"%@", @"Begin draw");

if ((int)targetFramebufferSize.width != (int)[gameView viewSize].width || (int)targetFramebufferSize.height != (int)[gameView viewSize].height)
{
[self resizeTargetFramebufferWithViewSize:[gameView viewSize]];
}

glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID);
if (!no_update)
{

if ((int)targetFramebufferSize.width != (int)[gameView viewSize].width || (int)targetFramebufferSize.height != (int)[gameView viewSize].height)
{
[self resizeTargetFramebufferWithViewSize:[gameView viewSize]];
}

glBindFramebuffer(GL_FRAMEBUFFER, targetFramebufferID);

@try
{
no_update = YES; // block other attempts to draw
Expand Down Expand Up @@ -4731,7 +4732,7 @@ - (void) drawUniverse
if (bpHide && !drawthing->isImmuneToBreakPatternHide) continue;
if (vdist == 1 && [drawthing cameraRangeFront] > farPlane*1.5) continue;
if (vdist == 0 && [drawthing cameraRangeBack] < nearPlane) continue;
// if (vdist == 1 && [drawthing isPlanet]) continue;
// if (vdist == 1 && [drawthing isPlanet]) continue;

if (!((d_status == STATUS_COCKPIT_DISPLAY) ^ demoShipMode)) // either demo ship mode or in flight
{
Expand Down Expand Up @@ -4847,6 +4848,16 @@ - (void) drawUniverse
}



glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO);


OOLog(@"universe.profile.secondPassDraw", @"%@", @"Begin second pass draw");
[self drawTargetTextureIntoDefaultFramebuffer];
OOLog(@"universe.profile.secondPassDraw", @"%@", @"End second pass drawing");

OOLog(@"universe.profile.drawHUD", @"%@", @"Begin HUD drawing");

/* Reset for HUD drawing */
OOGLResetProjection();
OOGLFrustum(-0.5, 0.5, -aspect*0.5, aspect*0.5, 1.0, MAX_CLEAR_DEPTH);
Expand Down Expand Up @@ -4920,6 +4931,7 @@ - (void) drawUniverse
#if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))
[self drawWatermarkString:@"Development version " @OOLITE_SNAPSHOT_VERSION];
#endif
OOLog(@"universe.profile.drawHUD", @"%@", @"End HUD drawing");

OOCheckOpenGLErrors(@"Universe after drawing HUD");

Expand Down Expand Up @@ -4949,13 +4961,7 @@ - (void) drawUniverse
}
}
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultDrawFBO);
OOLog(@"universe.profile.draw", @"%@", @"End drawing");


OOLog(@"universe.profile.secondPassDraw", @"%@", @"Begin second pass draw");
[self drawTargetTextureIntoDefaultFramebuffer];
OOLog(@"universe.profile.secondPassDraw", @"%@", @"End second pass drawing");
}


Expand Down

0 comments on commit cb61589

Please sign in to comment.