Пример #1
0
void GLRenderer::endDrawingMeshes() {
	glDisableClientState(GL_VERTEX_ARRAY);
	if (m_normalsEnabled) {
		glDisableClientState(GL_NORMAL_ARRAY);
		m_normalsEnabled = false;
	}

	if (m_texcoordsEnabled) {
		glClientActiveTexture(GL_TEXTURE0);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		m_texcoordsEnabled = false;
	}

	if (m_tangentsEnabled) {
		glClientActiveTexture(GL_TEXTURE1);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		m_tangentsEnabled = false;
	}

	if (m_colorsEnabled) {
		glDisableClientState(GL_COLOR_ARRAY);
		m_colorsEnabled = false;
	}

	if (m_capabilities->isSupported(RendererCapabilities::EBindless)) {
		glDisableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
		glDisableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV);
	} else {
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	}
}
Пример #2
0
void close_objs_gl(Object *objs)
{
  Object *o;
  for (o = objs; o != NULL ; o = o->next) {
    switch (o->type) {
    case V_TRIMESH: case V_PRIM: {
      TmapInfo *ti = o->mat->tinfo;
      if (ti != NULL && ti->src->type == TSRC_IMAGE) {
	GLuint texture = ti->src->gltex;
	glDeleteTextures( 1, &texture);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      glDeleteBuffers(1, &(sh_vb_(o)->buffer));
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      glDeleteBuffers(1, &(sh_vb_(o)->indices));

      glVertexPointer(3, GL_FLOAT, 0, NULL); 
      glNormalPointer(GL_FLOAT, 0, NULL);
      glClientActiveTexture(GL_TEXTURE0); 
      glTexCoordPointer(3, GL_FLOAT, 0, NULL);
      glClientActiveTexture(GL_TEXTURE1); 
      glTexCoordPointer(3, GL_FLOAT, 0, NULL);
      glClientActiveTexture(GL_TEXTURE2); 
      glTexCoordPointer(3, GL_FLOAT, 0, NULL);
    }
      break;
    case V_GROUP:
      close_objs_gl(children_(o));
      break;
    default: error("(close_obj_gl) wrong type");
    }
  }
}
// draw points from vertex buffer objects
void SmokeRenderer::drawPoints(int start, int count, bool sort)
{
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, mPosVbo);
    glVertexPointer(4, GL_FLOAT, 0, 0);
    glEnableClientState(GL_VERTEX_ARRAY);                

    if (mColorVbo) {
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mColorVbo);
        glColorPointer(4, GL_FLOAT, 0, 0);
        glEnableClientState(GL_COLOR_ARRAY);
    }

    if (mVelVbo) {
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVelVbo);
        glClientActiveTexture(GL_TEXTURE0);
        glTexCoordPointer(4, GL_FLOAT, 0, 0);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    }

    if (sort) {
        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mIndexBuffer);
        glDrawElements(GL_POINTS, count, GL_UNSIGNED_INT, (void*) (start*sizeof(unsigned int)) );
        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
    } else {
        glDrawArrays(GL_POINTS, start, count);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);

    glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
Пример #4
0
	void VertexDecl::unbindArray()
	{
		bool haveTex = false;
		for ( InfoVec::iterator iter = mInfoVec.begin() , itEnd = mInfoVec.end(); 
			iter != itEnd; ++iter )
		{
			Info& info = *iter;
			switch( info.semantic )
			{
			case Vertex::ePosition:
				glDisableClientState( GL_VERTEX_ARRAY );
				break;
			case Vertex::eNormal:
				glDisableClientState( GL_NORMAL_ARRAY );
				break;
			case Vertex::eColor:
				glDisableClientState( ( info.idx == 0) ? GL_COLOR_ARRAY:GL_SECONDARY_COLOR_ARRAY );
				break;
			case Vertex::eTexcoord:
				haveTex = false;
				glClientActiveTexture( GL_TEXTURE0 + info.idx );
				glDisableClientState( GL_TEXTURE_COORD_ARRAY );
				break;
			}
		}
		if ( haveTex )
			glClientActiveTexture( GL_TEXTURE0 );
	}
Пример #5
0
void SS3OPiece::BindVertexAttribVBOs() const
{
	vboAttributes.Bind(GL_ARRAY_BUFFER);
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, pos)));

		glEnableClientState(GL_NORMAL_ARRAY);
		glNormalPointer(GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, normal)));

		glClientActiveTexture(GL_TEXTURE0);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, texCoords[0])));

		glClientActiveTexture(GL_TEXTURE1);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, texCoords[1])));

		glClientActiveTexture(GL_TEXTURE5);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(3, GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, sTangent)));

		glClientActiveTexture(GL_TEXTURE6);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(3, GL_FLOAT, sizeof(SS3OVertex), vboAttributes.GetPtr(offsetof(SS3OVertex, tTangent)));
	vboAttributes.Unbind();
}
Пример #6
0
void GraphicsLayer15::setTextureUnits(unsigned int units)
{
	glActiveTexture(GL_TEXTURE1);
	glClientActiveTexture(GL_TEXTURE1);
	if (units > 1) {
		glEnable(GL_TEXTURE_2D);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, s2)));
	} else {
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisable(GL_TEXTURE_2D);
	}

	glActiveTexture(GL_TEXTURE0);
	glClientActiveTexture(GL_TEXTURE0);
	if (units > 0) {
		glEnable(GL_TEXTURE_2D);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, s)));
	} else {
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisable(GL_TEXTURE_2D);
	}

	glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLvoid*>(offsetof(Vertex, x)));
}
Пример #7
0
void SAssPiece::BindVertexAttribVBOs() const
{
	vboAttributes.Bind(GL_ARRAY_BUFFER);
		glEnableClientState(GL_VERTEX_ARRAY);
		glVertexPointer(3, GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, pos)));

		glEnableClientState(GL_NORMAL_ARRAY);
		glNormalPointer(GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, normal)));

		// primary and secondary texture use first UV channel
		for (unsigned int n = 0; n < NUM_MODEL_TEXTURES; n++) {
			glClientActiveTexture(GL_TEXTURE0 + n);
			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
			glTexCoordPointer(2, GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, texCoords) + (0 * sizeof(float2))));
		}

		// extra UV channels (currently at most one)
		for (unsigned int n = 1; n < GetNumTexCoorChannels(); n++) {
			assert((GL_TEXTURE0 + NUM_MODEL_TEXTURES + (n - 1)) < GL_TEXTURE5);
			glClientActiveTexture(GL_TEXTURE0 + NUM_MODEL_TEXTURES + (n - 1));
			glEnableClientState(GL_TEXTURE_COORD_ARRAY);

			glTexCoordPointer(2, GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, texCoords) + (n * sizeof(float2))));
		}

		glClientActiveTexture(GL_TEXTURE5);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(3, GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, sTangent)));

		glClientActiveTexture(GL_TEXTURE6);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(3, GL_FLOAT, sizeof(SAssVertex), vboAttributes.GetPtr(offsetof(SAssVertex, tTangent)));
	vboAttributes.Unbind();
}
Пример #8
0
void set_gl_state()
{
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glEnable(GL_BLEND);
    glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);

    glVertexPointer(2, GL_FLOAT, 0,
                    (void*)&render_data.positions[0]);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, (void*)&render_data.colors[0]);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    glClientActiveTexture(GL_TEXTURE0);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, (void*)&render_data.texcoord1[0]); 

    glClientActiveTexture(GL_TEXTURE1);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, (void*)&render_texcoords2[0]);

    glClientActiveTexture(GL_TEXTURE0);

    BaseShader::current = NULL;
}
Пример #9
0
void CVertexBuffer::LoadVertices(unsigned int number_of_vertices, CVertex* data, unsigned int* indices)
{
	//za argument przyjmuje wskaznik na tablice struktur przedstawiajacych wierzcholek w formacie
	//GLfloat x, y, z
	//GLfloat nx, ny, nz
	//GLfloat s0, t0         //Texcoord0
	//GLfloat s1, t1         //Texcoord1
	//GLfloat s2, t2         //Texcoord2
	//dodatkowo wyrownane do 64bajtow czyli na koncu jakies smiec 16 bajtowy trzeba dodac
	//nie jestem pewien czy to konieczne, ale zawsze lepiej sluchac specjalistow:P
	_GuardedBind();

	GLsizei size = sizeof(data);

	glBufferData(m_Type, number_of_vertices*size, data, GL_STATIC_DRAW);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glVertexPointer(3, GL_FLOAT, size, BUFFER_OFFSET(0));
	glNormalPointer(GL_FLOAT, size, BUFFER_OFFSET(12));
	glClientActiveTexture(GL_TEXTURE0);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);    //Notice that after we call glClientActiveTexture, we enable the array
	glTexCoordPointer(2, GL_FLOAT, size, BUFFER_OFFSET(24));
	glClientActiveTexture(GL_TEXTURE1);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);    //Notice that after we call glClientActiveTexture, we enable the array
	glTexCoordPointer(2, GL_FLOAT, size, BUFFER_OFFSET(32));
	glClientActiveTexture(GL_TEXTURE2);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);    //Notice that after we call glClientActiveTexture, we enable the array
	glTexCoordPointer(2, GL_FLOAT, size, BUFFER_OFFSET(40));

	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glEnableVertexAttribArray(0);

	_GuardedUnbind();
}
Пример #10
0
void CMaterial::Apply(void* texCoordPtr)
{
	GLfloat shininess=32.0;
	bool _useTex1 = false;
	bool _useTexSpec = false;

	glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT, ambient);
	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE, diffuse);
	glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, specular);
	glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, emission);
	glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS, &shininess);

	//данные текстуры
	Texture* _tex = texture1.GetTexture();
	if (_tex->imageData != NULL)
	{
		_useTex1 = true;
		int _sampler = glGetUniformLocation(scene.shader->PShader, "tex1");

		// Установка текущего ТБ
		glUniform1i(_sampler,0);

		// Связывание ТБ с текстурой
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D,_tex->texID);

		// Включение массива текстурных координат
		glClientActiveTexture(GL_TEXTURE0);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2,GL_FLOAT,0, texCoordPtr);
	}

	
	//данные текстуры
	_tex = textureSpecular.GetTexture();
	if (_tex->imageData != NULL)
	{
		_useTexSpec = true;

		int _sampler = glGetUniformLocation(scene.shader->PShader, "texSpec");

		// Установка текущего ТБ
		glUniform1i(_sampler,1);

		// Связывание ТБ с текстурой
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_2D,_tex->texID);

		// Включение массива текстурных координат
		glClientActiveTexture(GL_TEXTURE1);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2,GL_FLOAT,0, texCoordPtr);
	}

	glUniform1i(glGetUniformLocation(scene.shader->PShader, "useTex1"), _useTex1);
	glUniform1i(glGetUniformLocation(scene.shader->PShader, "useTexSpec"), _useTexSpec);
}
Пример #11
0
void GraphicsLayer13::draw(const VertexArray& array, GLenum mode)
{
	glClientActiveTexture(GL_TEXTURE1);
	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &at(array.start).s2);
	glClientActiveTexture(GL_TEXTURE0);
	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &at(array.start).s);
	glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &at(array.start).x);
	glDrawArrays(mode, 0, array.length());
}
Пример #12
0
bool HalfEdgeModel::CallVBO( int type )
{
	if (type==USE_LINES && edgeVBO > 0)
	{
		glBindBuffer( GL_ARRAY_BUFFER, edgeVBO );
		glEnableClientState( GL_VERTEX_ARRAY );
		glVertexPointer( 3, GL_FLOAT, 3*sizeof(float)*vboEdgeComponents, BUFFER_OFFSET(0) );
		if (vboEdgeComponents >= 2)
		{
			glEnableClientState( GL_NORMAL_ARRAY );
			glNormalPointer( GL_FLOAT, 3*sizeof(float)*vboEdgeComponents, BUFFER_OFFSET(3*sizeof(float)) );
		}
		if (vboEdgeComponents >= 3)
		{
			glClientActiveTexture( GL_TEXTURE6 );
			glEnableClientState( GL_TEXTURE_COORD_ARRAY );
			glTexCoordPointer(3, GL_FLOAT, 3*sizeof(float)*vboEdgeComponents, BUFFER_OFFSET((vboEdgeComponents-2)*3*sizeof(float)) );
			glClientActiveTexture( GL_TEXTURE7 );
			glEnableClientState( GL_TEXTURE_COORD_ARRAY );
			glTexCoordPointer(3, GL_FLOAT, 3*sizeof(float)*vboEdgeComponents, BUFFER_OFFSET((vboEdgeComponents-1)*3*sizeof(float)) );
		}
		
		glDrawArrays( GL_LINES, 0, 2*vboEdgeCount );
	
		glDisableClientState( GL_VERTEX_ARRAY );
		if (vboEdgeComponents >= 1) glDisableClientState( GL_NORMAL_ARRAY );
		if (vboEdgeComponents >= 3)
		{
			glDisableClientState( GL_TEXTURE_COORD_ARRAY );
			glClientActiveTexture( GL_TEXTURE6 );
			glDisableClientState( GL_TEXTURE_COORD_ARRAY );
			glClientActiveTexture( GL_TEXTURE0 );
		}
		glBindBuffer( GL_ARRAY_BUFFER, 0 );
		return true;
	}

	if (type==USE_TRIANGLES && triVBO > 0)
	{
		glBindBuffer( GL_ARRAY_BUFFER, triVBO );
		glEnableClientState( GL_VERTEX_ARRAY );
		glVertexPointer( 3, GL_FLOAT, 3*sizeof(float)*vboTriComponents, BUFFER_OFFSET(0) );
		if (vboTriComponents >= 2)
		{
			glEnableClientState( GL_NORMAL_ARRAY );
			glNormalPointer( GL_FLOAT, 3*sizeof(float)*vboTriComponents, BUFFER_OFFSET(3*sizeof(float)) );
		}
		glDrawArrays( GL_TRIANGLES, 0, 3*vboTriCount );
		glDisableClientState( GL_VERTEX_ARRAY );
		if (vboTriComponents >= 1) glDisableClientState( GL_NORMAL_ARRAY );
		glBindBuffer( GL_ARRAY_BUFFER, 0 );
		return true;
	}

	return false;
}
Пример #13
0
void VboMesh::bindAllData() const
{
	if( mObj->mLayout.hasIndices() ) {
		mObj->mBuffers[INDEX_BUFFER].bind();
	}
	
	for( int buffer = STATIC_BUFFER; buffer <= DYNAMIC_BUFFER; ++buffer ) {
		if( ! mObj->mBuffers[buffer] ) continue;
		
		mObj->mBuffers[buffer].bind();
		uint8_t stride = ( buffer == STATIC_BUFFER ) ? mObj->mStaticStride : mObj->mDynamicStride;
		
		if( ( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticNormals() : mObj->mLayout.hasDynamicNormals() ) )
			glNormalPointer( GL_FLOAT, stride, ( const GLvoid *)mObj->mNormalOffset );

		if( ( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticColorsRGB() : mObj->mLayout.hasDynamicColorsRGB() ) )
			glColorPointer( 3, GL_FLOAT, stride, ( const GLvoid *)mObj->mColorRGBOffset );
		else if( ( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticColorsRGBA() : mObj->mLayout.hasDynamicColorsRGBA() ) )
			glColorPointer( 4, GL_FLOAT, stride, ( const GLvoid *)mObj->mColorRGBAOffset );


		for( size_t t = 0; t <= ATTR_MAX_TEXTURE_UNIT; ++t ) {
			if( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticTexCoords2d( t ) : mObj->mLayout.hasDynamicTexCoords2d( t ) ) {
				glClientActiveTexture( GL_TEXTURE0 + t );
				glTexCoordPointer( 2, GL_FLOAT, stride, (const GLvoid *)mObj->mTexCoordOffset[t] );
			}
			else if( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticTexCoords3d( t ) : mObj->mLayout.hasDynamicTexCoords3d( t ) ) {
				glClientActiveTexture( GL_TEXTURE0 + t );
				glTexCoordPointer( 3, GL_FLOAT, stride, (const GLvoid *)mObj->mTexCoordOffset[t] );
			}
		}	

		if( ( buffer == STATIC_BUFFER ) ? mObj->mLayout.hasStaticPositions() : mObj->mLayout.hasDynamicPositions() )
			glVertexPointer( 3, GL_FLOAT, stride, (const GLvoid*)mObj->mPositionOffset );
	}

	for( int buffer = STATIC_BUFFER; buffer <= DYNAMIC_BUFFER; ++buffer ) {
		if( ! mObj->mBuffers[buffer] ) continue;

		const vector<pair<VboMesh::Layout::CustomAttr,size_t> > &attributes( ( buffer == DYNAMIC_BUFFER ) ? mObj->mLayout.mCustomDynamic : mObj->mLayout.mCustomStatic );
		const vector<GLint> &locations( ( buffer == DYNAMIC_BUFFER ) ? mObj->mCustomDynamicLocations : mObj->mCustomStaticLocations );
		GLsizei stride = ( ( buffer == DYNAMIC_BUFFER ) ? mObj->mDynamicStride : mObj->mStaticStride );
	
		if( attributes.empty() )
			continue;
		
		mObj->mBuffers[buffer].bind();
		
		for( size_t a = 0; a < attributes.size(); ++a ) {
			const GLvoid *offset = reinterpret_cast<const GLvoid*>( attributes[a].second );
			glVertexAttribPointer( locations[a], Layout::sCustomAttrNumComponents[attributes[a].first], Layout::sCustomAttrTypes[attributes[a].first], GL_FALSE, stride, offset );
		}	
	}
}
Пример #14
0
void S3DOPiece::UnbindVertexAttribVBOs() const
{
	glClientActiveTexture(GL_TEXTURE1);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
}
Пример #15
0
GLvoid
draw_rect_multitex(float x, float y, float w, float h,
		   float tx, float ty, float tw, float th)
{
	float verts[4][4];
	float tex[4][2];

	verts[0][0] = x;
	verts[0][1] = y;
	verts[0][2] = 0.0;
	verts[0][3] = 1.0;
	tex[0][0] = tx;
	tex[0][1] = ty;
	verts[1][0] = x + w;
	verts[1][1] = y;
	verts[1][2] = 0.0;
	verts[1][3] = 1.0;
	tex[1][0] = tx + tw;
	tex[1][1] = ty;
	verts[2][0] = x + w;
	verts[2][1] = y + h;
	verts[2][2] = 0.0;
	verts[2][3] = 1.0;
	tex[2][0] = tx + tw;
	tex[2][1] = ty + th;
	verts[3][0] = x;
	verts[3][1] = y + h;
	verts[3][2] = 0.0;
	verts[3][3] = 1.0;
	tex[3][0] = tx;
	tex[3][1] = ty + th;

	glVertexPointer(4, GL_FLOAT, 0, verts);
	glEnableClientState(GL_VERTEX_ARRAY);

	glClientActiveTexture(GL_TEXTURE0);
	glTexCoordPointer(2, GL_FLOAT, 0, tex);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE1);
	glTexCoordPointer(2, GL_FLOAT, 0, tex);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glDrawArrays(GL_QUADS, 0, 4);

	glDisableClientState(GL_VERTEX_ARRAY);

	glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE1);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
Пример #16
0
void ResManager::Init(const string& dirResources, const string& dirUser, 
	int screenWidth, int screenHeight)
{
	m_dirUser = dirUser + FILE_SEPERATOR;
	m_dirResources = dirResources + FILE_SEPERATOR;
#ifdef _DEBUG
	cout << m_dirResources << endl;
	cout << m_dirUser << endl;
#endif
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
	glEnable(GL_CULL_FACE);
	glDisable(GL_DITHER);	// these are enabled by default
	glDisable(GL_ALPHA_TEST);
	
	glViewport(0, 0, m_screenWidth, m_screenHeight);
	m_initialised = true;
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glDisable(GL_LIGHTING);
	glFrontFace(GL_CW);
    glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	// set orthographic, so that we are drawing billboard style using screen dimensions 
	glOrthof(0, (float)m_screenWidth, (float)m_screenHeight, 0, -50.0f, 50.0f);

	glActiveTexture(GL_TEXTURE1);
	//glDisable(GL_TEXTURE_2D);
	glActiveTexture(GL_TEXTURE0);
	//glEnable(GL_TEXTURE_2D);
	glClientActiveTexture(GL_TEXTURE1);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glClientActiveTexture(GL_TEXTURE0);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisable(GL_DEPTH_TEST);	
	// handle tranparancy
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	const char* szLetters = " !\"#&'()*,-./0123456789:;<=>[email protected]\\_abcdefghijklmnopqrstuvwxyzÁáÉéÍíÑñÓóÚú";

	m_pFontAtlas = new FontAtlas();
	//m_pFontAtlas->AddFont("arial.ttf", 12, szLetters);
	//m_pFontAtlas->AddFont("times.ttf", 18, szLetters);
	//m_pFontAtlas->AddFont("times.ttf", 16, szLetters);
	m_pFontAtlas->CreateAtlas();


}
Пример #17
0
CVoid CSkyDome::RenderDome()
{
	glUseProgram(0);
	glMatrixMode( GL_MODELVIEW );
	g_render.PushMatrix();
	glTranslatef( m_position[0], m_position[1], m_position[2] );

	glPushAttrib( GL_LIGHTING_BIT );
	glDisable( GL_LIGHTING );
	//glDisable(GL_DEPTH_TEST);
	int i;
	g_render.BindVBO(GL_ARRAY_BUFFER, 0 ); // Disable VBOs

    //glColor3f(1,1,1);

    //glEnable(GL_BLEND);
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	if( g_polygonMode == ePOLYGON_FILL )
	{
		glActiveTexture( GL_TEXTURE0 );
		glEnable( GL_TEXTURE_2D );
		glBindTexture( GL_TEXTURE_2D, m_image->GetId() );

		glClientActiveTexture(GL_TEXTURE0);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glTexCoordPointer(2, GL_FLOAT, 0, &m_texCoordBuffer[0]);
	}
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, &m_vertexBuffer[0]);

	
	for (i = 0; i < m_numSlices; i++)
	{
		g_render.BindVBO(GL_ELEMENT_ARRAY_BUFFER, 0 );
		glDrawElements(GL_TRIANGLE_STRIP, (m_numSides + 1) * 2, GL_UNSIGNED_SHORT, &m_indexBuffer[i * (m_numSides + 1) * 2]);
	}
	
	glDisableClientState(GL_VERTEX_ARRAY);

    glClientActiveTexture(GL_TEXTURE0);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, 0);
	glDisable(GL_TEXTURE_2D);

	//glDisable(GL_BLEND);
	//glEnable(GL_DEPTH_TEST);
	glPopAttrib();
	glPopMatrix();
}
Пример #18
0
static void gl1_renderchain_disable_client_arrays(void *data,
      void *chain_data)
{
   if (gl_query_core_context_in_use())
      return;

   glClientActiveTexture(GL_TEXTURE1);
   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   glClientActiveTexture(GL_TEXTURE0);
   glDisableClientState(GL_VERTEX_ARRAY);
   glDisableClientState(GL_COLOR_ARRAY);
   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
Пример #19
0
void RenderManager::Init(int32 _frameBufferWidth, int32 _frameBufferHeight)
{
    DetectRenderingCapabilities();

    if (!FLAT_COLOR)
        FLAT_COLOR = ColorOnlyEffect::Create(renderer);
    if (!TEXTURE_MUL_FLAT_COLOR) 
        TEXTURE_MUL_FLAT_COLOR= TextureMulColorEffect::Create(renderer);
    if (!TEXTURE_MUL_FLAT_COLOR_ALPHA_TEST)
        TEXTURE_MUL_FLAT_COLOR_ALPHA_TEST = TextureMulColorAlphaTestEffect::Create(renderer);

#if defined(__DAVAENGINE_DIRECTX9__)
	currentState.direct3DDevice = GetD3DDevice();
#endif
    
    RenderManager::LockNonMain();
	currentState.Reset(false);
    hardwareState.Reset(true);

#if defined(__DAVAENGINE_OPENGL__)
#if !defined(__DAVAENGINE_IPHONE__) && !defined(__DAVAENGINE_ANDROID__)//Dizz: glDisableClientState functions are not supported by GL ES 2.0
    glDisableClientState(GL_VERTEX_ARRAY);
    oldVertexArrayEnabled = 0;                      

    glDisableClientState(GL_NORMAL_ARRAY);
    oldNormalArrayEnabled = 0;                      
	for (int k = 0; k < RenderState::MAX_TEXTURE_LEVELS; ++k)
    {
        glClientActiveTexture(GL_TEXTURE0 + k);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        oldTextureCoordArrayEnabled[k] = 0;                
    }
    glClientActiveTexture(GL_TEXTURE0);
    
    glDisableClientState(GL_COLOR_ARRAY);
    oldColorArrayEnabled = 0;                       

    RenderManager::UnlockNonMain();
#endif    
#endif
    
	frameBufferWidth = _frameBufferWidth;
	frameBufferHeight = _frameBufferHeight;
#if defined (__DAVAENGINE_OPENGL__)
//	Logger::Debug("[RenderManager::Init] orientation: %d x %d", frameBufferWidth, frameBufferHeight);
#else
//	Logger::Debug("[RenderManager::Init] orientation: %d x %d ", frameBufferWidth, frameBufferHeight);
#endif
    // TODO: Rethink of initialization concepts because they changed
    pointerArraysRendererState = pointerArraysCurrentState = 0;
}
Пример #20
0
void HouseChemry::Draw(){

	glUseProgram(shaderProgramID);

	glPushMatrix();

	glActiveTexture(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D); 
	glBindTexture(GL_TEXTURE_2D, housechemry_texture_id);

	glBindBuffer(GL_ARRAY_BUFFER, vboID);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID);

	glClientActiveTexture(GL_TEXTURE0);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(12));


	glVertexPointer(3, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(0));
	glNormalPointer(GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(20));
	glColorPointer(4, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(32));

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);


	glDrawElements(GL_TRIANGLES, numberOfIndices, GL_UNSIGNED_INT, BUFFER_OFFSET(0));


	glDisable(GL_TEXTURE_2D);

	glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glActiveTexture(GL_TEXTURE0);
	glDisable(GL_TEXTURE_2D);


	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);


	glPopMatrix();

	glUseProgram(0);
}
Пример #21
0
static void gl1_renderchain_ff_vertex(const void *data)
{
   const struct video_coords *coords = (const struct video_coords*)data;
   /* Fall back to fixed function-style if needed and possible. */
   glClientActiveTexture(GL_TEXTURE1);
   glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   glClientActiveTexture(GL_TEXTURE0);
   glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
   glEnableClientState(GL_VERTEX_ARRAY);
   glColorPointer(4, GL_FLOAT, 0, coords->color);
   glEnableClientState(GL_COLOR_ARRAY);
   glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
Пример #22
0
/*******************************************************************************
 * Function Name  : DrawDualTexQuad
 * Input		  : Size, (x,y,z) and texture pntr
 * Description    : Basic Draw Dual Textured Quad with Size in Location X, Y, Z.
 *******************************************************************************/
void OGLESEvilSkull::DrawDualTexQuad(float x, float y, float z, float Size, GLuint ui32Texture1, GLuint ui32Texture2)
{
	// Set Texture and Texture Options
	glBindTexture(GL_TEXTURE_2D, ui32Texture1);

	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, ui32Texture2);
	glEnable(GL_TEXTURE_2D);

	// Vertex Data
	VERTTYPE verts[] =		{	f2vt(x+Size), f2vt(y-Size), f2vt(z),
								f2vt(x+Size), f2vt(y+Size), f2vt(z),
								f2vt(x-Size), f2vt(y-Size), f2vt(z),
								f2vt(x-Size), f2vt(y+Size), f2vt(z)
							};

	VERTTYPE texcoords[] =	{	f2vt(0.0f), f2vt(1.0f),
								f2vt(0.0f), f2vt(0.0f),
								f2vt(1.0f), f2vt(1.0f),
								f2vt(1.0f), f2vt(0.0f)
							};

	// Set Arrays - Only need Vertex Array and Tex Coord Arrays
	glVertexPointer(3,VERTTYPEENUM,0,verts);

    glClientActiveTexture(GL_TEXTURE0);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2,VERTTYPEENUM,0,texcoords);

	glClientActiveTexture(GL_TEXTURE1);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2,VERTTYPEENUM,0,texcoords);

	// Draw Strip
	glDrawArrays(GL_TRIANGLE_STRIP,0,4);

	// Disable Arrays
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glClientActiveTexture(GL_TEXTURE0);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, 0);
	glDisable(GL_TEXTURE_2D);

	glActiveTexture(GL_TEXTURE0);
}
Пример #23
0
static CoglBool
toggle_texcood_attribute_enabled_cb (int bit_num, void *user_data)
{
  ForeachChangedBitState *state = user_data;
  CoglContext *context = state->context;

  _COGL_RETURN_VAL_IF_FAIL ((context->private_feature_flags &
                             COGL_PRIVATE_FEATURE_FIXED_FUNCTION),
                            FALSE);

#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
  {
    CoglBool enabled = _cogl_bitmask_get (state->new_bits, bit_num);

    GE( context, glClientActiveTexture (GL_TEXTURE0 + bit_num) );

    if (enabled)
      GE( context, glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
    else
      GE( context, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
  }
#endif

  return TRUE;
}
Пример #24
0
static int 
SetupGraphics(void)
{
    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

    CreateTexture(Width, Height);

    glDisable(GL_DEPTH_TEST);
    glActiveTexture(GL_TEXTURE0);
    
    glViewport(0, 0, Width, Height);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    TexCoords[3][0] = 0.0f;
    TexCoords[3][1] = 0.0f;
    TexCoords[2][0] = Width;
    TexCoords[2][1] = 0.0f;
    TexCoords[1][0] = Width;
    TexCoords[1][1] = Height;
    TexCoords[0][0] = 0.0f;
    TexCoords[0][1] = Height;

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, VertexPos);
    glClientActiveTexture(GL_TEXTURE0);
    glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);
    return GL_NO_ERROR;
}
Пример #25
0
int G3EnableClientStates (int bTexCoord, int bColor, int bNormals, int nTMU)
{
if (nTMU >= 0) {
	glActiveTexture (nTMU);
	glClientActiveTexture (nTMU);
	}
if (!G3EnableClientState (GL_VERTEX_ARRAY, -1))
	return 0;
if (bNormals) {
	if (!G3EnableClientState (GL_NORMAL_ARRAY, -1)) {
		G3DisableClientStates (0, 0, 0, -1);
		return 0;
		}
	}
else
	glDisableClientState (GL_NORMAL_ARRAY);
if (bTexCoord) {
	if (!G3EnableClientState (GL_TEXTURE_COORD_ARRAY, -1)) {
		G3DisableClientStates (0, 0, 0, -1);
		return 0;
		}
	}
else
	glDisableClientState (GL_TEXTURE_COORD_ARRAY);
if (bColor) {
	if (!G3EnableClientState (GL_COLOR_ARRAY, -1)) {
		G3DisableClientStates (bTexCoord, 0, 0, -1);
		return 0;
		}
	}
else
	glDisableClientState (GL_COLOR_ARRAY);
return 1;
}
Пример #26
0
void RenderPipe_img_opengl::render( GLuint target )
{
    glDepthMask(GL_FALSE);
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, target);

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    glUseProgram(m_pipeProgramID);

    glActiveTexture(GL_TEXTURE0_ARB);
    glClientActiveTexture(GL_TEXTURE0_ARB);

    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, m_texture);

    renderScreenQuad();
    glUseProgram(0);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    glDepthMask(GL_TRUE);
}
Пример #27
0
void gl_ff_vertex(const struct video_coords *coords)
{
#ifndef NO_GL_FF_VERTEX
   /* Fall back to fixed function-style if needed and possible. */
   glClientActiveTexture(GL_TEXTURE1);
   glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   glClientActiveTexture(GL_TEXTURE0);
   glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
   glEnableClientState(GL_VERTEX_ARRAY);
   glColorPointer(4, GL_FLOAT, 0, coords->color);
   glEnableClientState(GL_COLOR_ARRAY);
   glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
}
Пример #28
0
void SORE_Graphics::GraphicsArray::BeginDraw()
{
    BeginDrawHook();

    glVertexPointer(3, GL_FLOAT, sizeof(vertex), GetOffset(&(vertices[0]), offsetof(vertex, x)));
    if(hasTexCoords)
    {
        glClientActiveTexture(GL_TEXTURE0);
        glTexCoordPointer(2, GL_FLOAT, sizeof(vertex),
                          GetOffset(&(vertices[0]), offsetof(vertex, tex0i)));
    }
    if(hasNormals)
    {
        glNormalPointer(GL_FLOAT, sizeof(vertex), GetOffset(&(vertices[0]), offsetof(vertex, normx)));
    }
    if(hasColors)
    {
        glColorPointer(4, GL_FLOAT, sizeof(vertex), GetOffset(&(vertices[0]), offsetof(vertex, r)));
    }

    glEnableClientState(GL_VERTEX_ARRAY);
    if(hasColors)
        glEnableClientState(GL_COLOR_ARRAY);
    if(hasTexCoords)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    if(hasNormals)
        glEnableClientState(GL_NORMAL_ARRAY);

}
Пример #29
0
	bool OGLRenderSystem::ApplyVertexDeclaration( int stride, char* data )
	{
		static const int glVDeclType[] = { GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_SHORT, GL_UNSIGNED_BYTE, GL_SHORT, GL_SHORT, GL_UNSIGNED_SHORT, GL_UNSIGNED_SHORT, 0, 0, 0, 0 };
		static const int glVDeclCount[] = {  1, 2,  3,  4, 4, 4, 2, 4, 4, 2, 4, 2, 4, 0, 0, 0, 0, 0 };
		if( !mRenderState.mVDeclaration )
			return false;

		int curPos = 0;
		for( VertexElement::List::iterator i = mRenderState.mVDeclaration->mElements.begin( ); i != mRenderState.mVDeclaration->mElements.end( ); i++ )
		{
			switch( (*i).semantic )
			{
			case VDeclSemantic::POSITION:
				glEnableClientState( GL_VERTEX_ARRAY );
				glVertexPointer( glVDeclCount[ (*i).type ], glVDeclType[ (*i).type ], stride, data + curPos );
				break;
			case VDeclSemantic::TEXCOORD:
				glClientActiveTexture( GL_TEXTURE0_ARB + (*i).usageidx );
				glTexCoordPointer( glVDeclCount[ (*i).type ], glVDeclType[ (*i).type ], stride, data + curPos );
				glEnableClientState( GL_TEXTURE_COORD_ARRAY );
				break;
			case VDeclSemantic::COLOUR:
				glEnableClientState( GL_COLOR_ARRAY );
				glColorPointer( glVDeclCount[ (*i).type ], glVDeclType[ (*i).type ], stride, data + curPos );
				break;
			}

			curPos += VDeclType::LENGTH[ (*i).type ];
		}

		return true;
	};
Пример #30
0
static gboolean
toggle_texcood_attribute_enabled_cb (int bit_num, void *user_data)
{
  ForeachChangedBitState *state = user_data;
  CoglContext *context = state->context;

  _COGL_RETURN_VAL_IF_FAIL (_cogl_has_private_feature
                            (context, COGL_PRIVATE_FEATURE_GL_FIXED),
                            FALSE);

#ifdef HAVE_COGL_GL
  {
    gboolean enabled = _cogl_bitmask_get (state->new_bits, bit_num);

    GE( context, glClientActiveTexture (GL_TEXTURE0 + bit_num) );

    if (enabled)
      GE( context, glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
    else
      GE( context, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
  }
#endif

  return TRUE;
}