当前位置: 首页>>代码示例>>C++>>正文


C++ vec2i类代码示例

本文整理汇总了C++中vec2i的典型用法代码示例。如果您正苦于以下问题:C++ vec2i类的具体用法?C++ vec2i怎么用?C++ vec2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了vec2i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: genNoiseTexture

Texture::Pointer TextureFactory::genNoiseTexture(const vec2i& size, bool norm, const std::string& id)
{
	DataStorage<vec4ub> randata(size.square());
	for (size_t i = 0; i < randata.size(); ++i)
	{
		vec4 rand_f = vec4(randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f),
			randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f));
		
		if (norm)
			rand_f.xyz().normalize();
		
		randata[i].x = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.x, 0.0f, 1.0f));
		randata[i].y = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.y, 0.0f, 1.0f));
		randata[i].z = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.z, 0.0f, 1.0f));
		randata[i].w = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.w, 0.0f, 1.0f));
	}

	TextureDescription::Pointer desc = TextureDescription::Pointer::create();
	desc->data = BinaryDataStorage(4 * size.square());
	desc->target = TextureTarget::Texture_2D;
	desc->internalformat = TextureFormat::RGBA;
	desc->format = TextureFormat::RGBA;
	desc->type = DataType::UnsignedChar;
	desc->size = size;
	desc->mipMapCount = 1;
	desc->layersCount = 1;
    desc->bitsPerPixel = 32;
    
	etCopyMemory(desc->data.data(), randata.data(), randata.dataSize());

	return Texture::Pointer::create(renderContext(), desc, id, false);
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:32,代码来源:texturefactory.cpp

示例2: genNoiseTexture

Texture TextureFactory::genNoiseTexture(const vec2i& size, bool norm, const std::string& id)
{
	DataStorage<vec4ub> randata(size.square());
	for (size_t i = 0; i < randata.size(); ++i)
	{
		vec4 rand_f = vec4(randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f),
			randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f));
		
		randata[i] = vec4f_to_4ub(norm ? vec4(rand_f.xyz().normalize(), rand_f.w) : rand_f);
	}

	TextureDescription::Pointer desc(new TextureDescription);
	desc->data = BinaryDataStorage(4 * size.square());
	desc->target = GL_TEXTURE_2D;
	desc->format = GL_RGBA;
	desc->internalformat = GL_RGBA;
	desc->type = GL_UNSIGNED_BYTE;
	desc->size = size;
	desc->mipMapCount = 1;
	desc->layersCount = 1;
    desc->bitsPerPixel = 32;
    
	etCopyMemory(desc->data.data(), randata.data(), randata.dataSize());

	return Texture(new TextureData(renderContext(), desc, id, false));
}
开发者ID:celesius,项目名称:et-engine,代码行数:26,代码来源:texturefactory.cpp

示例3: 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;
	}
}
开发者ID:pushmatrix,项目名称:tron,代码行数:9,代码来源:grid.cpp

示例4: GetWindowSize

// 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;
}
开发者ID:Haris07,项目名称:zooshi,代码行数:58,代码来源:game.cpp

示例5: readFramebufferData

void Renderer::readFramebufferData(const vec2i& size, TextureFormat format, DataType dataType, BinaryDataStorage& data)
{
	ET_ASSERT((8 * data.size()) >= (size.square() * bitsPerPixelForTextureFormat(format, dataType)));
	
	glReadPixels(0, 0, size.x, size.y, textureFormatValue(format), dataTypeValue(dataType), data.data());
	checkOpenGLError("glReadPixels");
}
开发者ID:sergeyreznik,项目名称:et-engine,代码行数:7,代码来源:renderer.cpp

示例6: AndroidSetScalerResolution

namespace fpl {

// Quick hack for HW scaler setting
static vec2i g_android_scaler_resolution;

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);
}

const vec2i& AndroidGetScalerResolution() {
  return g_android_scaler_resolution;
}

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);
}

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;
  }
}

}  // namespace fpl
开发者ID:DavidLeeEvans,项目名称:pienoon,代码行数:60,代码来源:renderer_android.cpp

示例7: 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()) );
}
开发者ID:jacquelinekay,项目名称:biped-footstep-planner,代码行数:7,代码来源:bipedDemo.cpp

示例8: ET_ASSERT

void Program::setUniform(int nLoc, uint32_t type, const vec2i& value, bool forced)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (nLoc == -1) return;

	(void)type;
	ET_ASSERT(type == GL_INT_VEC2);
	ET_ASSERT(apiHandleValid());

	if (forced || ((_vec2iCache.count(nLoc) == 0) || (_vec2iCache[nLoc] != value)))
	{
		_vec2iCache[nLoc] = value;
		glUniform2iv(nLoc, 1, value.data());
		checkOpenGLError("glUniform2iv");
	}

#endif
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:18,代码来源:program.cpp

示例9: vec2i

vec2i operator-(const vec2i& v1, const vec2i &v2){
    return vec2i(v1.peekx()-v2.peekx(),
                 v1.peeky()-v2.peeky());
}
开发者ID:c0d1f1ed,项目名称:piko-public,代码行数:4,代码来源:vecs.cpp

示例10: dot

int dot(const vec2i& v1, const vec2i& v2){
    return ((v1.peekx()*v2.peekx())+
            (v1.peeky()*v2.peeky()));
}
开发者ID:c0d1f1ed,项目名称:piko-public,代码行数:4,代码来源:vecs.cpp

示例11: setUniform

 void Shader::setUniform(const std::string &name, const vec2i v, bool warn) {
     glUniform2i(uniform(name, warn), v.x(), v.y());
 }
开发者ID:cyrilcode,项目名称:cyfw,代码行数:3,代码来源:Shader.cpp

示例12: application

void MainController::applicationDidLoad(et::RenderContext* rc)
{
#if (ET_PLATFORM_WIN)
	application().pushSearchPath("..\\Data");
	application().pushSearchPath("Q:\\SDK\\");
	application().pushSearchPath("Q:\\SDK\\Models");
	application().pushSearchPath("Q:\\SDK\\Textures");
#elif (ET_PLATFORM_MAC)
	application().pushSearchPath("/Volumes/Development/SDK");
	application().pushSearchPath("/Volumes/Development/SDK/Models");
	application().pushSearchPath("/Volumes/Development/SDK/Textures");
#endif
	
	_scene.options.bounces = _productionBounces;
	_scene.options.samples = _productionSamples;
	_scene.options.exposure = 1.0f;
	updateTitle();
	
	rc->renderState().setDepthMask(false);
	rc->renderState().setDepthTest(false);
	
	_scene.load(rc);
	
	_textureData.resize(frameSize.square());
	_textureData.fill(255);
	
	_outputFunction = [this](const vec2i& pixel, const vec4& color) mutable
	{
		size_t index = pixel.x + pixel.y * frameSize.x;
		_textureData[index].x = static_cast<unsigned char>(255.0f * clamp(color.x, 0.0f, 1.0f));
		_textureData[index].y = static_cast<unsigned char>(255.0f * clamp(color.y, 0.0f, 1.0f));
		_textureData[index].z = static_cast<unsigned char>(255.0f * clamp(color.z, 0.0f, 1.0f));
	};
	
	BinaryDataStorage textureData(reinterpret_cast<unsigned char*>(_textureData.binary()), _textureData.dataSize());
	_result = rc->textureFactory().genTexture(TextureTarget::Texture_2D, TextureFormat::RGBA, frameSize,
		TextureFormat::RGBA, DataType::UnsignedChar, textureData, "result-texture");
	
	_cameraAngles.setValue(cameraInitialAngles);
	_cameraAngles.setTargetValue(cameraInitialAngles);
	_cameraAngles.finishInterpolation();
	
	_cameraAngles.updated.connect([this]()
	{
		updateCamera();
		startRender(true);
	});
	
	updateCamera();
	_cameraAngles.run();
	
	_gestures.pointerPressed.connect([this](et::PointerInputInfo)
		{ startRender(true); });

	_gestures.pointerReleased.connect([this](et::PointerInputInfo)
		{ startRender(false); });
	
	_gestures.drag.connect([this](et::vector2<float> d, unsigned long)
	{
		_cameraAngles.addTargetValue(0.1f * vec2(d.x, -d.y));
		_cameraAngles.finishInterpolation();
	});
	
	for (size_t i = 0; i < numThreads; ++i)
		_threads.push_back(sharedObjectFactory().createObject<RaytraceThread>(this));
		
	Invocation([this](){ startRender(false); }).invokeInMainRunLoop();
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:68,代码来源:MainController.cpp

示例13: setViewport

 void Camera::setViewport(vec2i dim)
 {
     vpWidth = dim.x();
     vpHeight = dim.y();
     hasProjChanged = true;
 }
开发者ID:cyrilcode,项目名称:cyfw,代码行数:6,代码来源:Camera.cpp

示例14: 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();
  
  bipedTrajectory.clear();
  searchTrajectory();
    
  /*searchResult = helper.search(init.x(), init.y(), initTheta,
                               goal.x(), goal.y(), goalr, 0, // TODO: don't hardcode
                               checker, maxDepth, viewDepth);*/

  planTime = gettimeasdouble() - start;

  changes = NoChange;


}
开发者ID:swatbotics,项目名称:e91-final,代码行数:30,代码来源:bipedDemo.cpp

示例15: 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";
 }
开发者ID:cyrilcode,项目名称:cyfw-examples,代码行数:8,代码来源:05-video.cpp


注:本文中的vec2i类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。