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


C++ TextureManager::RenderNormal方法代码示例

本文整理汇总了C++中TextureManager::RenderNormal方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::RenderNormal方法的具体用法?C++ TextureManager::RenderNormal怎么用?C++ TextureManager::RenderNormal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextureManager的用法示例。


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

示例1: OGL_Draw

void Shape_Blitter::OGL_Draw(const Image_Rect& dst)
{
#ifdef HAVE_OPENGL
	// Set up texture
	TextureManager TMgr;
	TMgr.ShapeDesc = BUILD_DESCRIPTOR(m_coll, 0);
    TMgr.LowLevelShape = m_frame;
    extended_get_shape_bitmap_and_shading_table(m_coll, m_frame,  &TMgr.Texture, &TMgr.ShadingTables, _shading_normal);
	TMgr.IsShadeless = false;
	TMgr.TransferMode = _shadeless_transfer;
    
    switch (m_type)
    {
        case Shape_Texture_Wall:
            TMgr.TextureType = OGL_Txtr_Wall;
            break;
        case Shape_Texture_Landscape:
	  {
            TMgr.TextureType = OGL_Txtr_Landscape;
            LandscapeOptions *LandOpts = View_GetLandscapeOptions(TMgr.ShapeDesc);	
            TMgr.LandscapeVertRepeat = LandOpts->VertRepeat;
            TMgr.Landscape_AspRatExp = LandOpts->OGL_AspRatExp;
	  }
            break;
        case Shape_Texture_Sprite:
            TMgr.TextureType = OGL_Txtr_Inhabitant;
            break;
        case Shape_Texture_WeaponInHand:
        case Shape_Texture_Interface:
            TMgr.TextureType = OGL_Txtr_WeaponsInHand;
            break;
    }
	if (!TMgr.Setup())
		return;
    
	// Get dimensions
	GLdouble U_Scale = TMgr.U_Scale;
	GLdouble V_Scale = TMgr.V_Scale;
	GLdouble U_Offset = TMgr.U_Offset;
	GLdouble V_Offset = TMgr.V_Offset;
    
	// Draw shape
	if (Wanting_sRGB && TMgr.TextureType != OGL_Txtr_WeaponsInHand)
	{
		glEnable(GL_FRAMEBUFFER_SRGB_EXT);
		Using_sRGB = true;
	}
	SglColor4f(tint_color_r, tint_color_g, tint_color_b, tint_color_a);
	glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	TMgr.SetupTextureMatrix();
	TMgr.RenderNormal();
    
    bool rotating = (rotation > 0.1 || rotation < -0.1);
	if (rotating)
	{
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		glTranslatef((dst.x + dst.w/2.0), (dst.y + dst.h/2.0), 0.0);
		glRotatef(rotation, 0.0, 0.0, 1.0);
		glTranslatef(-(dst.x + dst.w/2.0), -(dst.y + dst.h/2.0), 0.0);
	}

    if (m_type == Shape_Texture_Interface)
    {
        if (crop_rect.x > 0)
            U_Offset += crop_rect.x * U_Scale / static_cast<double>(m_scaled_src.w);
        if (crop_rect.y > 0)
            V_Offset += crop_rect.y * V_Scale / static_cast<double>(m_scaled_src.h);
        if (crop_rect.w < m_scaled_src.w)
            U_Scale *= crop_rect.w / static_cast<double>(m_scaled_src.w);
        if (crop_rect.h < m_scaled_src.h)
            V_Scale *= crop_rect.h / static_cast<double>(m_scaled_src.h);

		OGL_RenderTexturedRect(dst.x, dst.y, dst.w, dst.h,
							   U_Offset, V_Offset,
							   U_Offset + U_Scale,
							   V_Offset + V_Scale);
    }
    else if (m_type == Shape_Texture_Landscape)
    {
        U_Scale = -TMgr.Texture->width / static_cast<double>(TMgr.Texture->height);
        U_Offset = 0.5 - U_Scale/2.0;
        
        if (crop_rect.x > 0)
            V_Offset += crop_rect.x * V_Scale / static_cast<double>(m_scaled_src.w);
        if (crop_rect.y > 0)
            U_Offset += crop_rect.y * U_Scale / static_cast<double>(m_scaled_src.h);
        if (crop_rect.w < m_scaled_src.w)
            V_Scale *= crop_rect.w / static_cast<double>(m_scaled_src.w);
        if (crop_rect.h < m_scaled_src.h)
            U_Scale *= crop_rect.h / static_cast<double>(m_scaled_src.h);
		
		OGL_RenderTexturedRect(dst.x, dst.y, dst.w, dst.h,
							   V_Offset, U_Offset,
							   V_Offset + V_Scale,
							   U_Offset + U_Scale);
    }
    else
//.........这里部分代码省略.........
开发者ID:Aleph-One-Marathon,项目名称:alephone,代码行数:101,代码来源:Shape_Blitter.cpp

示例2: OGL_Draw

void Shape_Blitter::OGL_Draw(SDL_Rect& dst)
{
#ifdef HAVE_OPENGL
  // Set up texture
  TextureManager TMgr;
  TMgr.ShapeDesc = m_desc;
  get_shape_bitmap_and_shading_table(m_desc, &TMgr.Texture, &TMgr.ShadingTables,
                                     _shading_normal);
  TMgr.IsShadeless = false;
  TMgr.TransferMode = _shadeless_transfer;

  switch (m_type)
  {
  case Shape_Texture_Wall:
    TMgr.TextureType = OGL_Txtr_Wall;
    break;
  case Shape_Texture_Landscape:
  {
    TMgr.TextureType = OGL_Txtr_Landscape;
    LandscapeOptions *LandOpts = View_GetLandscapeOptions(TMgr.ShapeDesc);
    TMgr.LandscapeVertRepeat = LandOpts->VertRepeat;
    TMgr.Landscape_AspRatExp = LandOpts->OGL_AspRatExp;
  }
  break;
  case Shape_Texture_Sprite:
    TMgr.TextureType = OGL_Txtr_Inhabitant;
    break;
  case Shape_Texture_WeaponInHand:
  case Shape_Texture_Interface:
    TMgr.TextureType = OGL_Txtr_WeaponsInHand;
    break;
  }
  if (!TMgr.Setup()) {
    return;
  }

  // Get dimensions
  // DJB Doubles to floats...
  GLfloat U_Scale = TMgr.U_Scale;
  GLfloat V_Scale = TMgr.V_Scale;
  GLfloat U_Offset = TMgr.U_Offset;
  GLfloat V_Offset = TMgr.V_Offset;

  // Draw shape
  SglColor4f(tint_color_r, tint_color_g, tint_color_b, tint_color_a);
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  TMgr.SetupTextureMatrix();
  TMgr.RenderNormal();

  bool rotating = (rotation > 0.1 || rotation < -0.1);
  if (rotating) {
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glTranslatef((dst.x + dst.w/2.0), (dst.y + dst.h/2.0), 0.0);
    glRotatef(rotation, 0.0, 0.0, 1.0);
    glTranslatef(-(dst.x + dst.w/2.0), -(dst.y + dst.h/2.0), 0.0);
  }

  if (m_type == Shape_Texture_Interface) {
    if (crop_rect.x > 0) {
      U_Offset += crop_rect.x * U_Scale / static_cast<double>(m_scaled_src.w);
    }
    if (crop_rect.y > 0) {
      V_Offset += crop_rect.y * V_Scale / static_cast<double>(m_scaled_src.h);
    }
    if (crop_rect.w < m_scaled_src.w) {
      U_Scale *= crop_rect.w / static_cast<double>(m_scaled_src.w);
    }
    if (crop_rect.h < m_scaled_src.h) {
      V_Scale *= crop_rect.h / static_cast<double>(m_scaled_src.h);
    }

    // DJB OpenGL  Change from triangle fan
    GLfloat t[8] = {
      U_Offset, V_Offset,
      U_Offset + U_Scale, V_Offset,
      U_Offset + U_Scale, V_Offset + V_Scale,
      U_Offset, V_Offset + V_Scale
    };
    GLshort v[8] = {
      dst.x, dst.y,
      dst.x + dst.w, dst.y,
      dst.x + dst.w, dst.y + dst.h,
      dst.x, dst.y + dst.h
    };
    glVertexPointer(2, GL_SHORT, 0, v);
    glEnableClientState(GL_VERTEX_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, t);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

    /*
    glBegin(GL_TRIANGLE_FAN);
    glTexCoord2d(U_Offset, V_Offset);
    glVertex2i(dst.x, dst.y);
    glTexCoord2d(U_Offset + U_Scale, V_Offset);
    glVertex2i(dst.x + dst.w, dst.y);
    glTexCoord2d(U_Offset + U_Scale, V_Offset + V_Scale);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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