Sign in to follow this  
winsoft2003

OpenGL Some transformation Between Direct3D and OPENGL.

Recommended Posts

HI,I am referencing a terrain example written by OPENGL.The following is some fragment of code... ...................... glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_txt.GetTxtID()); //Activate the second texture ID and bind the fog texture to it glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); //Here we turn on the COMBINE properties and increase our RGB //gamma for the detail texture. 2 seems to work just right. glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); //Bind the detail texture glBindTexture(GL_TEXTURE_2D, m_cTxtDetail.GetTxtID()); # I know these code set the terrain texture,but I don't know which Direct3d interface could realize the following effect? " glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); " who can tell me? ============================================== The following is about texture coordinate transformation, which is written by OPENGL. //Now we want to enter the texture matrix. This will allow us //to change the tiling of the detail texture. glMatrixMode(GL_TEXTURE); //Reset the current matrix and apply our chosen scale value glLoadIdentity(); glScalef((float)32, (float)32, 32); I rewrote in Direct3D,Is it right?It does not work. // D3DXMATRIX matTexture; D3DXMatrixIdentity( &matTexture ); matTexture._11 = 32.0f; matTexture._22 = 32.0f; matTexture._33 = 32.0f; pD3DDevice->SetTransform( D3DTS_TEXTURE0, &matTexture ); Thanks!

Share this post


Link to post
Share on other sites
1) The texel value scaling would by achieved by passing the D3DTOP_MODULATE2X as an argument to SetTextureStageState.

2) There is a convenience function for this, google for D3DXMatrixScaling. Also, you realise you have to actually multiply your transformation matrices with this scaling matrix, and then set it through D3DDevice->SetTransform, right?

Share this post


Link to post
Share on other sites

Thank Pauljan!
I just want to expand the texture coordinate,I wrote the following code:

D3DXMATRIX matTexture;
D3DXMatrixIdentity( &matTexture );
D3DXMatrixScaling( &matTexture, 32.0f, 32.0f, 32.0f );
pD3DDevice->SetTransform( D3DTS_TEXTURE0, &matTexture );

But it still doesn't work.Should I pay attention to the calling position of these function? I Call these function, then DrawPrimitiveUp( ).Is there any problem?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this