Example #1
0
void Quiddiards::drawGround(){
	glPushMatrix();
	//glTranslatef(center.x(), center.y(), 0);
	int n = Ground::RESO - 1;
	bindTexture("ground.jpg");
	glDisable(GL_CULL_FACE);
	glBegin(GL_QUADS);
	for (int x = 0; x < n; x++){
		for (int y = 0; y < n; y++){
			QVector3D p00 = ground->at(x, y), p10 = ground->at(x + 1, y), p11 = ground->at(x + 1, y + 1), p01 = ground->at(x, y + 1);
			QVector3D n = QVector3D::crossProduct(p11 - p00, p01 - p10);
			glNormal3f(n.x(), n.y(), n.z());
			glTexCoord2f(0, 0);
			glVertex3f(p00.x(), p00.y(), p00.z());
			glTexCoord2f(1, 0);
			glVertex3f(p10.x(), p10.y(), p10.z());
			glTexCoord2f(1, 1);
			glVertex3f(p11.x(), p11.y(), p11.z());
			glTexCoord2f(0, 1);
			glVertex3f(p01.x(), p01.y(), p01.z());
		}
	}
	glEnd();
	glEnable(GL_CULL_FACE);
	releaseTexture();
	glPopMatrix();
}
Example #2
0
void Quiddiards::drawBall(const Ball& ball){
	glPushMatrix();

	glTranslatef(ball.getX(), ball.getY(), ball.getZ());
	//transpose the matrix because qt uses row-major matrix while opengl use column major matrix
	glMultMatrixf(ball.getRotation().transposed().constData());


	switch (ball.getType()){
	case Ball::QUAFFLE:
		bindTexture("quaffle.jpg");
		break;
	case Ball::BLUDGER:
		bindTexture("bludger.jpg");
		break;
	case Ball::CUEBALL:
		bindTexture("cueball.jpg");
		break;
	case Ball::SNITCH:
		bindTexture("snitch.jpg");
		break;
	default:
		QVector3D color = ball.getColor();
		glColor3f(color.x(), color.y(), color.z());
		break;
	}

	gluSphere(quad, ball.getR(), 16, 16);
	releaseTexture();

	glPopMatrix();
}
Example #3
0
int createTexture(AndroidContext *rc)
{
        if (!rc)
          return 0;
	if ( rc->texID >= 0 )
		releaseTexture(rc);

	LOG( ANDROID_LOG_INFO, TAG, "Android Create Texture Size: WxH: %dx%d",
                                            rc->tex_width, rc->tex_height);

	glGenTextures( 1, &(rc->texID) );

	rc->texData = (GLubyte*)gf_malloc( 4 * rc->tex_width * rc->tex_height );
	memset(rc->texData, 255, 4 * rc->tex_width * rc->tex_height );
	//memset(data, 0, 4 * width * height/2 );

	glBindTexture( GL_TEXTURE_2D, rc->texID);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

	glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, rc->tex_width, rc->tex_height, 0,
				GL_RGBA, GL_UNSIGNED_BYTE, NULL/*rc->texData*/ );

	glBindTexture( GL_TEXTURE_2D, 0);
        LOG( ANDROID_LOG_VERBOSE, TAG, "Android Create Texture DONE");
	return 0;
}
Example #4
0
const Texture& Texture::operator = (const Texture& another)
{
    if (textVertexArray) {
        delete []textVertexArray;
    }
    if (vertexPmtId) {
        delete []vertexPmtId;
    }
    releaseTexture();

    if (textVertexCount > 0) {
        textVertexCount = another.getVertexCount();
        vertexPmtCnt = another.getVertexPmtCnt();
        textVertexArray = new QPair<double, double>[textVertexCount];
        vertexPmtId = new int[textVertexCount];
        QPair<double, double>* vertex = another.getVertexArray();
        int* pmtId = another.getVertexPmtId();
        for (int i = 0; i < textVertexCount; ++i) {
            textVertexArray[i] = vertex[i];
            vertexPmtId[i] = pmtId[i];
        }
    }
    setFileName(another.getFileName());
    return *this;
}
RenderTexture::~RenderTexture()
{
#if BDE_GLOBAL_ENABLE_NICE_DESTROY
	if (mDxTexture)
		releaseTexture();
#endif
}
Example #6
0
void BitmapClass::shutdown()
{
	releaseTexture();

	shutdownBuffers();

	return ;
}
Example #7
0
void ModelClass::shutdown()
{
	releaseTexture();

	shutdownBuffers();

	return ;
}
Example #8
0
Texture::~Texture()
{
    if (textVertexArray) {
        delete []textVertexArray;
    }
    if (vertexPmtId) {
        delete []vertexPmtId;
    }
    releaseTexture();
}
Example #9
0
void Graphics::tryUpdateTexture_()
{
	if ( textureDirty_ ) {
		releaseTexture();
		textureDirty_ = false;
		
		Texture* texture = textureMgr.getInstance().createPrimitivesTexture( primitives_ );
		setTexture( texture );
		updateBoundingBox_();
	}
}
Example #10
0
static void droid_Shutdown(GF_VideoOutput *dr)
{
	RAWCTX;
	LOG( ANDROID_LOG_DEBUG, TAG, "Android Shutdown\n");

	releaseTexture(rc);
#ifdef GLES_FRAMEBUFFER_TEST
	releaseFrameBuffer(rc);
#endif
        LOG( ANDROID_LOG_VERBOSE, TAG, "Android Shutdown DONE");
}
Example #11
0
void RenderSystem::shutdown() {
  assert (m_initialised);
 
  if (debug) std::cout << "RenderSystem: Shutdown" << std::endl;
  ContextDestroyed.emit(true);
  
  releaseTexture(m_mouseState[CURSOR_DEFAULT]);
  releaseTexture(m_mouseState[CURSOR_TOUCH]);
  releaseTexture(m_mouseState[CURSOR_PICKUP]);
  releaseTexture(m_mouseState[CURSOR_USE]);
  releaseTexture(m_mouseState[CURSOR_ATTACK]);

  m_renderer->shutdown();

  m_cameraSystem.reset(0);
  m_graphics.reset(0);
  m_renderer.reset(0);
  m_stateManager.reset(0);
  m_textureManager.reset(0);

  m_initialised = false;
}
Example #12
0
void MailboxTextureHolder::releaseTextureThreadSafe() {
  // If this member is still null, it means we are still at the thread where
  // the m_texture was created.
  std::unique_ptr<gpu::SyncToken> passedSyncToken(
      new gpu::SyncToken(m_syncToken));
  if (!wasTransferred()) {
    releaseTexture(m_isConvertedFromSkiaTexture, m_textureId, m_contextProvider,
                   std::move(passedSyncToken));
  } else if (wasTransferred() && textureThreadTaskRunner()) {
    textureThreadTaskRunner()->postTask(
        BLINK_FROM_HERE,
        crossThreadBind(&releaseTexture, m_isConvertedFromSkiaTexture,
                        m_textureId, passed(std::move(m_contextProvider)),
                        passed(std::move(passedSyncToken))));
  }
  m_textureId = 0u;  // invalidate the texture.
  setWasTransferred(false);
  setTextureThreadTaskRunner(nullptr);
}
Example #13
0
void Texture::generateTexture()
{
    if (fileName != "" && textVertexArray != 0) {
        // bind texture to image
        loadTextureImage();

        releaseTexture();
        // generate id
        glGenTextures(1, &textureId);

        glBindTexture(GL_TEXTURE_2D, textureId);
        glTexImage2D(GL_TEXTURE_2D, 0, 4,//GL_RGBA,
                     textureImage.width(), textureImage.height(),
                     0, GL_RGBA, GL_UNSIGNED_BYTE, textureImage.bits());
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    }
}
void RenderTexture::setData(uint32* dataRGBA32, unsigned int height, unsigned int width)
{
	Assert(dataRGBA32);
	Assert(height > 0);
	Assert(width > 0);
	if (!mDxTexture)
	{
		// uninitialized buffer
		createTexture(dataRGBA32, height, width);
	}
	else if (mDataWidth == width && mDataHeight == height)
	{
		releaseTexture();
		createTexture(dataRGBA32, height, width);
	}
	else
	{
		fillTexture(dataRGBA32);
	}
}
Example #15
0
void Quiddiards::drawCueBroom(){
	// draw cuebroom only if cueball is not running
	glPushMatrix();

	//glColor3ub(0x7f, 0x3f, 0x0);
	glTranslatef(cuebroom.getX(), cuebroom.getY(), cuebroom.getZ());
	glMultMatrixf(cuebroom.getRotation().transposed().constData());
	bindTexture("stick.jpg");
	gluCylinder(quad, cuebroom.getR1(), cuebroom.getR0(), cuebroom.getStickLen(), 12, 6);
	releaseTexture();
	glPopMatrix();
	//glPushMatrix();
	//glTranslatef(cuebroom.getJoint().x(), cuebroom.getJoint().y(), cuebroom.getJoint().z());
	//gluDisk(quad, 0, cuebroom.getR0(), 1, 1);
	//glPopMatrix();
	//glPushMatrix();
	//glTranslatef(cuebroom.getHead().x(), cuebroom.getHead().y(), cuebroom.getHead().z());
	//gluDisk(quad, 0, cuebroom.getR1(), 1, 1);
	//glPopMatrix();
}
Example #16
0
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
    QSize size = Application::getInstance()->getGLWidget()->getDeviceSize();
    if (_framebufferObject != NULL && size == _framebufferObject->size()) {
        // Already build
        return;
    }
    
    if (_framebufferObject != NULL) {
        delete _framebufferObject;
    }
    
    _framebufferObject = new QOpenGLFramebufferObject(size);
    bindTexture();
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
    GLfloat borderColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
    releaseTexture();
}
Example #17
0
}

void GLTexture::initTexture(int w, int h)
{
	if (tex[0] != 0)
	{
		releaseTexture();
	}
        
    glGenTextures(1, &tex[0]);
	glEnable(texTarget);
    glBindTexture(texTarget, tex[0]);
    glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, minFilter);
    glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, magFilter);
    glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
    
	if (texTarget == GL_TEXTURE_1D) glTexImage1D(texTarget, 0, texInternalFormat, w, 0, GL_RGBA, type, NULL);
    else glTexImage2D(texTarget, 0, texInternalFormat, w, h, 0, GL_RGBA, type, NULL);
    
	glDisable(texTarget);
    glBindTexture(texTarget, 0);
	

	/*
    if (texTarget == GL_TEXTURE_RECTANGLE_ARB)
    {
		this->maxCoordS = w;
        this->maxCoordT = h;
	}
    else
    {
		this->maxCoordS = 1.0f;
        this->maxCoordT = 1.0f; 
	}*/

	width = w;
	height = h;

	printf("[GLtexture.init] %i, %i\n", width,height);
RenderableWebEntityItem::~RenderableWebEntityItem() {
    if (_webSurface) {
        _webSurface->pause();
        _webSurface->disconnect(_connection);
        // After the disconnect, ensure that we have the latest texture by acquiring the 
        // lock used when updating the _texture value
        _textureLock.lock();
        _textureLock.unlock();
        // The lifetime of the QML surface MUST be managed by the main thread
        // Additionally, we MUST use local variables copied by value, rather than
        // member variables, since they would implicitly refer to a this that 
        // is no longer valid
        auto webSurface = _webSurface;
        auto texture = _texture;
        AbstractViewStateInterface::instance()->postLambdaEvent([webSurface, texture] {
            if (texture) {
                webSurface->releaseTexture(texture);
            }
            webSurface->deleteLater();
        });
    }
    qDebug() << "Destroyed web entity " << getID();
}
Example #19
0
void Quiddiards::drawTable(){
	static GLfloat x1 = table.getRugLen() / 2,
		y1 = table.getRugWid() / 2,
		z1 = table.getRugHgt(),
		x2 = table.getDamLen() / 2,
		y2 = table.getDamWid() / 2,
		z2 = table.getDamHgt(),
		z3 = table.getBtmHgt();
	static GLfloat pTable[14 * 4 * 3] = {
		//desktop
		x1, y1, z1, -x1, y1, z1, -x1, -y1, z1, x1, -y1, z1,
		//bottom
		x2, y2, z3, x2, -y2, z3, -x2, -y2, z3, -x2, y2, z3,
		//front inner face
		x1, -y1, z2, x1, y1, z2, x1, y1, z1, x1, -y1, z1,
		//front upper face
		x1, y2, z2, x1, -y2, z2, x2, -y2, z2, x2, y2, z2,
		//front outer face
		x2, y2, z2, x2, -y2, z2, x2, -y2, z3, x2, y2, z3,
		//right inner face
		x1, y1, z2, -x1, y1, z2, -x1, y1, z1, x1, y1, z1,
		//right upper face
		x2, y2, z2, -x2, y2, z2, -x2, y1, z2, x2, y1, z2,
		//right outer face
		-x2, y2, z2, x2, y2, z2, x2, y2, z3, -x2, y2, z3,
		//back inner face
		-x1, y1, z2, -x1, -y1, z2, -x1, -y1, z1, -x1, y1, z1,
		//back upper face
		-x1, -y2, z2, -x1, y2, z2, -x2, y2, z2, -x2, -y2, z2,
		//back outer face
		-x2, -y2, z2, -x2, y2, z2, -x2, y2, z3, -x2, -y2, z3,
		//left inner face
		-x1, -y1, z2, x1, -y1, z2, x1, -y1, z1, -x1, -y1, z1,
		//left upper face
		-x2, -y2, z2, x2, -y2, z2, x2, -y1, z2, -x2, -y1, z2,
		//left outer face
		x2, -y2, z2, -x2, -y2, z2, -x2, -y2, z3, x2, -y2, z3
	};
	static GLfloat pLegs[4 * 3] = {
		//leg centers
		x1, y1, 0, -x1, y1, 0, -x1, -y1, 0, x1, -y1, 0
	};
	static GLfloat pHoles[6 * 3] = {
		//hole centers
		x1 - 0.01, y1 - 0.01, z1 + 0.01,
		x1 - 0.01, -y1 + 0.01, z1 + 0.01,
		-x1 + 0.01, -y1 + 0.01, z1 + 0.01,
		-x1 + 0.01, y1 - 0.01, z1 + 0.01,
		0, y1 - 0.01, z1 + 0.01,
		0, -y1 + 0.01, z1 + 0.01
	};

	static GLfloat pTableTex[14 * 4 * 2] = {
		8, 0, 8, 8, 0, 8, 0, 0,
		8, 0, 8, 8, 0, 8, 0, 0,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1,
		0, 0, 4, 0, 4, 1, 0, 1
	};
	glPushMatrix();

	//draw table
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, pTable);
	glTexCoordPointer(2, GL_FLOAT, 0, pTableTex);
	//rug
	//glColor3ub(0x0, 0x5f, 0x0);
	bindTexture("rug.jpg");
	glDrawArrays(GL_QUADS, 0, 4);
	releaseTexture();
	//dam
	//glColor3ub(0x7f, 0x4f, 0x0);
	bindTexture("dam.jpg");
	glDrawArrays(GL_QUADS, 4, 13 * 4);
	releaseTexture();
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	//draw legs
	//glColor3ub(0x7f, 0x3f, 0x0);
	bindTexture("leg.jpg");
	for (int i = 0; i < 4; i++){
		glPushMatrix();
		glTranslatef(pLegs[3 * i], pLegs[3 * i + 1], pLegs[3 * i + 2]);
		gluCylinder(quad, table.getLegRad(), table.getLegRad(), table.getLegHgt(), 12, 6);
		glPopMatrix();
	}
	releaseTexture();

	// draw holes
	//glDisable(GL_CULL_FACE);
	//glColor3ub(0x0, 0x0, 0x0);
	//for (int i = 0; i < 6; i++){
	//	glPushMatrix();
	//	glTranslatef(pHoles[3 * i], pHoles[3 * i + 1], pHoles[3 * i + 2]);
	//	gluDisk(quad, 0, table.getHoleRad(), 12, 1);
	//	glRotatef(90, 1, 0, 0);
	//	gluDisk(quad, 0, table.getHoleRad(), 12, 1);
	//	if (i < 4){
	//		glRotatef(90, 0, 1, 0);
	//		gluDisk(quad, 0, table.getHoleRad(), 12, 1);
	//	}
	//	glPopMatrix();
	//}
	//glEnable(GL_CULL_FACE);

	glPopMatrix();
}
Example #20
0
wyRenderTexture::~wyRenderTexture() {
	releaseBuffer();
	releaseTexture();
}
Example #21
0
		void DiffuseModel::shutdown()
		{
			releaseTexture();
			shutdownBuffers();
		}
Example #22
0
/*
================
 Font::shutdown
================
*/
void Font::shutdown()
{
	releaseTexture();
	releaseFontData();
}
/** Executes test iteration.
 *
 *  @return Returns STOP when test has finished executing, CONTINUE if more iterations are needed.
 */
tcu::TestNode::IterateResult TextureFilterAnisotropicDrawingTestCase::iterate()
{
	const glw::Functions& gl = m_context.getRenderContext().getFunctions();

	bool result = true;

	GLfloat maxAnisoDegree = 2.0;

	gl.getFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisoDegree);
	GLU_EXPECT_NO_ERROR(gl.getError(), "getFloatv");

	std::vector<GLfloat> anisoVec;
	anisoVec.push_back(1.0f);
	anisoVec.push_back(2.0f);
	if (maxAnisoDegree > 2.0f)
		anisoVec.push_back(maxAnisoDegree);

	for (deUint32 iTarget = 0; iTarget < m_supportedTargets.size(); ++iTarget)
	{
		GLenum target = m_supportedTargets[iTarget];

		for (deUint32 iFormat = 0; iFormat < m_supportedInternalFormats.size(); ++iFormat)
		{
			GLenum format = m_supportedInternalFormats[iFormat];

			// Generate texture
			generateTexture(gl, target);

			// Fill texture with strips pattern
			fillTexture(gl, target, format);

			// Draw scene
			GLuint lastPoints = 0xFFFFFFFF;
			for (deUint32 i = 0; i < anisoVec.size(); ++i)
			{
				GLfloat aniso = anisoVec[i];

				if (result)
					result = result && drawTexture(gl, target, aniso);

				// Verify result
				if (result)
				{
					GLuint currentPoints = verifyScene(gl);

					if (lastPoints <= currentPoints)
					{
						m_testCtx.getLog()
							<< tcu::TestLog::Message
							<< "Anisotropy verification failed (lastPoints <= currentPoints) for "
							<< "anisotropy: " << aniso << ", "
							<< "target: " << glu::getTextureTargetName(target) << ", "
							<< "internalFormat: " << glu::getUncompressedTextureFormatName(format) << ", "
							<< "lastPoints: " << lastPoints << ", "
							<< "currentPoints: " << currentPoints << tcu::TestLog::EndMessage;

						result = false;
						break;
					}

					lastPoints = currentPoints;
				}
			}

			// Release texture
			releaseTexture(gl);

			if (!result)
			{
				// Stop loops
				iTarget = m_supportedTargets.size();
				iFormat = m_supportedInternalFormats.size();
			}
		}
	}

	if (result)
		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
	else
		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail");
	return STOP;
}
Example #24
0
ccMaterial::~ccMaterial()
{
	releaseTexture();
}
Example #25
0
/*
================
 Terrain::shutdown
================
*/
void Terrain::shutdown()
{
	releaseTexture();
	shutdownBuffers();
	shutdownHeightMap();
}
Example #26
0
void Quiddiards::drawFlag(Flag& flag){
	/* draw flag stick */
	glPushMatrix();
	glTranslatef(flag.getX(), flag.getY(), 0);

	bindTexture("stick.jpg");
	gluCylinder(quad, flag.getStickR(), flag.getStickR(), flag.getZ(), 12, 6);
	releaseTexture();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(flag.getX(), flag.getY(), flag.getZ());
	glRotatef(-90.0f, 1, 0, 0);
	float theta = 57.3f*atan2f(wind.y(), wind.x());
	glRotatef(theta, 0, -1, 0);
	glScalef(flag.getWid() / flag.RESO, flag.getHgt() / flag.RESO, flag.getBend());
	glTranslatef(0, 0, -flag.at(0, 0, 2));	// stick the flag to the stick

	/* load flag textures */
	switch (flag.getType()){
	case Flag::GRYFFINDOR:
		bindTexture("gryf.jpg");
		break;
	case Flag::SLYTHERIN:
		bindTexture("slyt.jpg");
		break;
	case Flag::HUFFLEPUFF:
		bindTexture("huff.jpg");
		break;
	case Flag::RAVENCLAW:
		bindTexture("rave.jpg");
		break;
	default:
		QVector3D color = flag.getColor();
		glColor3f(color.x(), color.y(), color.z());
		break;
	}
	/* use nurbs surface */
	/* nurbs points */
	//static const int sn = 8, tn = 4;	// surface and texture's u&v array size
	//static GLfloat texpts1[4 * 2] = { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f };
	//static GLfloat texpts2[4 * 2] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f };
	//static GLfloat knots[sn] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
	//static GLfloat tknots[tn] = { 0.0f, 0.0f, 1.0f, 1.0f };
	///* front */
	//static int n = Flag::RESO;
	//gluBeginSurface(nurbs);
	//gluNurbsSurface(nurbs, tn, tknots, tn, tknots, 2 * 2, 2, texpts1, tn / 2, tn / 2, GL_MAP2_TEXTURE_COORD_2);
	//gluNurbsSurface(nurbs, sn, knots, sn, knots, 3 * n, 3, flag.getPoints(), sn / 2, sn / 2, GL_MAP2_VERTEX_3);
	//gluEndSurface(nurbs);
	///* back */
	//glFrontFace(GL_CW);
	//gluBeginSurface(nurbs);
	//gluNurbsSurface(nurbs, tn, tknots, tn, tknots, 2 * 2, 2, texpts2, tn / 2, tn / 2, GL_MAP2_TEXTURE_COORD_2);
	//gluNurbsSurface(nurbs, sn, knots, sn, knots, 3 * n, 3, flag.getPoints(), sn / 2, sn / 2, GL_MAP2_VERTEX_3);
	//gluEndSurface(nurbs);
	//glFrontFace(GL_CCW);

	/* use quadrics */
	float x1, y1, x2, y2;
	int n = Flag::RESO - 1;
	glBegin(GL_QUADS);
	for (int x = 0; x < n; x++){
		for (int y = 0; y < n; y++){
			x1 = float(x) / n;
			y1 = float(y) / n;
			x2 = float(x + 1) / n;
			y2 = float(y + 1) / n;

			glTexCoord2f(x1, y1);
			glVertex3f(flag.at(x, y, 0), flag.at(x, y, 1), flag.at(x, y, 2));
			glTexCoord2f(x1, y2);
			glVertex3f(flag.at(x, y + 1, 0), flag.at(x, y + 1, 1), flag.at(x, y + 1, 2));
			glTexCoord2f(x2, y2);
			glVertex3f(flag.at(x + 1, y + 1, 0), flag.at(x + 1, y + 1, 1), flag.at(x + 1, y + 1, 2));
			glTexCoord2f(x2, y1);
			glVertex3f(flag.at(x + 1, y, 0), flag.at(x + 1, y, 1), flag.at(x + 1, y, 2));
		}
	}
	glEnd();

	glBegin(GL_QUADS);
	for (int x = 0; x < n; x++){
		for (int y = 0; y < n; y++){
			x1 = float(x) / n;
			y1 = float(y) / n;
			x2 = float(x + 1) / n;
			y2 = float(y + 1) / n;

			glTexCoord2f(x1, y1);
			glVertex3f(flag.at(n - x, y, 0), flag.at(n - x, y, 1), flag.at(n - x, y, 2));
			glTexCoord2f(x1, y2);
			glVertex3f(flag.at(n - x, y + 1, 0), flag.at(n - x, y + 1, 1), flag.at(n - x, y + 1, 2));
			glTexCoord2f(x2, y2);
			glVertex3f(flag.at(n - 1 - x, y + 1, 0), flag.at(n - 1 - x, y + 1, 1), flag.at(n - 1 - x, y + 1, 2));
			glTexCoord2f(x2, y1);
			glVertex3f(flag.at(n - 1 - x, y, 0), flag.at(n - 1 - x, y, 1), flag.at(n - 1 - x, y, 2));
		}
	}
	glEnd();
	releaseTexture();
	glPopMatrix();
}
Example #27
0
void Quiddiards::drawSkybox(){
	//draw sky
	// Note: the points are clockwise looking from outside, thus ccw from inside
	static GLfloat pSkybox[6 * 4 * 3] = {
		// front
		MAXRANGE, MAXRANGE, MAXRANGE,
		MAXRANGE, MAXRANGE, -MAXRANGE,
		MAXRANGE, -MAXRANGE, -MAXRANGE,
		MAXRANGE, -MAXRANGE, MAXRANGE,
		// right
		-MAXRANGE, MAXRANGE, MAXRANGE,
		-MAXRANGE, MAXRANGE, -MAXRANGE,
		MAXRANGE, MAXRANGE, -MAXRANGE,
		MAXRANGE, MAXRANGE, MAXRANGE,
		// back
		-MAXRANGE, -MAXRANGE, MAXRANGE,
		-MAXRANGE, -MAXRANGE, -MAXRANGE,
		-MAXRANGE, MAXRANGE, -MAXRANGE,
		-MAXRANGE, MAXRANGE, MAXRANGE,
		// left
		MAXRANGE, -MAXRANGE, MAXRANGE,
		MAXRANGE, -MAXRANGE, -MAXRANGE,
		-MAXRANGE, -MAXRANGE, -MAXRANGE,
		-MAXRANGE, -MAXRANGE, MAXRANGE,
		// up
		-MAXRANGE, MAXRANGE, MAXRANGE,
		MAXRANGE, MAXRANGE, MAXRANGE,
		MAXRANGE, -MAXRANGE, MAXRANGE,
		-MAXRANGE, -MAXRANGE, MAXRANGE,
		// down
		MAXRANGE, MAXRANGE, -MAXRANGE,
		-MAXRANGE, MAXRANGE, -MAXRANGE,
		-MAXRANGE, -MAXRANGE, -MAXRANGE,
		MAXRANGE, -MAXRANGE, -MAXRANGE,
	};

	static GLfloat pSkyboxTex[6 * 4 * 2] = {
		0, 0, 0, 1, 1, 1, 1, 0,
		0, 0, 0, 1, 1, 1, 1, 0,
		0, 0, 0, 1, 1, 1, 1, 0,
		0, 0, 0, 1, 1, 1, 1, 0,
		0, 0, 0, 1, 1, 1, 1, 0,
		0, 0, 0, 1, 1, 1, 1, 0,
	};

	static GLfloat pNorm[6 * 3] = {
		-1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1
	};

	glPushMatrix();
	//glTranslatef(center.x(), center.y(), center.z());
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, pSkybox);
	glTexCoordPointer(2, GL_FLOAT, 0, pSkyboxTex);
	glNormalPointer(GL_FLOAT, 0, pNorm);

	//glColorMaterial(GL_FRONT, GL_SPECULAR);
	//glDisable(GL_LIGHTING);
	bindTexture("skybox_front.jpg");
	glDrawArrays(GL_QUADS, 0, 4);
	releaseTexture();
	bindTexture("skybox_right.jpg");
	glDrawArrays(GL_QUADS, 4, 4);
	releaseTexture();
	bindTexture("skybox_back.jpg");
	glDrawArrays(GL_QUADS, 8, 4);
	releaseTexture();
	bindTexture("skybox_left.jpg");
	glDrawArrays(GL_QUADS, 12, 4);
	releaseTexture();
	bindTexture("skybox_up.jpg");
	glDrawArrays(GL_QUADS, 16, 4);
	releaseTexture();
	bindTexture("skybox_down.jpg");
	//bindTexture("ground.jpg");
	glDrawArrays(GL_QUADS, 20, 4);
	releaseTexture();
	//glEnable(GL_LIGHTING);
	//glColorMaterial(GL_FRONT, GL_DIFFUSE);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

	glPopMatrix();
}