Jump to content
  • Advertisement
Sign in to follow this  
xDS4Lx

Texture problem

This topic is 3217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i started trying to learn how to render not using immediate mode, switched all my drawing to use indexed vertex arrays and all the geometry renders, i then tried texturing and wow it doesnt work. Here is a small example:
        m_cverts[0] = Vertex3(0, 0, 0);
	m_cverts[1] = Vertex3(1, 0, 1);
	m_cverts[2] = Vertex3(1, 0, 0);
	m_cverts[3] = Vertex3(0, 0, 1);
	m_cverts[4] = Vertex3(1, 0, 2);
	m_cverts[5] = Vertex3(0, 0, 2);


        float* m_uv = new float[12];
	
	m_uv[0] = 0.0f;
	m_uv[1] = 0.0f;

	m_uv[2] = 1.0f;
	m_uv[3] = 1.0f;

	m_uv[4] = 1.0f;
	m_uv[5] = 0.0f;

	m_uv[6] = 0.0f;
	m_uv[7] = 1.0f;

	m_uv[8] = 1.0f;
	m_uv[9] = 1.0f;

	m_uv[10] = 0.0f;
	m_uv[11] = 1.0f;
        ....
        ....

        GLuint indicies[] = {0, 1, 2,
			     0, 3, 1,
			     3, 4, 1,
			     3, 5, 4};

	glDrawElements(GL_TRIANGLES, 12, GL_UNSIGNED_INT, indicies);




[Edit] I didnt move the triangles to the center because you dont see the "texture" running down the middle when you move the camera. As you can see the texture is not mapped correctly to the second set of triangles. Can someone please help.

Share this post


Link to post
Share on other sites
Advertisement
your code:

m_uv[6] = 0.0f;
m_uv[7] = 1.0f;

m_uv[8] = 1.0f;
m_uv[9] = 1.0f;

m_uv[10] = 0.0f; // same as 6??
m_uv[11] = 1.0f; // same as 7??

Share this post


Link to post
Share on other sites
I think we're going to need a little more information before we can help you out.

Can you show us the code that binds the vertex pointers and texture coordinate pointers before calling glDrawElements?

Also, I'm really not sure what I'm supposed to be seeing in your screen shot. Where is the second set of triangles supposed to be? Are you trying to draw the same geometry twice, in different locations?

[EDIT] - ah, good catch szecs

Share this post


Link to post
Share on other sites
Yeah the triangles are drawn as such

(0)--(2)
|\ |
| \ |
| \ |
(3)--(1)
|\ |
| \ |
| \ |
(5)--(4)


So wouldn't (5) need the same texture coords as 3, i am not trying to map the texture across all the verts I want the texture to start over on every "quad".

Share this post


Link to post
Share on other sites
I switched the tex coords for the last two verts to:


m_uv[8] = 1.0f;
m_uv[9] = 2.0f;

m_uv[10] = 0.0f;
m_uv[11] = 2.0f;



And now the texture tiles how i wanted it, is that correct?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!