Jump to content
  • Advertisement

OpenGL Loading texture from dds file

Recommended Posts

Hello everyone!

I'm trying to complete OpenGL tutorial http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/

And I faced a problem when loading texture from dds file to my triangle. Here is my code (basically from the tutorial):

Load DDS from file(Texture.cpp): https://pastebin.com/Y5TKPvue

Vertex shader: https://pastebin.com/2pPXQkS9

Fragment shader: https://pastebin.com/4nF2jVMy

dds file: https://drive.google.com/open?id=1yYF2oyLbqn-OMB_QxZKyzKwBwxl_9sCb

rendered window: https://imgur.com/a/1pP92

In main file I call drawing triangle, I call texture.Bind();

Also I tried to manually set uv points in fragment shader, and it seems working(color might be changed based on coordinates). 


If you have any idea, will be really appreciated.



Share this post

Link to post
Share on other sites

Ok, I got an idea. It seems something wrong with uv coordinates.

Because, when I changed one row in vertex shader to 

UV = vertexPosition_modelspace.xy;

I got ugly stretched texture on my triangle.

Maybe I filled buffer in a wrong way.

Share this post

Link to post
Share on other sites

The problem was I created in a separate file another buffer and vertex array object. Here in texture I haven't created such object.

So I need to move this code to the place where vertex array object is bound.

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

  • 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!