OpenGL: Render skybox cubmap issue












0















I am creating a Sky box with a cube map so I used this site to generate the sides of the cube map Sky box generator, now I have 6 512 png files, I used the following code to render it:



glGenTextures(1, &cubemapTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
for (GLuint i = 0; i < images.size(); i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGB, GL_UNSIGNED_BYTE, images[i].data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);


the code was working fine with different images but those images that are downloaded from this site give me the following result



enter image description here



this is a sample of the image used not working:



Sample tha is not working



this is a sample of the worked images:



enter image description here










share|improve this question























  • Have you tried GL_RGBA ?

    – VuVirt
    Nov 14 '18 at 14:59











  • I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

    – Mohamed Moussa
    Nov 14 '18 at 15:03






  • 1





    Both should be GL_RGBA

    – VuVirt
    Nov 14 '18 at 15:16






  • 1





    It worked, thank you. could you post it as Answer?

    – Mohamed Moussa
    Nov 14 '18 at 15:44
















0















I am creating a Sky box with a cube map so I used this site to generate the sides of the cube map Sky box generator, now I have 6 512 png files, I used the following code to render it:



glGenTextures(1, &cubemapTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
for (GLuint i = 0; i < images.size(); i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGB, GL_UNSIGNED_BYTE, images[i].data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);


the code was working fine with different images but those images that are downloaded from this site give me the following result



enter image description here



this is a sample of the image used not working:



Sample tha is not working



this is a sample of the worked images:



enter image description here










share|improve this question























  • Have you tried GL_RGBA ?

    – VuVirt
    Nov 14 '18 at 14:59











  • I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

    – Mohamed Moussa
    Nov 14 '18 at 15:03






  • 1





    Both should be GL_RGBA

    – VuVirt
    Nov 14 '18 at 15:16






  • 1





    It worked, thank you. could you post it as Answer?

    – Mohamed Moussa
    Nov 14 '18 at 15:44














0












0








0








I am creating a Sky box with a cube map so I used this site to generate the sides of the cube map Sky box generator, now I have 6 512 png files, I used the following code to render it:



glGenTextures(1, &cubemapTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
for (GLuint i = 0; i < images.size(); i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGB, GL_UNSIGNED_BYTE, images[i].data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);


the code was working fine with different images but those images that are downloaded from this site give me the following result



enter image description here



this is a sample of the image used not working:



Sample tha is not working



this is a sample of the worked images:



enter image description here










share|improve this question














I am creating a Sky box with a cube map so I used this site to generate the sides of the cube map Sky box generator, now I have 6 512 png files, I used the following code to render it:



glGenTextures(1, &cubemapTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
for (GLuint i = 0; i < images.size(); i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGB, GL_UNSIGNED_BYTE, images[i].data);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);


the code was working fine with different images but those images that are downloaded from this site give me the following result



enter image description here



this is a sample of the image used not working:



Sample tha is not working



this is a sample of the worked images:



enter image description here







c++ opengl textures skybox






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 14:29









Mohamed MoussaMohamed Moussa

378




378













  • Have you tried GL_RGBA ?

    – VuVirt
    Nov 14 '18 at 14:59











  • I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

    – Mohamed Moussa
    Nov 14 '18 at 15:03






  • 1





    Both should be GL_RGBA

    – VuVirt
    Nov 14 '18 at 15:16






  • 1





    It worked, thank you. could you post it as Answer?

    – Mohamed Moussa
    Nov 14 '18 at 15:44



















  • Have you tried GL_RGBA ?

    – VuVirt
    Nov 14 '18 at 14:59











  • I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

    – Mohamed Moussa
    Nov 14 '18 at 15:03






  • 1





    Both should be GL_RGBA

    – VuVirt
    Nov 14 '18 at 15:16






  • 1





    It worked, thank you. could you post it as Answer?

    – Mohamed Moussa
    Nov 14 '18 at 15:44

















Have you tried GL_RGBA ?

– VuVirt
Nov 14 '18 at 14:59





Have you tried GL_RGBA ?

– VuVirt
Nov 14 '18 at 14:59













I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

– Mohamed Moussa
Nov 14 '18 at 15:03





I tried it glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data); the texture became black.

– Mohamed Moussa
Nov 14 '18 at 15:03




1




1





Both should be GL_RGBA

– VuVirt
Nov 14 '18 at 15:16





Both should be GL_RGBA

– VuVirt
Nov 14 '18 at 15:16




1




1





It worked, thank you. could you post it as Answer?

– Mohamed Moussa
Nov 14 '18 at 15:44





It worked, thank you. could you post it as Answer?

– Mohamed Moussa
Nov 14 '18 at 15:44












1 Answer
1






active

oldest

votes


















1














It seems that PNG files contain alpha channel, so you should use GL_RGBA in your glTexImage2D call like this:



glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data);





share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302550%2fopengl-render-skybox-cubmap-issue%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    It seems that PNG files contain alpha channel, so you should use GL_RGBA in your glTexImage2D call like this:



    glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data);





    share|improve this answer




























      1














      It seems that PNG files contain alpha channel, so you should use GL_RGBA in your glTexImage2D call like this:



      glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data);





      share|improve this answer


























        1












        1








        1







        It seems that PNG files contain alpha channel, so you should use GL_RGBA in your glTexImage2D call like this:



        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data);





        share|improve this answer













        It seems that PNG files contain alpha channel, so you should use GL_RGBA in your glTexImage2D call like this:



        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA, images[i].width, images[i].height, 0, GL_RGBA , GL_UNSIGNED_BYTE, images[i].data);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 16:04









        VuVirtVuVirt

        1,389711




        1,389711
































            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302550%2fopengl-render-skybox-cubmap-issue%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python