Beispiel #1
0
	//--
	void
	CgShaderCelScreen::BindEnd()
	{
		CgShader::BindEnd();
	
		cgGLDisableTextureParameter(m_cgParamSamplerOutline);
		cgGLDisableTextureParameter(m_cgParamSamplerCel);	
	}
Beispiel #2
0
	//--
	void
	CgShaderCel::BindEnd()
	{
		CgShader::BindEnd();
		
		cgGLDisableTextureParameter(m_cgParamSamplerOutline);
		cgGLDisableTextureParameter(m_cgParamSamplerSpecular);
		cgGLDisableTextureParameter(m_cgParamSamplerDiffuse);	
	}
void CG_RENDER_CUBEMAP(void)
{
glPushMatrix();    
        glTranslatef(0, 0.0f, 1.5f);                                          
        //glRotatef(spinFloat -25, 0.0f, 0.0f, 1.0f);  spinFloat += 0.0;
        glRotatef(90, 1.0, 0.0,0.0);
    
    
    cgGLBindProgram( cgVertexProgram );
	cgGLBindProgram( cgFragmentProgram );
	cgGLEnableProfile( cgVertexProfile );
    cgGLEnableProfile( cgFragmentProfile );

    cgGLEnableTextureParameter( cgEnvironmentMap );
    cgGLSetStateMatrixParameter( cgModelViewProj,	CG_GL_MODELVIEW_PROJECTION_MATRIX,	CG_GL_MATRIX_IDENTITY );
	cgGLSetStateMatrixParameter( cgModelView,		CG_GL_MODELVIEW_MATRIX,				CG_GL_MATRIX_IDENTITY );
	cgGLSetStateMatrixParameter( cgModelViewI,		CG_GL_MODELVIEW_MATRIX,				CG_GL_MATRIX_INVERSE );
	cgGLSetStateMatrixParameter( cgModelViewIT,		CG_GL_MODELVIEW_MATRIX,				CG_GL_MATRIX_INVERSE_TRANSPOSE );

        glInterleavedArrays( GL_T2F_N3F_V3F, 0, MeTooB);                        
        glDrawArrays( GL_TRIANGLES, 0, 7608); 

	cgGLDisableTextureParameter( cgEnvironmentMap );
    cgGLDisableProfile( cgVertexProfile );
    cgGLDisableProfile( cgFragmentProfile );
glPopMatrix();
}
Beispiel #4
0
void board_update()
{
  cgGLEnableProfile(cg__fragmentProfile);
  cgGLBindProgram(cg__fragmentProgram);

  // transfer data to texture
    texture_load_array(board__computeTexture, GL_TEXTURE_RECTANGLE_ARB, board__width, board__width, board__data);

  // perform computation
    CGparameter textureCg = cgGetNamedParameter(cg__fragmentProgram, "aBoard");
    cgGLSetTextureParameter(textureCg, board__computeTexture);
    cgGLEnableTextureParameter(textureCg);

    CGparameter widthCg = cgGetNamedParameter(cg__fragmentProgram, "aWidth");
    cgSetParameter1f(widthCg, board__width);

    board_draw(); // GPGPU CONCEPT 4: Viewport-Sized Quad = Data Stream Generator.

    cgGLDisableTextureParameter(textureCg);
    cgGLDisableProfile(cg__fragmentProfile);

  // Read back the results
    glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
    // The glReadBuffer function selects a color buffer source for pixels.
    // void glReadBuffer(GLenum mode); mode is a color buffer

    // The glReadPixels function reads a block of pixels from the framebuffer.
    glReadPixels(
      0, 0,           // GLint x, y The window coordinates of the first pixel that is read from the framebuffer. This location is the lower-left corner of a rectangular block of pixels
      board__width,   // GLsizei width
      board__width,   // GLsizei height
      GL_RGBA,        // GLenum format
      GL_FLOAT,       // GLenum type
      board__data);   // GLvoid *pixels
}
 //
 // DisableSampler
 //
 void CCgSamplerUniform::DisableSampler() const
 {
     cgGLDisableTextureParameter( m_Parameter );
     /*
 #ifdef _DEBUG
     CGerror Error = cgGetError();
     if (Error != CG_NO_ERROR)
         throw CCgException( this, Error, "::DisableSampler() : A Cg error has occured." );
 #endif
 */
 }
Beispiel #6
0
void GLCgShader::DisableTextures()
{
	for (std::list<CGparameter>::iterator iter = m_enabledTextures.begin(); iter != m_enabledTextures.end(); ++iter)
	{
		cgGLDisableTextureParameter((*iter));
	}
	m_enabledTextures.clear();
	m_video->UnsetTexture(0);
	m_video->UnsetTexture(1);
	m_video->UnsetTexture(2);
	m_video->UnsetTexture(4);
}
Beispiel #7
0
	void	IOGLBaseShader::FreeSampler(const CString& strName){
		auto uParam = this->GetParameter(strName);

		if(this->m_bBinded){
			cgGLDisableTextureParameter(uParam);
		}
		
		uint32 uIndex = 0;
		if(Collection::TryFind(this->m_uSamplerParams, uParam, uIndex)){
			cgGLSetTextureParameter(uParam, 0);
			this->m_uSamplerParams.Remove(uIndex);
			this->m_pSamplerTextures.Remove(uIndex);
		}
	}
Beispiel #8
0
void GLCgShader::DisableIfEnabled(CGparameter param)
{
	for (std::list<CGparameter>::iterator iter = m_enabledTextures.begin(); iter != m_enabledTextures.end();)
	{
		if ((*iter) == param)
		{
			cgGLDisableTextureParameter((*iter));
			iter = m_enabledTextures.erase(iter);
		}
		else
		{
			++iter;
		}
	}
}
void display(void) {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    cgGLBindProgram(cg_vertex_program);
    checkForCgError("binding vertex program");

    cgGLEnableProfile(cg_vertex_profile);
    checkForCgError("enabling vertex profile");
    // parameter

    //cgGLSetParameter1f(cg_parameter_vertex_scale_factor, 0.7);
    //cgGLSetParameter1f(cg_parameter_vertex_rotation, rotation);

    // Zeit die seit dem rendern des letzten Bildes vergangen ist:
    cgGLEnableTextureParameter(cg_parameter_vertex_time);
    t = diff_seconds();
    glVertex2f(0.0f, 0.0f);
    glTexCoord1f(Particle->t);
    cgGLDisableTextureParameter(cg_parameter_vertex_time);
    // Berechnung der Framerate mit Hilfe der Zeitmessungsfunktion:
    frames++;
    timer += t;
    if (timer > 1.0) {
        printf("Frames per second: %i\n", frames);
        timer -= 1.0;
        frames = 0;

        printf("Number of particles: %d\n", water_list.size());
    }
    //cgGLEnableTextureParameter(cg_parameter_vertex_velocity);
    drawParticles(water_list,water_tex);
    //glVertex2f(0.0f, 0.0f);
    //glTexCoord3fv(Particle->velocity);
    //cgGLDisableTextureParameter(cg_parameter_vertex_velocity);



    cgGLDisableProfile(cg_vertex_profile);
    checkForCgError("disabling vertex profile");

    glutSwapBuffers();
}
void  Cg::Disable(void){
	cgGLDisableTextureParameter(vdecalParam);
	cgGLDisableTextureParameter(fdecalParam);
	cgGLDisableProfile(vertexProfile);CheckCgError();
	cgGLDisableProfile(fragmentProfile);CheckCgError();
}
Beispiel #11
0
int Skydome::Render()
{
    cgGLEnableProfile(psSkydomeProfile);
    cgGLBindProgram(psSkydomeProgram);

    cgSetParameter1f(dayTime, mDayTime);
	cgSetParameter1i(transition, stage);

    cgGLEnableTextureParameter(text1);
    cgGLEnableTextureParameter(text2);
	cgGLEnableTextureParameter(text3);

	glPushMatrix();
	//glTranslatef(0.0f, -100.0f, 0.0f);
	glRotatef(rotTheta,0.0f, 1.0f, 0.0f);
	glRotatef(270, 1.0f, 0.0f, 0.0f);

	glEnable(GL_TEXTURE_2D);

	//glBindTexture(GL_TEXTURE_2D, cloudTexture.TextureID);

	glBegin(GL_TRIANGLE_STRIP);

	for (int i=0; i < NumVertices; i++)
	{
		glColor3f(1.0f, 1.0f, 1.0f);

		glTexCoord2f(Vertices[i].u, Vertices[i].v);
		glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z);
	}

	glEnd();

	glPopMatrix();

	cgGLDisableTextureParameter(text1);
	cgGLDisableTextureParameter(text2);
	cgGLDisableTextureParameter(text3);

    cgGLDisableProfile(psSkydomeProfile);

	
	cgGLEnableProfile(psSkydomeSunProfile);
    cgGLBindProgram(psSkydomeSunProgram);

	cgGLEnableTextureParameter(suntext1);
    cgGLEnableTextureParameter(suntext2);

	/*glPushMatrix();
	glRotatef(mSunPhi-90.0, 0.0, 0.0, 1.0);
	//glTranslatef(-mSunPos.GetX(), -mSunPos.GetY(), 0.0);*/

	glPushMatrix();
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glTranslatef(mSunPos.GetX(), mSunPos.GetY(), 0.0);
	//glTranslatef(0.0, 1.0, 0.0);
	glRotatef(60 * mSunPhi + 90.0f, 0, 0, 1.0f);
	glScalef(10.0, 10.0, 10.0);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0, 0.0);
		glVertex3f(-1.0, 0.0, 1.0);
		glTexCoord2f(0.0, 1.0);
		glVertex3f(-1.0, 0.0, -1.0);
		glTexCoord2f(1.0, 1.0);
		glVertex3f(1.0, 0.0, -1.0);
		glTexCoord2f(1.0, 0.0);
		glVertex3f(1.0, 0.0, 1.0);
	glEnd();
	glPopMatrix();

	//glPopMatrix();

	cgGLDisableTextureParameter(suntext1);
	cgGLDisableTextureParameter(suntext2);

	cgGLDisableProfile(psSkydomeSunProfile);
	
    return 1;
}
Beispiel #12
0
	void	IOGLBaseShader::UnbindSamplers(){
		for(uint32 i = 0; i < this->m_uSamplerParams.GetLength(); i++){
			cgGLDisableTextureParameter(this->m_uSamplerParams[i]);
		}
	}
void drawParticles(std::list<Particle> &drawList, GLuint texture)
{

    static float overTime = 0.0;
    int particlesToEmit = particles_per_Second * t + overTime;
    overTime += particles_per_Second * t - particlesToEmit;


    glBindTexture(GL_TEXTURE_2D, texture);
    glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);


    for(std::list<Particle>::iterator it = drawList.begin(); it != drawList.end(); ++it)
    {
        //update and draw particles if alive
        if(it->isAlive)
        {

            it->t += t;
            if(it->t > it->lifeTime)
                it->isAlive = false;


            glPointSize(10.0 * (it->lifeTime - it->t) / it->lifeTime + 0.1);

            glColor4f(1 - (it->lifeTime - it->t) / it->lifeTime,
                      1-(it->lifeTime - it->t) / it->lifeTime
                      ,1.0f, 1.0);
            glBegin(GL_POINTS);

            glVertex3f( it->position[0] + it->t * it->velocity[0],
                        it->position[1] + it->t * it->velocity[1] - 0.5 * 9.81 * it->t * it->t,
                        it->position[2] + it->t * it->velocity[2]);

            glEnd();

        }
        //revive particle if necessary
        else if(particlesToEmit > 0)
        {
            --particlesToEmit;
            it->isAlive = true;
            it->t = 0;
            it->lifeTime = myRand(1.5,2.5);

            it->position[0] = myRand(-0.5,0.5);
            it->position[1] = 0;
            it->position[2] = myRand(-0.5,0.5);

            it->velocity[0] = myRand(-2, 2);
            it->velocity[1] = myRand(5.0,10.0);
            it->velocity[2] = myRand(-2, 2);

            cgGLEnableTextureParameter(cg_parameter_vertex_velocity);
            glVertex2f(0.0f, 0.0f);
            glTexCoord3fv(it->velocity);
            cgGLDisableTextureParameter(cg_parameter_vertex_velocity);

        }
    }
    //create new particles if necessary
    for(int i = 0; i < particlesToEmit; ++i)
    {
        Particle neu;

        neu.isAlive = true;
        neu.t = 0;
        neu.lifeTime = myRand(1.5,2.5);

        neu.position[0] = myRand(-0.5,0.5);
        neu.position[1] = 0;
        neu.position[2] = myRand(-0.5, 0.5);

        neu.velocity[0] = myRand(-2, 2);
        neu.velocity[1] = myRand(5.0,10.0);
        neu.velocity[2] = myRand(-2, 2);

        cgGLEnableTextureParameter(cg_parameter_vertex_velocity);
        glVertex2f(0.0f, 0.0f);
        glTexCoord3fv(neu->velocity);
        cgGLDisableTextureParameter(cg_parameter_vertex_velocity);

        water_list.push_back(neu);
    }

}
void ParticleShaderVoronoi::drawPost()
{

	// Get the viewport dimensions
	GLint viewport[4];
	glGetIntegerv(GL_VIEWPORT, viewport);

	if ((pbufferOne->height != viewport[3]) || (pbufferOne->width != viewport[2]))
	{
		delete pbufferOne;
		setupBuffers(viewport[2], viewport[3]);
	}

	// Get the light position
	GLfloat lightpos[4];
	glGetLightfv(GL_LIGHT0, GL_POSITION, lightpos);

	// Create storage for matrices
	GLfloat mm[16];
	GLfloat pm[16];

	// If we're not sharing contexts, need to copy state
	glGetFloatv(GL_MODELVIEW_MATRIX, mm);
	glGetFloatv(GL_PROJECTION_MATRIX, pm);

	// Switch to pbufferOne rendering context
	if (wglMakeCurrent(pbufferOne->hdc, pbufferOne->hglrc) == FALSE)
		pbufferOne->wglGetLastError();

	// If we're not sharing contexts, need to update state
	if (pbufferOne->onecontext == false) {

		glMatrixMode(GL_PROJECTION);
		glLoadMatrixf(pm);
	
		glMatrixMode(GL_MODELVIEW);
		glLoadMatrixf(mm);

		glEnable(GL_DEPTH_TEST);
	}
	else {
		// Turn off color writes, for better performance
		glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
	}

	// Clear the depth texture
	glClear(GL_DEPTH_BUFFER_BIT);

	cgGLEnableProfile(vProfile);
	cgGLEnableProfile(fProfile);
	cgGLBindProgram(vProgram);
	bindCGParametersVertex();
	cgGLBindProgram(fProgramZero);
	bindCGParametersFragmentZero();
	

	// Draw into the buffer for the depth texture
	for (unsigned int i = 0; i < ps->size(); i++)
		drawParticle(i);

	// Turn back on color for eventual rendering
	if (pbufferOne->onecontext) {
		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	}

	cgGLDisableProfile(vProfile);
    cgGLDisableProfile(fProfile);

	// Switch to normal rendering context
	if (wglMakeCurrent(hdc, hglrc) == FALSE)
		pbufferOne->wglGetLastError();
	
	// Setup CG
	cgGLEnableProfile(vProfile);
	cgGLEnableProfile(fProfile);
	cgGLBindProgram(vProgram);
	bindCGParametersVertex();
	bindCGParametersFragmentOne();
	cgGLBindProgram(fProgramOne);
	
	// Make the depth texture active
	glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
	glActiveTextureARB(GL_TEXTURE0_ARB);
	
	// Bind the depth texture
	glEnable(GL_TEXTURE_RECTANGLE_NV);
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glBindTexture(GL_TEXTURE_RECTANGLE_NV, depth_texture);
	
	// Bind pbufferOne as a depth texture
	wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB");
	if (wglBindTexImageARB(pbufferOne->hpbuffer, WGL_DEPTH_COMPONENT_NV) == FALSE)
		pbufferOne->wglGetLastError();

	cgGLEnableTextureParameter(firstPassDepth);
	
	glActiveTextureARB(GL_TEXTURE1_ARB);
	
	// Set parameters
	cgGLSetParameter1f(depthRange, GLfloat(abs(10.0 - 0.5)));
	cgGLSetParameter4fv(lightPositionEC, lightpos);
	cgGLSetParameter1f(toleranceScaleFactor, GLfloat(toleranceScale));
	cgGLSetStateMatrixParameter(viewMatrix, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);

	glEnable(GL_DEPTH_TEST);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

	// Draw the particles to the screen
	for (unsigned int i = 0; i < ps->size(); i++) {
		drawSecondPass(i);
	}

	cgGLDisableTextureParameter(firstPassDepth);
	
	glDisable(GL_TEXTURE_RECTANGLE_NV);

	// Release the depth texture
	wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
	if (wglReleaseTexImageARB(pbufferOne->hpbuffer, WGL_DEPTH_COMPONENT_NV) == false)
		pbufferOne->wglGetLastError();

	cgGLDisableProfile(vProfile);
    cgGLDisableProfile(fProfile);
}
Beispiel #15
0
void CGDisableTextureParameterAmbientReflectiveSea()
{
	cgGLDisableTextureParameter( g_CGparam_AmbientReflectiveSea );
}