view Renderer/test_render/viewer_types.cpp @ 283:55ea4465b1a2

fix test_render
author e065746@localhost.localdomain
date Fri, 05 Jun 2009 16:49:12 +0900
parents
children
line wrap: on
line source

#include "viewer_types.h"

static int
getLocalPosition(int d, int offset)
{
    /**
     * offset が 2 の冪乗の時だけ使える。
     * 現在は offset は 2 の冪乗のみなので
     * これで問題ないけどどうなの?
     */
    return d & (offset-1);

    // offset が 2 の冪乗以外はこれにしないとだめ
    //return d % offset;
}

/**
 * ワールド座標における x の値を
 * split_screen_w で分割した領域(1 〜 split_screen_w)での座標に変換する
 * (ex. split_screen_w が 256 の場合、
 *      x =   1 -> 1
 *      x = 256 -> 256
 *      x = 257 -> 1
 */
int
getLocalX(int x)
{
    return getLocalPosition(x, split_screen_w);
}

/**
 * getLocalX に同じ
 */
int
getLocalY(int y)
{
    return getLocalPosition(y, split_screen_h);
}