-2

I want to render two textures on the screen at the same time at different positions, but, I'm confused about the vertex coordinates.

How could I write a vertex shader to meet my goal?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • it's easier to do with the viewport – ratchet freak Oct 27 '14 at 10:30
  • 1
    happygygt: your question is both unclear and vague. I'd suggest you to explain a little better what you are trying to achieve, and state especially what *exactly* your problem is. As it is, the better answer to your question "How could I write a vertex shader to meet my goal?" that comes to my mind is: "read a book about OpenGL/GLSL". Keep in mind that if you don't take time to kind toward the people on this site by being clear and specific, there is no reason for them to spend some of their time for you... – Rick77 Oct 27 '14 at 10:40

1 Answers1

1

Just to address the "two images to the screen separately" bit...

A texture maps image colours onto geometry. To be pedantic, you can't draw a texture but you can blit and you can draw geometry with a mapped texture (using per-vertex texture coordinates).

You can bind two textures at once while drawing, but you'll need both a second set of texture coordinates and to handle how they blend (or don't in your case). Even then the shader will be quite specific and because the images are separate there'll be unnecessary code running for each pixel to handle the other image. What happens when you want to draw 3 images, or 100?

Instead, just draw a quad with one image twice (binding each texture in turn before drawing). The overhead will be tiny unless you're drawing lots, at which point you might look at texture atlases and drawing all the geometry with one draw call (really getting towards the "at the same time" part of the question).

Community
  • 1
  • 1
jozxyqk
  • 16,424
  • 12
  • 91
  • 180