예제 #1
0
파일: TextEngine.cpp 프로젝트: naohisas/KVS
void TextEngine::draw( const kvs::Vec2& p, const std::string& text, kvs::ScreenBase* screen ) const
{
    GLint view[4]; kvs::OpenGL::GetViewport( view );

    kvs::OpenGL::WithPushedAttrib attrib( GL_ALL_ATTRIB_BITS );
    attrib.disable( GL_TEXTURE_1D );
    attrib.disable( GL_TEXTURE_2D );
//    attrib.enable( GL_TEXTURE_2D );
    attrib.disable( GL_TEXTURE_3D );
    attrib.disable( GL_DEPTH_TEST );
    attrib.enable( GL_BLEND );
    attrib.enable( GL_CULL_FACE );
    {
        kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        kvs::OpenGL::WithPushedMatrix modelview( GL_MODELVIEW );
        modelview.loadIdentity();
        {
            kvs::OpenGL::WithPushedMatrix projection( GL_PROJECTION );
            projection.loadIdentity();
            {
                kvs::OpenGL::Enable( GL_TEXTURE_2D );
                kvs::OpenGL::Enable( GL_BLEND );
                kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

                const GLint left = view[0];
                const GLint top = view[1];
                const GLint right = view[0] + view[2];
                const GLint bottom = view[1] + view[3];
                kvs::OpenGL::SetOrtho( left, right, bottom, top, 0, 1 );
                m_font.draw( p, text );
            }
        }
    }
}
예제 #2
0
파일: TextEngine.cpp 프로젝트: naohisas/KVS
void TextEngine::draw( const kvs::Vec3& p, const std::string& text, kvs::ScreenBase* screen ) const
{
    GLdouble model[16]; kvs::OpenGL::GetModelViewMatrix( model );
    GLdouble proj[16]; kvs::OpenGL::GetProjectionMatrix( proj );
    GLint view[4]; kvs::OpenGL::GetViewport( view );
    GLdouble winx = 0, winy = 0, winz = 0;
    kvs::OpenGL::Project( p.x(), p.y(), p.z(), model, proj, view, &winx, &winy, &winz );

    kvs::OpenGL::WithPushedAttrib attrib( GL_ALL_ATTRIB_BITS );
    attrib.disable( GL_TEXTURE_1D );
    attrib.disable( GL_TEXTURE_2D );
//    attrib.enable( GL_TEXTURE_2D );
    attrib.disable( GL_TEXTURE_3D );
    attrib.enable( GL_DEPTH_TEST );
    attrib.enable( GL_BLEND );
    {
        kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        kvs::OpenGL::WithPushedMatrix modelview( GL_MODELVIEW );
        modelview.loadIdentity();
        {
            kvs::OpenGL::WithPushedMatrix projection( GL_PROJECTION );
            projection.loadIdentity();
            {
                const GLint left = view[0];
                const GLint top = view[1];
                const GLint right = view[0] + view[2];
                const GLint bottom = view[1] + view[3];
                kvs::OpenGL::SetOrtho( left, right, bottom, top, 0, 1 );
                kvs::OpenGL::Translate( 0, 0, -winz );
                m_font.draw( kvs::Vec2( winx, top - ( winy - bottom ) ), text );
            }
        }
    }
}
예제 #3
0
파일: gl_2_0.cpp 프로젝트: gatgui/pygl
static PyObject* py_glGetVertexAttrib(PyObject *, PyObject *args) {
  CHECK_ARG_COUNT(args, 2);
  PyObject *rv = 0;
  Uint attrib(PyTuple_GetItem(args, 0));
  Enum pname(PyTuple_GetItem(args, 1));
  switch (pname) {
    case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
    case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
    case GL_VERTEX_ATTRIB_ARRAY_SIZE:
    case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
    case GL_VERTEX_ATTRIB_ARRAY_TYPE:
    case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: {
      GLint value;
      glGetVertexAttribiv(attrib, pname, &value);
      rv = PyInt_FromLong(value);
      break;
    }
    case GL_CURRENT_VERTEX_ATTRIB: {
      Array1D<Float> values(4);
      glGetVertexAttribfv(attrib, pname, values);
      rv = values.toPy();
      break;
    }
    default:
      PyErr_SetString(PyExc_RuntimeError, "gl.GetVertexAttrib: invalid parameter name");
  }
  return rv;
}
예제 #4
0
/*===========================================================================*/
void ColorMapBar::draw_color_bar( const int x, const int y, const int width, const int height )
{
    kvs::OpenGL::WithPushedAttrib attrib( GL_ALL_ATTRIB_BITS );
    attrib.disable( GL_BLEND );
    attrib.disable( GL_DEPTH_TEST );
    attrib.disable( GL_TEXTURE_3D );
    attrib.enable( GL_TEXTURE_2D );

    kvs::Texture::Binder binder( m_texture );
    switch ( m_orientation )
    {
    case ColorMapBar::Horizontal:
    {
        kvs::OpenGL::Begin( GL_QUADS );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 0.0f, 1.0f ), kvs::Vec2( x,         y ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 1.0f, 1.0f ), kvs::Vec2( x + width, y ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 1.0f, 0.0f ), kvs::Vec2( x + width, y + height ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 0.0f, 0.0f ), kvs::Vec2( x,         y + height ) );
        kvs::OpenGL::End();
        break;
    }
    case ColorMapBar::Vertical:
    {
        kvs::OpenGL::Begin( GL_QUADS );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 0.0f, 0.0f ), kvs::Vec2( x,         y ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 0.0f, 1.0f ), kvs::Vec2( x + width, y ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 1.0f, 1.0f ), kvs::Vec2( x + width, y + height ) );
        kvs::OpenGL::TexCoordVertex( kvs::Vec2( 1.0f, 0.0f ), kvs::Vec2( x,         y + height ) );
        kvs::OpenGL::End();
        break;
    }
    default: break;
    }
}
void ModelRenderInstance::Render(RenderOptions& renderOptions)
{
   m_spDisplayState->Tick();

   OpenGL::PushedAttributes attrib(GL_POLYGON_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT);

   if (renderOptions.Get(RenderOptions::optionModelFilled))
      glPolygonMode(GL_FRONT, GL_FILL);
   else
      glPolygonMode(GL_FRONT, GL_LINE);

   glPushMatrix();

   // position model
   Vector3d vPos = CalculatedPos();
   glTranslated(vPos.X(), vPos.Y(), vPos.Z());

   glRotated(m_dViewAngle, 0.0, 1.0, 0.0);

   double dTransparency = CalcPlayerTransparency();

   // blend model
   if (dTransparency < 1.0)
   {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   }

   double dLuminance = m_bSelected ? 1.2 : 1.0;
   glColor4d(dLuminance, dLuminance, dLuminance, dTransparency);

   m_spDisplayState->Render(renderOptions);

   glPopMatrix();
}
예제 #6
0
void antPlane::generateColors( const antRGBA & color_1, const antRGBA & color_2 )
{
    m_colors = ( GLfloat * ) malloc( N_COLOR_ATTRIBS * m_nVertices * sizeof( GLfloat ) );
    
    // for each square ---------------------------------------------------------
    for ( int i = 0; i < m_nRows; i++ )
    {
        for ( int j = 0; j < m_nColumns; j++ )
        {
    //--------------------------------------------------------------------------
            
            int c = (i * m_nColumns + j) * 6 * N_COLOR_ATTRIBS;
            
            // for each
            for ( int n = 0; n < N_COLOR_ATTRIBS; n++ )
            {
                m_colors[ c + n ] = color_1.v[n];
                m_colors[ c + (1 * N_COLOR_ATTRIBS) + n ] = color_1.v[n];
                m_colors[ c + (2 * N_COLOR_ATTRIBS) + n ] = color_1.v[n];
                
                m_colors[ c + (3 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
                m_colors[ c + (4 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
                m_colors[ c + (5 * N_COLOR_ATTRIBS) + n ] = color_2.v[n];
            }
        }
    }
    
    m_hasColors = true;
    bindVao(0);
    bindVbo(1);
    setData( m_nVertices * N_COLOR_ATTRIBS * sizeof(GLfloat), m_colors );
    attrib( ATTR_COLOR_LOC, N_COLOR_ATTRIBS );
    enableColors();
}
예제 #7
0
void
setname (	/* does parameter assignments */
    unsigned char *argi,
    int xp
)
{
	register unsigned char *argscan = argi;
	register struct namnod *n;

	if (letter(*argscan))
	{
		while (alphanum(*argscan))
			argscan++;

		if (*argscan == '=')
		{
			*argscan = 0;	/* make name a cohesive string */

			n = lookup(argi);
			*argscan++ = '=';
			attrib(n, xp);
			if (xp & N_ENVNAM)
			{
				n->namenv = n->namval = argscan;
				if (n == &pathnod)
					set_builtins_path();
			}
			else
				assign(n, argscan);

			dolocale(n->namid);
			return;
		}
	}
}
예제 #8
0
uint32_t DisplayHDMI::GetBestConfig(HWS3DMode s3d_mode) {
  uint32_t best_index = 0, index;
  uint32_t num_modes = 0;

  hw_intf_->GetNumDisplayAttributes(&num_modes);

  // Get display attribute for each mode
  std::vector<HWDisplayAttributes> attrib(num_modes);
  for (index = 0; index < num_modes; index++) {
    hw_intf_->GetDisplayAttributes(index, &attrib[index]);
  }

  // Select best config for s3d_mode. If s3d is not enabled, s3d_mode is kS3DModeNone
  for (index = 0; index < num_modes; index ++) {
    if (attrib[index].s3d_config[s3d_mode]) {
      break;
    }
  }
  if (index < num_modes) {
    best_index = UINT32(index);
    for (size_t index = best_index + 1; index < num_modes; index ++) {
      if (!attrib[index].s3d_config[s3d_mode])
        continue;

      // From the available configs, select the best
      // Ex: 1920x1080@60Hz is better than 1920x1080@30 and 1920x1080@30 is better than 1280x720@60
      if (attrib[index].y_pixels > attrib[best_index].y_pixels) {
        best_index = UINT32(index);
      } else if (attrib[index].y_pixels == attrib[best_index].y_pixels) {
        if (attrib[index].x_pixels > attrib[best_index].x_pixels) {
          best_index = UINT32(index);
        } else if (attrib[index].x_pixels == attrib[best_index].x_pixels) {
          if (attrib[index].vsync_period_ns < attrib[best_index].vsync_period_ns) {
            best_index = UINT32(index);
          }
        }
      }
    }
  } else {
    DLOGW("%s, could not support S3D mode from EDID info. S3D mode is %d",
          __FUNCTION__, s3d_mode);
  }

  // Used for changing HDMI Resolution - override the best with user set config
  uint32_t user_config = UINT32(Debug::GetHDMIResolution());
  if (user_config) {
    uint32_t config_index = 0;
    // For the config, get the corresponding index
    DisplayError error = hw_intf_->GetConfigIndex(user_config, &config_index);
    if (error == kErrorNone)
      return config_index;
  }

  return best_index;
}
예제 #9
0
파일: attribs.c 프로젝트: aphogat/piglit
static void draw_quad(unsigned mode, float *v,
		      void (*attrib)(float x, float y, float z, float w))
{
	static const float verts[] = {
		0,   0,
		0,  10,
		10, 10,
		10,  0
	};
	int i;

	switch (mode) {
	case VERTEX_ARRAYS:
		attrib(v[0], v[1], v[2], v[3]);
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(2, GL_FLOAT, 0, verts);
		glDrawArrays(GL_QUADS, 0, 4);
		glDisableClientState(GL_VERTEX_ARRAY);
		break;
	case IMMEDIATE_MODE:
		glBegin(GL_QUADS);
		for (i = 0; i < 4; i++) {
			attrib(v[0], v[1], v[2], v[3]);
			glVertex2fv(&verts[i*2]);
		}
		glEnd();
		break;
	case DISPLAY_LIST:
		glNewList(1, GL_COMPILE);
		glBegin(GL_QUADS);
		for (i = 0; i < 4; i++) {
			attrib(v[0], v[1], v[2], v[3]);
			glVertex2fv(&verts[i*2]);
		}
		glEnd();
		glEndList();
		glCallList(1);
		break;
	default:
		assert(0);
	}
}
예제 #10
0
//-----------------------------------------------------------------------------
void SDEditor::setParameter (VstInt32 index, float value)
{
  if (mLock)
    return;

	// called from ADelayEdit
	switch (index)
	{
		case kDelay:
      {
        nuiAttrib<float> attrib(GetAttribute(_T("Delay")));
        attrib.Set(value);
      }
// 			if (delayFader)
// 				delayFader->setValue (effect->getParameter (index));
// 			if (delayDisplay)
// 				delayDisplay->setValue (effect->getParameter (index));
			break;

		case kFeedBack:
// 			if (feedbackFader)
// 				feedbackFader->setValue (effect->getParameter (index));
// 			if (feedbackDisplay)
// 				feedbackDisplay->setValue (effect->getParameter (index));
      {
        nuiAttrib<float> attrib(GetAttribute(_T("Feedback")));
        attrib.Set(value);
      }
			break;

		case kOut:
// 			if (volumeFader)
// 				volumeFader->setValue (effect->getParameter (index));
// 			if (volumeDisplay)
// 				volumeDisplay->setValue (effect->getParameter (index));
      {
        nuiAttrib<float> attrib(GetAttribute(_T("Out")));
        attrib.Set(value);
      }
			break;
	}
}
예제 #11
0
/*==========================================================================*/
void PolygonRenderer::exec( kvs::ObjectBase* object, kvs::Camera* camera, kvs::Light* light )
{
    kvs::IgnoreUnusedVariable( light );
    kvs::IgnoreUnusedVariable( camera );

    kvs::PolygonObject* polygon = reinterpret_cast<kvs::PolygonObject*>( object );

    BaseClass::startTimer();

    kvs::OpenGL::WithPushedAttrib attrib( GL_CURRENT_BIT | GL_ENABLE_BIT );

/*
    if ( this->isEnabledShading() )
    {
        if ( polygon->normals().size() == 0 )
        {
            glEnable( GL_AUTO_NORMAL );
        }
    }
*/

    this->initialize();
#if KVS_ENABLE_DEPRECATED
    polygon->applyMaterial();
#endif

    // Anti-aliasing.
    if ( m_enable_anti_aliasing )
    {
#if defined ( GL_MULTISAMPLE )
        if ( m_enable_multisample_anti_aliasing )
        {
            GLint buffers = 0;
            GLint samples = 0;
            kvs::OpenGL::GetIntegerv( GL_SAMPLE_BUFFERS, &buffers );
            kvs::OpenGL::GetIntegerv( GL_SAMPLES, &samples );
            if ( buffers > 0 && samples > 1 ) kvs::OpenGL::Enable( GL_MULTISAMPLE );
        }
        else
#endif
        {
            kvs::OpenGL::Enable( GL_POLYGON_SMOOTH );
            kvs::OpenGL::Enable( GL_BLEND );
            kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
            KVS_GL_CALL( glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ) );
        }
    }

    kvs::OpenGL::Enable( GL_DEPTH_TEST );
    ::PolygonRenderingFunction( polygon );
    kvs::OpenGL::Disable( GL_DEPTH_TEST );

    BaseClass::stopTimer();
}
예제 #12
0
파일: TextEngine.cpp 프로젝트: naohisas/KVS
void TextEngine::draw( const kvs::Vec2& p, const kvs::Font::Icon& icon, const float size ) const
{
    kvs::OpenGL::WithPushedAttrib attrib( GL_ALL_ATTRIB_BITS );
    attrib.disable( GL_TEXTURE_1D );
    attrib.disable( GL_TEXTURE_2D );
//    attrib.enable( GL_TEXTURE_2D );
    attrib.disable( GL_TEXTURE_3D );
    attrib.disable( GL_DEPTH_TEST );
    attrib.enable( GL_BLEND );
    kvs::OpenGL::SetBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    m_font.draw( p, icon, size );
}
예제 #13
0
파일: main.c 프로젝트: AyrtonC/GC_AVL
int main(int argc, const char * argv[]) {
    int *v, *w, *z;
    int *vet[100];
    int i;
    w = (int*)_malloc(sizeof(int));
    v = (int*)_malloc(sizeof(int));
    z = NULL;
    for (i = 0; i < 100; i++){
        vet[i] = (int*)_malloc(sizeof(int));
    }
    *v = 10;
    *w = 20;
    printf("*v = %d, *w = %d\n", *v, *w);
    dump();
    v = (int*)attrib(v, w);
    z = (int*)attrib(z, w);
    printf("*v = %d, *w = %d, *z = %d\n", *v, *w, *z);
    dump();
    for (i = 0; i < 100; i++){
        vet[i] = (int*)attrib(vet[i], NULL);
    }
    printf("New dump:\n");
        dump();
    v = (int*)attrib(v, NULL);
    w = (int*)attrib(w, NULL);
    z = (int*)attrib(z, NULL);
    printf("Dump:\n");
    dump();
    return 0;
}
예제 #14
0
void
assign(struct namnod *n, const unsigned char *v)
{
	if (n->namflg & N_RDONLY)
		failed(n->namid, wtfailed);

#ifndef RES

	else if (flags & rshflg)
	{
		if (n == &pathnod || eq(n->namid,"SHELL"))
			failed(n->namid, restricted);
	}
#endif

	else if (n->namflg & N_FUNCTN)
	{
		func_unhash(n->namid);
		freefunc(n);

		n->namenv = 0;
		n->namflg = N_DEFAULT;
	}

	if (n == &mchknod)
	{
		mailchk = stoi(v);
	}

	replace(&n->namval, v);
	attrib(n, N_ENVCHG);

	if (n == &pathnod)
	{
		zaphash();
		set_dotpath();
		set_builtins_path();
		return;
	}

	if (flags & prompt)
	{
		if ((n == &mailpnod) || (n == &mailnod && mailpnod.namflg == N_DEFAULT))
			setmail(n->namval);
	}
}
예제 #15
0
int main (int argc, char *argv[])
{
	document ("<atag></atag>");
	string ("<atag/>");

	document ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
	tag ("b", 0);
	tag ("c", "a", 0);
	string ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");

	document (buf);
	cdata ("\" <online&dangerous> \"", "status", 0);
	attrib ("c", "d", "a", "b", 0);
	tag ("test", 0);
	string (buf);

	return 0;
}
예제 #16
0
void GLShader::shareAttrib(const GLShader &otherShader, const std::string &name, const std::string &_as) {
    std::string as = _as.length() == 0 ? name : _as;
    auto it = otherShader.mBufferObjects.find(name);
    if (it == otherShader.mBufferObjects.end())
        throw std::runtime_error("shareAttribute(" + otherShader.mName + ", " + name + "): attribute not found!");
    const Buffer &buffer = it->second;

    if (name != "indices") {
        int attribID = attrib(as);
        if (attribID < 0)
            return;
        glEnableVertexAttribArray(attribID);
        glBindBuffer(GL_ARRAY_BUFFER, buffer.id);
        glVertexAttribPointer(attribID, buffer.dim, buffer.glType, buffer.compSize == 1 ? GL_TRUE : GL_FALSE, 0, 0);
    } else {
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.id);
    }
}
예제 #17
0
파일: vao.cpp 프로젝트: fwsGonzo/library
	void VAO::createScreenspaceVAO()
	{
		struct screenvertex_t
		{
			float x, y;
		};

		screenvertex_t sv_t[4] =
		{
			{ 1, 0 }, { 0, 0 }, { 0, 1 }, { 1, 1 }
		};
    std::array<uint16_t, 6> ind {0,1,2,0,2,3};

		begin(sizeof(screenvertex_t), 4, sv_t);
    indexes(ind.data(), ind.size());
		attrib(0, 2, GL_FLOAT, GL_FALSE, 0);
		end();
	}
예제 #18
0
void
PTXReader::proc_lu(vector<wstring>& one_mlu) {
  wstring tags=attrib(L"tags");
  if (tags.length()==0)
    parseError(L"mandatory attribute 'tags' cannot be empty");
  else if (tags[0]=='*')
    parseError(L"mandatory attribute 'tags' cannot start with '*'");
  
  wstring::size_type p=tags.find(L"*",0);
  if ((p!=wstring::npos) && (p!=(tags.size()-1)))
     parseError(L"mandatory attribute 'tags' cannot cannot have a '*' in the middle");

  tags=StringUtils::substitute(tags, L".*",L"");
  tags=StringUtils::substitute(tags, L".", L"><");
  tags=L"<"+tags+L">";

  one_mlu.push_back(tags);
}
예제 #19
0
void GLShader::uploadAttrib(const std::string &name, uint32_t size, int dim,
                             uint32_t compSize, GLuint glType, bool integral, const uint8_t *data, int version) {
    int attribID = 0;
    if (name != "indices") {
        attribID = attrib(name);
        if (attribID < 0)
            return;
    }

    GLuint bufferID;
    auto it = mBufferObjects.find(name);
    if (it != mBufferObjects.end()) {
        Buffer &buffer = it->second;
        bufferID = it->second.id;
        buffer.version = version;
        buffer.size = size;
        buffer.compSize = compSize;
    } else {
        glGenBuffers(1, &bufferID);
        Buffer buffer;
        buffer.id = bufferID;
        buffer.glType = glType;
        buffer.dim = dim;
        buffer.compSize = compSize;
        buffer.size = size;
        buffer.version = version;
        mBufferObjects[name] = buffer;
    }
    size_t totalSize = (size_t) size * (size_t) compSize;

    if (name == "indices") {
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferID);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, totalSize, data, GL_DYNAMIC_DRAW);
    } else {
        glBindBuffer(GL_ARRAY_BUFFER, bufferID);
        glBufferData(GL_ARRAY_BUFFER, totalSize, data, GL_DYNAMIC_DRAW);
        if (size == 0) {
            glDisableVertexAttribArray(attribID);
        } else {
            glEnableVertexAttribArray(attribID);
            glVertexAttribPointer(attribID, dim, glType, integral, 0, 0);
        }
    }
}
예제 #20
0
파일: Shader.cpp 프로젝트: cyrilcode/cyfw
    void Shader::uploadAttrib(const string &name, uint32_t size, unsigned int dim, uint32_t compSize,
                              GLuint glType, bool integral, const int *data)
    {
        int attribId = 0;
        if (name != "indices") {
            attribId = attrib(name);
            if (attribId < 0)
                return;
        }

        GLuint bufferId;
        auto it = buffers.find(name);
        if (it != buffers.end()) {
            shader::buffer &buffer = it->second;
            bufferId = it->second.id;
            buffer.size = size;
            buffer.compSize = compSize;
        }
        else {
            glGenBuffers(1, &bufferId);
            shader::buffer buffer;
            buffer.id = bufferId;
            buffer.type = glType;
            buffer.dim = dim;
            buffer.compSize = compSize;
            buffer.size = size;
            buffers[name] = buffer;
        }
        size_t totalSize = (size_t) size * (size_t) compSize;

        if (name == "indices") {
            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferId);
            glBufferData(GL_ELEMENT_ARRAY_BUFFER, totalSize, data, GL_STATIC_DRAW);
        } else {
            glBindBuffer(GL_ARRAY_BUFFER, bufferId);
            glBufferData(GL_ARRAY_BUFFER, totalSize, data, GL_STATIC_DRAW);
            if (size == 0) {
                glDisableVertexAttribArray(attribId);
            } else {
                glEnableVertexAttribArray(attribId);
                glVertexAttribPointer(attribId, dim, glType, integral, 0, 0);
            }
        }
    }
void WorldRenderManager::RenderOutline()
{
   OpenGL::RenderXyzAxes();

   OpenGL::PushedAttributes attrib(GL_LINE_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT);

   glDisable(GL_TEXTURE_2D);
   glDisable(GL_LIGHTING);

   glLineWidth(3.0f);

   glColor3ub(255, 255, 255);
   glBegin(GL_LINE_LOOP);
   glVertex3d(0.0, 0.0, 0.0);
   glVertex3d(1024.0, 0.0, 0.0);
   glVertex3d(1024.0, 0.0, 1024.0);
   glVertex3d(0.0, 0.0, 1024.0);
   glEnd();
}
예제 #22
0
void antPlane::generateVertices()
{
    float sx = m_width / m_nColumns;
    float sz = m_depth / m_nRows;
    
    m_vertices = ( GLfloat * ) malloc( N_VERTEX_ATTRIBS * m_nVertices * sizeof( GLfloat ) );
    
    for ( int i = 0; i < m_nRows; i++ )
    {
        for ( int j = 0; j < m_nColumns; j++ )
        {
            antVec3 bl( j * sx - m_width / 2.f, 0.f, i * sz - m_depth / 2.f ); // bottom left
            antVec3 tl( j * sx - m_width / 2.f, 0.f, ( i + 1 ) * sz - m_depth / 2.f ); // top left
            antVec3 tr( ( j + 1 ) * sx - m_width / 2.f, 0.f, ( i + 1 ) * sz - m_depth / 2.f ); // top right
            antVec3 br( ( j + 1 ) * sx - m_width / 2.f, 0.f, i * sz - m_depth / 2.f ); // bottom right
            
            int v = (i * m_nColumns + j) * 6 * N_VERTEX_ATTRIBS;
            for ( int n = 0; n < N_VERTEX_ATTRIBS; n++ )
            {
                m_vertices[ v + n ] = bl.v[n];
                m_vertices[ v + (1 * N_VERTEX_ATTRIBS) + n ] = tl.v[n];
                m_vertices[ v + (2 * N_VERTEX_ATTRIBS) + n ] = tr.v[n];
                
                m_vertices[ v + (3 * N_VERTEX_ATTRIBS) + n ] = tr.v[n];
                m_vertices[ v + (4 * N_VERTEX_ATTRIBS) + n ] = br.v[n];
                m_vertices[ v + (5 * N_VERTEX_ATTRIBS) + n ] = bl.v[n];
            }
        }
    }
    
    m_hasVertices = true;    
    bindVao(0);
    bindVbo(0);
    setData( m_nVertices * N_VERTEX_ATTRIBS * sizeof(GLfloat), m_vertices );
    attrib( ATTR_POSITION_LOC, N_VERTEX_ATTRIBS );
    enableVertices();
}
예제 #23
0
			void RectColored::FillVertexAttribs()
			{
				sht::graphics::VertexAttribute attrib(sht::graphics::VertexAttribute::kVertex, 2);
				attribs_.push_back(attrib);
			}
예제 #24
0
buffer_ptr Mesh::tangents()
{
    return attrib(attrib_tangent_id);
}
예제 #25
0
buffer_ptr Mesh::texuvs()
{
    return attrib(attrib_texuv_id);
}
예제 #26
0
buffer_ptr Mesh::normals()
{
    return attrib(attrib_normal_id);
}
예제 #27
0
buffer_ptr Mesh::vertives()
{
    return attrib(attrib_vertex_id);
}
예제 #28
0
buffer_ptr Mesh::indices()
{
    return attrib(attrib_index_id);
}
예제 #29
0
/*-----------------------------------------------------------------------------
	Locate the first HTML element on the DOM in the given document that
	matches the attribute we're looking for
	
	This will recursively search any frames within the document
-----------------------------------------------------------------------------*/
CComPtr<IHTMLElement> CPagetestBase::FindDomElementByAttribute(CString &tag, CString &attribute, CString &value, attrOperator &op, CComPtr<IHTMLDocument2> doc)
{
	CComPtr<IHTMLElement> result;
	CComBSTR attrib(attribute);
	
	bool innerText = false;
	bool innerHtml = false;
	bool sourceIndex = false;
	if( !attribute.CompareNoCase(_T("innerText")) )
		innerText = true;
	else if( !attribute.CompareNoCase(_T("innerHtml")) )
		innerHtml = true;
	else if( !attribute.CompareNoCase(_T("sourceIndex")) )
		sourceIndex = true;

	// force class to className (it's a special case where the attribute is different on the DOM)
	if( !attribute.CompareNoCase(_T("class")) )
		attribute = _T("className");

	if( doc )
	{
		// get all of the elements
		if( !result )
		{
			bool ok = false;
			if( !sourceIndex && !innerText && !innerHtml && op == equal && tag.IsEmpty() && (!attribute.CompareNoCase(_T("id"))) )
			{
				CComQIPtr<IHTMLDocument3> doc3 = doc;
				if( doc3 )
				{
					ok = true;
					_bstr_t val = value;
					
					doc3->getElementById(val, &result);
				}
			}

			if( !ok )
			{
				// have to manually walk all of the elements
				CComPtr<IHTMLElementCollection> coll;
				ok = false;
				
				// if we're looking for name, short-cut and do a direct search
				if( !tag.IsEmpty() || (!attribute.CompareNoCase(_T("name")) && op == equal) )
				{
					CComQIPtr<IHTMLDocument3> doc3 = doc;
					if( doc3 )
					{
						ok = true;
						if( !attribute.CompareNoCase(_T("name")) && op == equal )
						{
							_bstr_t name = value;
							doc3->getElementsByName(name, &coll);
						}
						else if( !tag.IsEmpty() )
						{
							_bstr_t tagName = tag;
							doc3->getElementsByTagName(tagName, &coll);
						}
					}
				}
				
				if( !ok )
					if( SUCCEEDED(doc->get_all(&coll)) )
						ok = true;
				
				if( ok && coll )
				{
					long count = 0;
					if( SUCCEEDED(coll->get_length(&count)) )
					{
						for( long i = 0; i < count && !result; i++ )
						{
							_variant_t index = i;
							CComPtr<IDispatch> item;
							if( SUCCEEDED(coll->item(index, index, &item)) && item )
							{
								CComQIPtr<IHTMLElement> element = item;
								if( element )
								{
									ok = false;
									
									// see if we're looking for a particular element type
									if( tag.IsEmpty() )
										ok = true;
									else
									{
										_bstr_t elementTag;
										if( SUCCEEDED(element->get_tagName(elementTag.GetAddress())) )
										{
											CString elTag = elementTag;
											if( !tag.CompareNoCase(elTag) )
												ok = true;
										}
									}
									
									if( ok )
									{								
										_variant_t varVal;
										_bstr_t text;
										
										if( sourceIndex )
										{
											long index;
											if( SUCCEEDED(element->get_sourceIndex(&index)) )
											{
												long lValue = _ttol(value);
												if( index == lValue )
													result = element;
											}
										}
										else
										{
											if( innerText )
												element->get_innerText(text.GetAddress());
											else if (innerHtml)
												element->get_innerHTML(text.GetAddress());
											else if( SUCCEEDED(element->getAttribute(attrib, 0, &varVal)) )
											{
												if( varVal.vt != VT_EMPTY && varVal.vt != VT_NULL && varVal.vt != VT_ERROR )
													text = (_bstr_t)varVal;
											}

											CString val = text;
											val.Trim();
											if( val.GetLength() )
											{
												switch( op )
												{
													case equal:
														{
															if( val == value )
																result = element;
														}break;
													
													case left:
														{
															if( val.Left(value.GetLength()) == value )
																result = element;
														}break;

													case mid:
														{
															if( val.Find(value) > -1 )
																result = element;
														}break;
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}

		// recursively check in any iFrames
		if( !result )
		{
			// walk all of the frames on the document
			CComPtr<IHTMLFramesCollection2> frames;
			if( SUCCEEDED(doc->get_frames(&frames)) && frames )
			{
				// for each frame, walk all of the elements in the frame
				long count = 0;
				if( SUCCEEDED(frames->get_length(&count)) )
				{
					for( long i = 0; i < count && !result; i++ )
					{
						_variant_t index = i;
						_variant_t varFrame;
						
						if( SUCCEEDED(frames->item(&index, &varFrame)) )
						{
							CComQIPtr<IHTMLWindow2> window(varFrame);
							if( window )
							{
								CComQIPtr<IHTMLDocument2> frameDoc;
								frameDoc = HtmlWindowToHtmlDocument(window);
								if( frameDoc )
									result = FindDomElementByAttribute(tag, attribute, value, op, frameDoc);
							}
						}
					}
				}
			}
		}
	}
	
	return result;
}
예제 #30
0
파일: Axis2D.cpp 프로젝트: naohisas/KVS
/*===========================================================================*/
void Axis2D::exec( kvs::ObjectBase* object, kvs::Camera* camera, kvs::Light* light )
{
    kvs::TableObject* table = kvs::TableObject::DownCast( object );

    BaseClass::startTimer();

    kvs::OpenGL::WithPushedAttrib attrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
    m_painter.begin( screen() );
    {
        const int x0 = m_left_margin;
        const int x1 = camera->windowWidth() - m_right_margin;
        const int y0 = m_top_margin;
        const int y1 = camera->windowHeight() - m_bottom_margin;
        const kvs::FontMetrics metrics = m_painter.fontMetrics();

        // Draw background.
        if ( m_background_color.a() > 0.0f )
        {
            kvs::OpenGL::Begin( GL_QUADS );
            kvs::OpenGL::Color( m_background_color );
            kvs::OpenGL::Vertex( kvs::Vec2( x0, y0 ) );
            kvs::OpenGL::Vertex( kvs::Vec2( x1, y0 ) );
            kvs::OpenGL::Vertex( kvs::Vec2( x1, y1 ) );
            kvs::OpenGL::Vertex( kvs::Vec2( x0, y1 ) );
            kvs::OpenGL::End();
        }

        // Draw axes.
        const int d = int( m_axis_width * 0.5 );
        kvs::OpenGL::SetLineWidth( m_axis_width );
        kvs::OpenGL::Begin( GL_LINES );
        kvs::OpenGL::Color( m_axis_color );
        kvs::OpenGL::Vertices( kvs::Vec2( x0 - d, y1 ), kvs::Vec2( x1 + d, y1 ) ); // X axis (bottom)
        kvs::OpenGL::Vertices( kvs::Vec2( x0, y1 + d ), kvs::Vec2( x0, y0 - d ) ); // Y axis (left)
        kvs::OpenGL::Vertices( kvs::Vec2( x0 - d, y0 ), kvs::Vec2( x1 + d, y0 ) ); // X axis (top)
        kvs::OpenGL::Vertices( kvs::Vec2( x1, y1 + d ), kvs::Vec2( x1, y0 - d ) ); // Y axis (right)
        kvs::OpenGL::End();

        // Draw min/max values.
        const std::string x_min_value = kvs::String::ToString( table->minValue(0) );
        const std::string x_max_value = kvs::String::ToString( table->maxValue(0) );
        const kvs::Vec2 x_min_position( x0, y1 + metrics.height() + 5 );
        const kvs::Vec2 x_max_position( x1 - metrics.width( x_max_value ), y1 + metrics.height() + 5 );

        m_painter.drawText( x_min_position, x_min_value );
        m_painter.drawText( x_max_position, x_max_value );

        const std::string y_min_value = kvs::String::ToString( table->minValue(1) );
        const std::string y_max_value = kvs::String::ToString( table->maxValue(1) );
        const kvs::Vec2 y_min_position( x0 - metrics.width( y_min_value ) - 5, y1 );
        const kvs::Vec2 y_max_position( x0 - metrics.width( y_max_value ) - 5, y0 + metrics.height() );

        m_painter.drawText( y_min_position, y_min_value );
        m_painter.drawText( y_max_position, y_max_value );

        // Draw x label.
        const std::string x_label = m_x_label.empty() ? table->label(0) : m_x_label;
        if ( x_label.size() > 0 )
        {
            const float x_label_position_x = ( x0 + x1 - metrics.width( x_label ) ) * 0.5f;
            const float x_label_position_y = y1 + metrics.height() * 2.0f + 5.0f;
            m_painter.drawText( kvs::Vec2( x_label_position_x, x_label_position_y ), x_label );
        }

        // Draw y label.
        const std::string y_label = m_y_label.empty() ? table->label(1) : m_y_label;
        if ( y_label.size() > 0 )
        {
            kvs::OpenGL::PushMatrix();
            const float y_value_position = kvs::Math::Min( y_min_position.x(), y_max_position.x() );
            kvs::OpenGL::Translate( y_value_position - 5.0f, ( y0 + y1 + metrics.width( y_label ) ) * 0.5f, 0.0f );
            kvs::OpenGL::Rotate( -90.0, 0, 0, 1 );
            m_painter.drawText( kvs::Vec2( 0, 0 ), y_label );
            kvs::OpenGL::PopMatrix();
        }
    }
    m_painter.end();

    BaseClass::stopTimer();
}