Re: Blank screen with Mesa_offscreen render 11.1.2

vikramnrao <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <CAK3wyPe61NGODAbk6ATpJMJcC6kmZqnsSzbnqUugJhwRKOnz8A@mail.gmail.com>
Hi Brian,

I managed to get it work with Mesa 7.5.1. Since there was an urgent
requirement for off-screen rendering I am using this.
However I have tried by clearing the screen to blue color which is working
fine.The problem should be else where. Will look into it and update.


Thanks &  Regards,
Vikram

On Sun, Apr 3, 2016 at 1:56 AM, Brian Paul <[email protected]> wrote:

> I guess I'd start by trimming down the program, or writing a new test
> case, that does something extremely simple, like clearing the surface to
> non-black and see if that works.
>
> -Brian
>
> On 03/25/2016 02:16 AM, vikramnrao wrote:
>
>> Hi Brian,
>>
>> I added glFlush and glFinish still no luck with that.
>> Am I doing something wrong in the shader code ?
>> The same code works fine with the openGL libraries using freeglut and
>> glew.
>>
>>
>> Thanks & Regards,
>> Vikram
>>
>> On Thu, Mar 24, 2016 at 7:15 PM, Brian Paul <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>     On 03/24/2016 12:45 AM, vikramnrao wrote:
>>
>>         Hi,
>>
>>         Its been quite sometime that I am looking into Off screen
>> rendering
>>         using Mesa 11.1.2. :)
>>
>>         I was able to render the textured model using Mesa 7.5.1 but
>>         somehow I
>>         couldn't manage lighting the scene there.
>>
>>         However I want my code to run using Mesa 11.1.2.
>>         I am not able to see anything in the off-screen rendered targa
>>         image.
>>         It just appears blank.
>>
>>         What is wrong in the following code ?
>>
>>     [...]
>>
>>
>>
>>
>>         glGetError();
>>         // Draw the triangle !
>>         glDrawArrays(GL_TRIANGLES, 0, indexed_vertex_data.size());
>>
>>
>>     Try putting a glFlush() or glFinish() call here.
>>
>>     -Brian
>>
>>
>>
>>
>>         SaveScreenGrab("mesa_snapshot.tga");
>>
>>
>>         glDisableVertexAttribArray(vertexPosition_modelspaceID);
>>
>>         // Cleanup VBO
>>         glDeleteBuffers(1, &vertexbuffer);
>>         glDeleteBuffers(1, &normalbuffer);
>>         glDeleteBuffers(1, &uvbuffer);
>>         glDeleteTextures(1, &diffuseMap);
>>         glDeleteProgram(programID);
>>
>>         }
>>
>>         *************************
>>         Shader code
>>         *************************
>>         --------------------
>>         vertex shader:
>>         ---------------------
>>
>>            attribute vec3 vertexPosition_modelspace;
>>            attribute vec2 vertexUV;
>>            attribute vec3 normalv;
>>
>>            varying vec2 TexCoords;
>>            varying vec3 normalf;
>>            varying vec3 FragPos;
>>
>>            uniform mat4 MVP;
>>            uniform mat4 Model;
>>
>>
>>            void main() {
>>
>>         gl_Position = MVP * vec4(vertexPosition_modelspace,1);
>>               FragPos = vec3(Model * vec4(vertexPosition_modelspace,1));
>>               normalf = vec3(Model * vec4(normalv,1));
>>               TexCoords = vertexUV;
>>
>>            }
>>
>>
>>         ------------------------
>>         Fragment shader:
>>         -------------------------
>>            #version 120
>>
>>         struct Material{
>>               vec4 ambient;
>>               vec4 diffuse;
>>               vec4 specular;
>>               float shininess;
>>         };
>>
>>         struct DirLight {
>>               vec3 direction;
>>               vec3 ambient;
>>               vec3 diffuse;
>>               vec3 specular;
>>         };
>>
>>
>>         in vec3 FragPos;
>>         in vec3 normalf;
>>         in vec2 TexCoords;
>>         in vec3 vertexColor;
>>         vec4 texel0;
>>
>>         uniform sampler2D MeshTexture;
>>         uniform DirLight dirLight;
>>         out vec4 ResultFragColor;
>>         uniform vec3 viewPos;
>>         uniform Material material;
>>         uniform float matAlpha;
>>
>>         //Function prototype
>>         vec4 SurfaceColor (in Material mat, in vec4 texel);
>>
>>         void main()
>>         {
>>
>>                texel0 = texture2D(MeshTexture, TexCoords);
>>
>>               vec3 norm = normalize(normalf);
>>         vec3 viewDir = normalize(viewPos - FragPos);
>>         vec3 lightDir = normalize(-dirLight.direction);
>>
>>               // Diffuse shading
>>               float diff = max(dot(norm, lightDir), 0.0);
>>
>>               // Specular shading
>>               vec3 reflectDir = reflect(-lightDir, norm);
>>               float spec = pow(max(dot(viewDir, reflectDir), 0.0),
>>         material.shininess);
>>
>>         vec4 surfaceColorValue ;
>>         surfaceColorValue = mix(material.diffuse, texel0, texel0.a);
>>         surfaceColorValue.a =  min(matAlpha*( 1 + texel0.a) , 1);
>>
>>         vec4 ambient = vec4(dirLight.ambient, 1)  * surfaceColorValue ;
>>         vec4 diffuse = vec4(dirLight.diffuse, 1) * diff *
>>         surfaceColorValue ;
>>         vec4 specular = vec4(dirLight.specular, 1)  * spec  *
>>         material.specular ;
>>
>>         vec4 result = ambient + diffuse + specular ;
>>
>>         ResultFragColor = result;
>>
>>         }
>>
>>         vec4 SurfaceColor (in Material mat, in vec4 texel)
>>         {
>>            vec4 SurfColor;
>>
>>            SurfColor = mix(mat.diffuse, texel, texel.a);
>>            SurfColor.a =  min(matAlpha*( 1 + texel.a) , 1);
>>            return SurfColor;
>>         }
>>
>>         }
>>
>>
>>
>>
>>         Thanks & Regards,
>>         Vikram
>>
>>
>>
>>
>

_______________________________________________
mesa-users mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.