예제 #1
0
static void Render(int frameNumber) {
  RaycastCalculateView(frameNumber);

  PROFILE(RaycastTunnel)
    RaycastTunnel(smallMap, CameraView.Transformed);

  PROFILE (UVMapScale8x)
    UVMapScale8x(uvmap, smallMap);

  UVMapSetTexture(uvmap, texture);
  UVMapSetOffset(uvmap, 0, frameNumber);

  PROFILE (UVMapRender)
    UVMapRender(uvmap, canvas);

  PROFILE (RenderShadeMap)
    RenderShadeMap(shades, uvmap->map.normal.v);

  PixBufSetColorMap(shades, colorMap);
  PixBufSetBlitMode(shades, BLIT_COLOR_MAP);

  PROFILE (BlitShadeMap)
    PixBufBlit(canvas, 0, 0, shades, NULL);

  PROFILE (ChunkyToPlanar)
    c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #2
0
static void Render(int frameNumber) {
  PixBufT *umap;

  int du = frameNumber;
  int dv = 2 * frameNumber;
  int i;

  umap = NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u);

  UVMapSetOffset(uvmap, du, dv);
  PixBufBlit(umap, 0, 0, origU, NULL);

  for (i = 0; i < 8; i++) {
    PixBufSetBlitMode(flare, BLIT_ADDITIVE);
    PixBufBlit(umap, 
               (int)(128.0f + sin(-frameNumber * M_PI / 45.0f + M_PI * i / 4) * 80.0f), 
               (int)(96.0f + cos(-frameNumber * M_PI / 45.0f + M_PI * i / 4) * 48.0f),
               flare, NULL);
  }

  UVMapRender(uvmap, canvas);

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);

  MemUnref(umap);
}
예제 #3
0
파일: object3d.c 프로젝트: argasek/morphine
void RenderMesh(int frameNumber_) {
  PixBufT *canvas = R_("Canvas");
  SceneT *scene = R_("Scene");
  float frameNumber = frameNumber_;
  float s = sin(frameNumber * 3.14159265f / 90.0f) + 1.0f;

  {
    MatrixStack3D *ms = GetObjectTranslation(scene, "Object");

    StackReset(ms);
    PushScaling3D(ms, 0.75f + 0.5f * s, 0.75f + 0.5f * s, 0.75f + 0.5f * s);
    PushRotation3D(ms, 0, (float)(-frameNumber * 2), frameNumber);
    PushTranslation3D(ms, 0.0f, 0.0f, -2.0f);
  }

  PixBufClear(canvas);
#if 0
  RenderFlatShading = true;
  PixBufSetColorMap(canvas, R_("ColorMap"), -32);
#endif
  PROFILE(RenderScene)
    RenderScene(scene, canvas);

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #4
0
/*
 * Effect rendering functions.
 */
void RenderEffect(int frameNumber) {
  PixBufT *canvas = R_("Canvas");
  UVMapT *uvmap = R_("Map");
  PixBufT *comp = R_("Component");
  PixBufT *shades = R_("Shades");
  uint8_t *cfunc = R_("ColFunc");

  int du = 2 * frameNumber;
  int dv = 4 * frameNumber;

  {
    int i;

    for (i = 0; i < 256; i++) {
      uint8_t v = i + du;

      if (v >= 128)
        cfunc[i] = ~v * 2;
      else 
        cfunc[i] = v * 2;
    }
  }

  PixBufSetBlitMode(comp, BLIT_COLOR_FUNC);
  PixBufSetColorFunc(comp, cfunc);
  PROFILE (PixBufBlitWithColorFunc)
    PixBufBlit(shades, 0, 0, comp, NULL);

  UVMapSetOffset(uvmap, du, dv);
  PROFILE (UVMapRenderFast)
    UVMapRender(uvmap, canvas);

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #5
0
static void Render(int frameNumber) {
  int du = 2 * frameNumber;
  int dv = 4 * frameNumber;

  {
    int i;

    for (i = 0; i < 256; i++) {
      uint8_t v = i + du;

      if (v >= 128)
        colorFunc[i] = ~v * 2;
      else 
        colorFunc[i] = v * 2;
    }
  }

  PixBufSetBlitMode(component, BLIT_COLOR_FUNC);
  PixBufSetColorFunc(component, colorFunc);
  PROFILE (PixBufBlitWithColorFunc)
    PixBufBlit(shades, 0, 0, component, NULL);

  UVMapSetOffset(uvmap, du, dv);
  PROFILE (UVMapRenderFast)
    UVMapRender(uvmap, canvas);

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #6
0
파일: fire.c 프로젝트: argasek/morphine
void RenderEffect(int frameNumber) {
  PixBufT *canvas = R_("Canvas");

  PROFILE(Fire)
    RenderFire(canvas);
  PROFILE(C2P)
    c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #7
0
파일: uvmap.c 프로젝트: cahirwpz/demoscene
static void Render(int frameNumber) {
  int du = 2 * frameNumber;
  int dv = 4 * frameNumber;

  UVMapSetOffset(uvmap, du, dv);
  PROFILE(UVMapRender)
    UVMapRender(uvmap, canvas);
  PROFILE(C2P)
    c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #8
0
static void Render(int frameNumber) {
  int change = (frameNumber * 2) % 256;

  switch (effect) {
    case 0:
      PROFILE(PixBufCopy)
        PixBufCopy(canvas, image);
      PROFILE(PixBufAddAndClamp)
        PixBufAddAndClamp(shade, map[0], change);
      PixBufSetColorMap(shade, lighten);
      PixBufSetBlitMode(shade, BLIT_COLOR_MAP);
      PROFILE(PixBufBlit)
        PixBufBlit(canvas, 0, 0, shade, NULL);
      break;

    case 1:
      PROFILE(PixBufCopy)
        PixBufCopy(canvas, image);
      PROFILE(PixBufAddAndClamp)
        PixBufAddAndClamp(shade, map[0], change - 64);
      PixBufSetColorMap(shade, darken);
      PixBufSetBlitMode(shade, BLIT_COLOR_MAP);
      PROFILE(PixBufBlit)
        PixBufBlit(canvas, 0, 0, shade, NULL);
      break;

    case 2:
      PROFILE(PixBufCopy)
        PixBufCopy(canvas, image);
      PROFILE(PixBufAddAndClamp)
        PixBufAddAndClamp(shade, map[1], change - 64);
      PixBufSetColorMap(shade, lighten);
      PixBufSetBlitMode(shade, BLIT_COLOR_MAP);
      PROFILE(PixBufBlit)
        PixBufBlit(canvas, 0, 0, shade, NULL);
      break;

    case 3:
      PROFILE(PixBufCopy)
        PixBufCopy(canvas, image);
      PROFILE(PixBufAddAndClamp)
        PixBufAddAndClamp(shade, map[1], change - 64);
      PixBufSetColorMap(shade, darken);
      PixBufSetBlitMode(shade, BLIT_COLOR_MAP);
      PROFILE(PixBufBlit)
        PixBufBlit(canvas, 0, 0, shade, NULL);
      break;

    default:
      break;
  }

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #9
0
static void Render(int frameNumber) {
  PointT *toDraw = triangleToDraw;

  float s = sin(frameNumber * 3.14159265f / 22.5f);
  float c = cos(frameNumber * 3.14159265f / 45.0f);

  StackReset(ms);
  PushTranslation2D(ms, -1.5f, -1.5f);
  PushScaling2D(ms, 20.0f + 10.0f * s, 20.0f + 10.0f * s);
  PushRotation2D(ms, (float)(frameNumber * -3));
  PushTranslation2D(ms, (float)(WIDTH/2) + c * (WIDTH/4), (float)(HEIGHT/2));

  Transform2D(crossToDraw, cross, 12, GetMatrix2D(ms, 0));

  if (effect == 0) {
    PixBufClear(canvas);
    DrawPolyLine(canvas, crossToDraw, 12, TRUE);
  }

  StackReset(ms);
  PushTranslation2D(ms, 5.0f, 10.0f);
  PushScaling2D(ms, 2.5f, 2.5f);
  PushRotation2D(ms, (float)(frameNumber*5*c));
  PushTranslation2D(ms, WIDTH/2 + c * 50, HEIGHT/2 + s * 20);

  Transform2D(triangleToDraw, triangle, 3, GetMatrix2D(ms, 0));

  frameNumber &= 255;

  if (frameNumber < 128)
    canvas->fgColor = frameNumber * 2;
  else 
    canvas->fgColor = (255 - frameNumber) * 2;

  if (effect == 1) {
    TriPoint p1 = { toDraw[0].x, toDraw[0].y };
    TriPoint p2 = { toDraw[1].x, toDraw[1].y };
    TriPoint p3 = { toDraw[2].x, toDraw[2].y };
    DrawTriangle(canvas, &p1, &p2, &p3);
  }

  if (effect == 2) {
    DrawEllipse(canvas,
                toDraw[1].x, toDraw[1].y,
                30 + c * 15, 30 + s * 15);
  }

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #10
0
파일: blur.c 프로젝트: cahirwpz/demoscene
static void Render(int frameNumber) {
  if (init) {
    PixBufCopy(buffer, image);
    init = false;
  }

  if (effect == 0)
    BlurV3(canvas, buffer);
  if (effect == 1)
    BlurH3(canvas, buffer);

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);

  PixBufSwapData(canvas, buffer);
}
예제 #11
0
static void Render(int frameNumber) {
  PixBufT *umap;

  int du = 2 * frameNumber;
  int dv = 4 * frameNumber;

  {
    MatrixStack3D *ms = GetObjectTranslation(scene, "Object");

    StackReset(ms);
    PushScaling3D(ms, 1.25f, 1.25f, 1.25f);
    PushRotation3D(ms, 0, (float)(-frameNumber * 2), frameNumber);
    PushTranslation3D(ms, 0.0f, 0.0f, -2.0f);
  }

  if (effectNum == 0) {
    umap = NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u);

    PROFILE(PixBufClear)
      PixBufClear(shades);
    PROFILE(RenderScene)
      RenderScene(scene, shades);

    PixBufSetBlitMode(shades, BLIT_ADDITIVE);
    PixBufBlit(umap, 0, 0, orig, NULL);
    PixBufBlit(umap, 0, 0, shades, NULL);

    UVMapSetOffset(uvmap, du, dv);
    UVMapRender(uvmap, canvas);

    MemUnref(umap);
  } else {
    UVMapSetOffset(uvmap, du, dv);
    UVMapRender(uvmap, canvas);

    PROFILE(PixBufClear)
      PixBufClear(shades);
    PROFILE(RenderScene)
      RenderScene(scene, shades);

    PixBufSetColorMap(shades, colorMap);
    PixBufSetBlitMode(shades, BLIT_COLOR_MAP);

    PixBufBlit(canvas, 0, 0, shades, NULL);
  }

  c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}
예제 #12
0
/*
 * Load demo.
 */
bool LoadDemo() {
  const char *loadImgPath = JsonQueryString(DemoConfig, "load/image");
  const char *loadPalPath = JsonQueryString(DemoConfig, "load/palette");
  const char *musicPath = JsonQueryString(DemoConfig, "music/file");

  if ((TheLoadImg = NewPixBufFromFile(loadImgPath)) &&
      (TheLoadPal = NewPaletteFromFile(loadPalPath)) &&
      (TheMusic = AudioStreamOpen(musicPath)) &&
      (TheCanvas = NewPixBuf(PIXBUF_CLUT, WIDTH, HEIGHT)) &&
      InitDisplay(WIDTH, HEIGHT, DEPTH))
  {
    c2p1x1_8_c5_bm(TheLoadImg->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
    LoadPalette(TheLoadPal);
    DisplaySwap();

    return true;
  }

  return false;
}
예제 #13
0
void RenderChunky(int frameNumber) {
  c2p1x1_8_c5_bm(GetCanvasPixelData(R_("Canvas")),
                 GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0);
}