本文整理汇总了C++中vec2i::x方法的典型用法代码示例。如果您正苦于以下问题:C++ vec2i::x方法的具体用法?C++ vec2i::x怎么用?C++ vec2i::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec2i
的用法示例。
在下文中一共展示了vec2i::x方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateSearch
void updateSearch() {
if (!valid(init) || !valid(goal)) {
return;
}
if (!checker or (changes & (GoalChanged | InflationChanged))) {
delete checker;
checker = 0;
checker = new BipedChecker(&grid, goal.x(), goal.y(), inflate_h, inflate_z);
}
searchResult = 0;
helper.clear();
double start = gettimeasdouble();
searchResult = helper.search(init.x(), init.y(), initTheta,
goal.x(), goal.y(), goalr,
checker, maxDepth, viewDepth);
planTime = gettimeasdouble() - start;
changes = NoChange;
}
示例2: valid
bool valid(const vec2i& p) {
return ( p.x() >= 0 &&
p.y() >= 0 &&
size_t(p.x()) < grid.nx() &&
size_t(p.y()) < grid.ny() &&
grid(p.x(), p.y()) );
}
示例3: setup
void setup()
{
size = window->getFramebufferSize();
if (grabber.open(0, size.x(), size.y()) < 0)
throw "Failed to open capture device";
if (grabber.start() < 0)
throw "Failed to start capture device";
}
示例4: eglCreateWindowSurface
EGLAPI EGLSurface EGLAPIENTRY
HookEglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win, const EGLint* attrib_list) {
// Apply scaler setting
ANativeWindow* window = Android_JNI_GetNativeWindow();
ANativeWindow_setBuffersGeometry(window, g_android_scaler_resolution.x(),
g_android_scaler_resolution.y(), 0);
return eglCreateWindowSurface(dpy, config, win, attrib_list);
}
示例5: cellType
int Grid::cellType(vec2i coord) {
int index = coord.y() * d_cols + coord.x();
if (d_map[index]) {
return 1;
} else {
d_map[index] = 1;
return 0;
}
}
示例6: InitializeRenderer
// Initialize the 'renderer_' member. No other members have been initialized at
// this point.
bool Game::InitializeRenderer() {
#ifdef __ANDROID__
vec2i window_size = GetWindowSize();
if (fplbase::IsTvDevice()) {
window_size = vec2i(kAndroidTvMaxScreenWidth, kAndroidTvMaxScreenHeight);
}
#else
vec2i window_size(1200, 800);
#endif // __ANDROID__
if (!renderer_.Initialize(window_size, GetConfig().window_title()->c_str())) {
LogError("Renderer initialization error: %s\n",
renderer_.last_error().c_str());
return false;
}
#ifdef __ANDROID__
// Restart the app if HW scaler setting failed.
auto retry = fplbase::LoadPreference("HWScalerRetry", 0);
const auto kMaxRetry = 3;
auto current_window_size = fplbase::AndroidGetScalerResolution();
if (current_window_size.x() != window_size.x() ||
current_window_size.y() != window_size.y()) {
if (retry < kMaxRetry) {
LogError("Restarting application.");
fplbase::SavePreference("HWScalerRetry", retry + 1);
fplbase::RelaunchApplication();
return false;
}
// The HW may not support the API. Fallback to native resolution pass until
// the API success next time.
} else {
// HW scaler setting was success. Clear retry counter.
fplbase::SavePreference("HWScalerRetry", 0);
}
#endif // __ANDROID__
renderer_.set_color(mathfu::kOnes4f);
// Initialize the first frame as black.
renderer_.ClearFrameBuffer(mathfu::kZeros4f);
#ifdef ANDROID_HMD
vec2i size = fplbase::AndroidGetScalerResolution();
const vec2i viewport_size =
size.x() && size.y() ? size : renderer_.window_size();
fplbase::InitializeUndistortFramebuffer(viewport_size.x(), viewport_size.y());
#endif // ANDROID_HMD
#if ZOOSHI_OVERDRAW_DEBUG
renderer_.SetBlendMode(BlendMode::kBlendModeAdd);
renderer_.force_blend_mode() = BlendMode::kBlendModeAdd;
renderer_.override_pixel_shader() =
"void main() { gl_FragColor = vec4(0.2, 0.2, 0.2, 1); }";
#endif // ZOOSHI_OVERDRAW_DEBUG
return true;
}
示例7: AndroidPreCreateWindow
void AndroidPreCreateWindow() {
// Apply scaler setting prior creating surface
if (g_android_scaler_resolution.x() && g_android_scaler_resolution.y()) {
// Initialize OpenGL function pointers inside SDL
if (SDL_GL_LoadLibrary(NULL) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_ERROR,
"couldn't initialize OpenGL library\n");
}
// Hook eglCreateWindowSurface call
SDL_VideoDevice* device = SDL_GetVideoDevice();
device->egl_data->eglCreateWindowSurface = HookEglCreateWindowSurface;
}
}
示例8: AndroidSetScalerResolution
void AndroidSetScalerResolution(const vec2i& resolution) {
// Check against the real size of the device
JNIEnv* env = reinterpret_cast<JNIEnv*>(SDL_AndroidGetJNIEnv());
jobject activity = reinterpret_cast<jobject>(SDL_AndroidGetActivity());
jclass fpl_class = env->GetObjectClass(activity);
jmethodID get_size =
env->GetMethodID(fpl_class, "GetLandscapedSize", "()[I");
jintArray size = (jintArray)env->CallObjectMethod(activity, get_size);
jint* size_ints = env->GetIntArrayElements(size, NULL);
int width = std::min(size_ints[0], resolution.x());
int height = std::min(size_ints[1], resolution.y());
g_android_scaler_resolution = vec2i(width, height);
// Update the underlying activity with the scaled resolution
jmethodID set_resolution =
env->GetMethodID(fpl_class, "SetHeadMountedDisplayResolution", "(II)V");
env->CallVoidMethod(activity, set_resolution, width, height);
env->ReleaseIntArrayElements(size, size_ints, JNI_ABORT);
env->DeleteLocalRef(size);
env->DeleteLocalRef(fpl_class);
env->DeleteLocalRef(activity);
}
示例9: setUniform
void Shader::setUniform(const std::string &name, const vec2i v, bool warn) {
glUniform2i(uniform(name, warn), v.x(), v.y());
}
示例10: setViewport
void Camera::setViewport(vec2i dim)
{
vpWidth = dim.x();
vpHeight = dim.y();
hasProjChanged = true;
}
示例11: draw
void draw()
{
window->clear();
grabber.update();
grabber.draw(size.x() / 4, size.y() / 4, size.x() / 2, size.y() / 2);
}
示例12: display
void display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, grid_texture);
glColor3ub(255,255,255);
glBegin(GL_QUADS);
glTexCoord2f(1, 0);
glVertex2f(grid.nx(), 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(0, 1);
glVertex2f(0, grid.ny());
glTexCoord2f(1, 1);
glVertex2f(grid.nx(), grid.ny());
glEnd();
glDisable(GL_TEXTURE_2D);
if (valid(init)) {
glPushMatrix();
glColor3ub(63,255,63);
glTranslated(init.x(), init.y(), 0);
gluDisk(quadric, 0, goalr, 32, 1);
glRotated(initTheta*180/M_PI, 0, 0, 1);
glBegin(GL_TRIANGLES);
glVertex2f(6, 0);
glVertex2f(0, 2);
glVertex2f(0, -2);
glEnd();
glPopMatrix();
}
if (valid(goal)) {
glPushMatrix();
glColor3ub(255,63,63);
glTranslated(goal.x(), goal.y(), 0);
gluDisk(quadric, 0, goalr, 32, 1);
glPopMatrix();
}
draw(searchResult, true);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, width, 0, height);
std::ostringstream ostr;
ostr << "Goal pos: (" << goal.x() << ", " << goal.y() << ")\n"
<< "Init pos: (" << init.x() << ", " << init.y() << ")\n"
<< "Init theta: " << initTheta*180/M_PI << "\n"
<< "XY inflation: " << inflate_h << "\n"
<< "Z inflation: " << inflate_z << "\n"
<< "Max depth: " << maxDepth << "\n"
<< "View depth: " << viewDepth << "\n"
<< "Auto-plan: " << (auto_plan ? "on" : "off") << "\n"
<< "\n"
<< "Plan cost: " << (searchResult ? searchResult->costToCome : 0) << "\n"
<< "Plan time: " << (searchResult ? planTime : 0) << "\n";
if (show_help) {
ostr << "\n\n"
<< " Left-click init pos\n"
<< "Shift+click init theta\n"
<< "Right-click goal pos\n\n"
<< " 1/2 max depth\n"
<< " 3/4 view depth\n"
<< " -/+ XY inflation\n"
<< " A auto-plan\n"
<< " Enter re-plan\n"
<< " ESC quit\n"
<< " ? hide help";
} else {
ostr << "\nPress ? to toggle help.";
}
std::string str = ostr.str();
void* font = GLUT_BITMAP_8_BY_13;
const int tx = 8;
const int ty = 13;
const int th = ty+2;
int maxwidth = 0;
int linewidth = 0;
int rh = th;
//.........这里部分代码省略.........