Exemple #1
0
void GamePhase::execute(float const delta)
{
  ew::ControlContext* ctx = engine->getControlContext();
  if(actionKeyPush(ACTION_EXIT, ctx))
  {
    engine->setState(States::TITLE);
  }

  if(actionKeyPush(ACTION_PAUSE, ctx))
  {
    world->setPaused(!world->getPaused());
  }

  if(actionKeyPush(ACTION_SHOW_INFO, ctx))
  {
    world->hud->toggleShowFPS();
  }

  if(actionKeyPush(ACTION_SHOW_OVERDRAW, ctx)) {
    if(glhckRenderGetPass() & GLHCK_PASS_OVERDRAW) {
      glhckRenderPass(glhckRenderPassDefaults() & ~GLHCK_PASS_DEPTH);
    } else {
      glhckRenderPass(GLHCK_PASS_OVERDRAW);
    }
  }

  world->update(delta);
}
Exemple #2
0
/* \brief push 2D drawing state */
GLHCKAPI void glhckRenderStatePush2D(int width, int height, kmScalar near, kmScalar far)
{
   GLHCK_INITIALIZED();
   TRACE(2);
   glhckRenderStatePush();
   glhckRenderPass(glhckRenderGetPass() & ~GLHCK_PASS_DEPTH);
   glhckRenderProjection2D(width, height, near, far);
}
Exemple #3
0
/* \brief creates virtual display and inits renderer */
GLHCKAPI int glhckDisplayCreate(int width, int height, glhckRenderType renderType)
{
   GLHCK_INITIALIZED();
   CALL(0, "%d, %d, %d", width, height, renderType);

   if (width <= 0 && height <= 0)
      goto fail;

   /* close display if created already */
   if (GLHCKR()->type == renderType && renderType != GLHCK_RENDER_AUTO) goto success;
   else glhckDisplayClose();

   /* init renderer */
   switch (renderType) {
      case GLHCK_RENDER_AUTO:
#ifdef GLHCK_HAS_OPENGL
         _glhckRenderOpenGL();
         if (_glhckRenderInitialized()) break;
#endif
#ifdef GLHCK_HAS_OPENGL_FIXED_PIPELINE
         _glhckRenderOpenGLFixedPipeline();
         if (_glhckRenderInitialized()) break;
#endif
         _glhckRenderStub();
         break;

      case GLHCK_RENDER_OPENGL:
      case GLHCK_RENDER_GLES2:
#ifdef GLHCK_HAS_OPENGL
         _glhckRenderOpenGL();
#else
         DEBUG(GLHCK_DBG_ERROR, "OpenGL support was not compiled in!");
#endif
         break;
      case GLHCK_RENDER_OPENGL_FIXED_PIPELINE:
      case GLHCK_RENDER_GLES1:
#ifdef GLHCK_HAS_OPENGL_FIXED_PIPELINE
         _glhckRenderOpenGLFixedPipeline();
#else
         DEBUG(GLHCK_DBG_ERROR, "OpenGL Fixed Pipeline support was not compiled in!");
#endif
         break;
      case GLHCK_RENDER_STUB:
      default:
         _glhckRenderStub();
         break;
   }

   /* check that initialization was success */
   if (!_glhckRenderInitialized()) goto fail;

   /* check render api and output warnings,
    * if any function is missing */
   _glhckRenderCheckApi();
   GLHCKR()->type = renderType;

   /* default render pass bits */
   glhckRenderPass(glhckRenderPassDefaults());

   /* default cull face */
   glhckRenderCullFace(GLHCK_BACK);

   /* counter-clockwise are front face by default */
   glhckRenderFrontFace(GLHCK_CCW);

   /* resize display */
   glhckDisplayResize(width, height);

success:
   RET(0, "%d", RETURN_OK);
   return RETURN_OK;

fail:
   RET(0, "%d", RETURN_FAIL);
   return RETURN_FAIL;
}