Names of vectors in diffrent fragment and vertex shader files












0














I'm trying to make 2 objects in OpenGL with 2 diffrent textures and one of them should moving.



I make 2 shader program and sign it to diffrent indicates tabs. Parameters of shader programs looking but program draws only one obejct (which I use later). Is it correctly if I make .frag and .vert file same structure and name of in/out vectors but change only texture and delete transformation from static object?



//fragment of moving object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;


out vec3 vecColor;
out vec2 TexCoord;


uniform mat4 transform;
uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view* transform * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}

// fragment of static object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 vecColor;
out vec2 TexCoord;

uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}
// code of Use()
void Use() const
{
glUseProgram(get_programID());
}

// Drawing elements in main event loop whiile()
// Draw first object
theProgram_stelaz.Use();
glBindVertexArray(VAO_stelaz);
glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);
// Draw second object
theProgram.Use();
glBindVertexArray(VAO_wings);
glDrawElements(GL_TRIANGLES, _countof(indices_wings), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);


Now program draws only secon object from indices_wings. I want to draw two elements and just object from indices_wings should move.










share|improve this question







New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    "I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
    – Rabbid76
    2 days ago












  • I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
    – Fijal
    2 days ago










  • How are you signing the shader programs?
    – genpfault
    2 days ago










  • @genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
    – Fijal
    yesterday


















0














I'm trying to make 2 objects in OpenGL with 2 diffrent textures and one of them should moving.



I make 2 shader program and sign it to diffrent indicates tabs. Parameters of shader programs looking but program draws only one obejct (which I use later). Is it correctly if I make .frag and .vert file same structure and name of in/out vectors but change only texture and delete transformation from static object?



//fragment of moving object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;


out vec3 vecColor;
out vec2 TexCoord;


uniform mat4 transform;
uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view* transform * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}

// fragment of static object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 vecColor;
out vec2 TexCoord;

uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}
// code of Use()
void Use() const
{
glUseProgram(get_programID());
}

// Drawing elements in main event loop whiile()
// Draw first object
theProgram_stelaz.Use();
glBindVertexArray(VAO_stelaz);
glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);
// Draw second object
theProgram.Use();
glBindVertexArray(VAO_wings);
glDrawElements(GL_TRIANGLES, _countof(indices_wings), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);


Now program draws only secon object from indices_wings. I want to draw two elements and just object from indices_wings should move.










share|improve this question







New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    "I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
    – Rabbid76
    2 days ago












  • I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
    – Fijal
    2 days ago










  • How are you signing the shader programs?
    – genpfault
    2 days ago










  • @genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
    – Fijal
    yesterday
















0












0








0







I'm trying to make 2 objects in OpenGL with 2 diffrent textures and one of them should moving.



I make 2 shader program and sign it to diffrent indicates tabs. Parameters of shader programs looking but program draws only one obejct (which I use later). Is it correctly if I make .frag and .vert file same structure and name of in/out vectors but change only texture and delete transformation from static object?



//fragment of moving object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;


out vec3 vecColor;
out vec2 TexCoord;


uniform mat4 transform;
uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view* transform * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}

// fragment of static object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 vecColor;
out vec2 TexCoord;

uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}
// code of Use()
void Use() const
{
glUseProgram(get_programID());
}

// Drawing elements in main event loop whiile()
// Draw first object
theProgram_stelaz.Use();
glBindVertexArray(VAO_stelaz);
glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);
// Draw second object
theProgram.Use();
glBindVertexArray(VAO_wings);
glDrawElements(GL_TRIANGLES, _countof(indices_wings), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);


Now program draws only secon object from indices_wings. I want to draw two elements and just object from indices_wings should move.










share|improve this question







New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm trying to make 2 objects in OpenGL with 2 diffrent textures and one of them should moving.



I make 2 shader program and sign it to diffrent indicates tabs. Parameters of shader programs looking but program draws only one obejct (which I use later). Is it correctly if I make .frag and .vert file same structure and name of in/out vectors but change only texture and delete transformation from static object?



//fragment of moving object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;


out vec3 vecColor;
out vec2 TexCoord;


uniform mat4 transform;
uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view* transform * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}

// fragment of static object
#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
layout (location = 2) in vec2 texCoord;

out vec3 vecColor;
out vec2 TexCoord;

uniform mat4 view;
uniform mat4 projection;

void main()
{
gl_Position = projection*view * vec4(position, 1.0f);
vecColor = color;
TexCoord = texCoord;
}
// code of Use()
void Use() const
{
glUseProgram(get_programID());
}

// Drawing elements in main event loop whiile()
// Draw first object
theProgram_stelaz.Use();
glBindVertexArray(VAO_stelaz);
glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);
// Draw second object
theProgram.Use();
glBindVertexArray(VAO_wings);
glDrawElements(GL_TRIANGLES, _countof(indices_wings), GL_UNSIGNED_INT,
0);
glBindVertexArray(0);


Now program draws only secon object from indices_wings. I want to draw two elements and just object from indices_wings should move.







opengl shader fragment-shader vertex-shader






share|improve this question







New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Fijal

1




1




New contributor




Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Fijal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    "I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
    – Rabbid76
    2 days ago












  • I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
    – Fijal
    2 days ago










  • How are you signing the shader programs?
    – genpfault
    2 days ago










  • @genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
    – Fijal
    yesterday
















  • 1




    "I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
    – Rabbid76
    2 days ago












  • I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
    – Fijal
    2 days ago










  • How are you signing the shader programs?
    – genpfault
    2 days ago










  • @genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
    – Fijal
    yesterday










1




1




"I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
– Rabbid76
2 days ago






"I make 2 shader program ..." - Why is it not possible to draw both object with the same shader program? If the textures are different then it is sufficient to bind the proper texture before drawing the mesh. Note in one case the transform matrix can be set the identity matrix. It is very very expensive to change the shader program, but it is common to use a model (transform) matrix.
– Rabbid76
2 days ago














I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
– Fijal
2 days ago




I should bind proper texture and change matrix transform to identity in while loop after drawind first object? (I will be grateful for any example how change it)
– Fijal
2 days ago












How are you signing the shader programs?
– genpfault
2 days ago




How are you signing the shader programs?
– genpfault
2 days ago












@genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
– Fijal
yesterday






@genpfault , sign to indices tab? I create new VAO and sign like this glBindVertexArray(VAO_stelaz); glDrawElements(GL_TRIANGLES, _countof(indices_stelaz), GL_UNSIGNED_INT, 0);
– Fijal
yesterday



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Fijal is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945368%2fnames-of-vectors-in-diffrent-fragment-and-vertex-shader-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Fijal is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Fijal is a new contributor. Be nice, and check out our Code of Conduct.













Fijal is a new contributor. Be nice, and check out our Code of Conduct.












Fijal is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945368%2fnames-of-vectors-in-diffrent-fragment-and-vertex-shader-files%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas