<div dir="ltr">Hi Brian,<div><br></div><div>I added glFlush and glFinish still no luck with that.</div><div>Am I doing something wrong in the shader code ?</div><div>The same code works fine with the openGL libraries using freeglut and glew.</div><div><br></div><div><br></div><div>Thanks & Regards,</div><div>Vikram</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 24, 2016 at 7:15 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03/24/2016 12:45 AM, vikramnrao wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Its been quite sometime that I am looking into Off screen rendering<br>
using Mesa 11.1.2. :)<br>
<br>
I was able to render the textured model using Mesa 7.5.1 but somehow I<br>
couldn't manage lighting the scene there.<br>
<br>
However I want my code to run using Mesa 11.1.2.<br>
I am not able to see anything in the off-screen rendered targa image.<br>
It just appears blank.<br>
<br>
What is wrong in the following code ?<br>
<br>
</blockquote></span>
[...]<span class=""><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
glGetError();<br>
// Draw the triangle !<br>
glDrawArrays(GL_TRIANGLES, 0, indexed_vertex_data.size());<br>
</blockquote>
<br></span>
Try putting a glFlush() or glFinish() call here.<span class="HOEnZb"><font color="#888888"><br>
<br>
-Brian</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
SaveScreenGrab("mesa_snapshot.tga");<br>
<br>
<br>
glDisableVertexAttribArray(vertexPosition_modelspaceID);<br>
<br>
// Cleanup VBO<br>
glDeleteBuffers(1, &vertexbuffer);<br>
glDeleteBuffers(1, &normalbuffer);<br>
glDeleteBuffers(1, &uvbuffer);<br>
glDeleteTextures(1, &diffuseMap);<br>
glDeleteProgram(programID);<br>
<br>
}<br>
<br>
*************************<br>
Shader code<br>
*************************<br>
--------------------<br>
vertex shader:<br>
---------------------<br>
<br>
attribute vec3 vertexPosition_modelspace;<br>
attribute vec2 vertexUV;<br>
attribute vec3 normalv;<br>
<br>
varying vec2 TexCoords;<br>
varying vec3 normalf;<br>
varying vec3 FragPos;<br>
<br>
uniform mat4 MVP;<br>
uniform mat4 Model;<br>
<br>
<br>
void main() {<br>
<br>
gl_Position = MVP * vec4(vertexPosition_modelspace,1);<br>
FragPos = vec3(Model * vec4(vertexPosition_modelspace,1));<br>
normalf = vec3(Model * vec4(normalv,1));<br>
TexCoords = vertexUV;<br>
<br>
}<br>
<br>
<br>
------------------------<br>
Fragment shader:<br>
-------------------------<br>
#version 120<br>
<br>
struct Material{<br>
vec4 ambient;<br>
vec4 diffuse;<br>
vec4 specular;<br>
float shininess;<br>
};<br>
<br>
struct DirLight {<br>
vec3 direction;<br>
vec3 ambient;<br>
vec3 diffuse;<br>
vec3 specular;<br>
};<br>
<br>
<br>
in vec3 FragPos;<br>
in vec3 normalf;<br>
in vec2 TexCoords;<br>
in vec3 vertexColor;<br>
vec4 texel0;<br>
<br>
uniform sampler2D MeshTexture;<br>
uniform DirLight dirLight;<br>
out vec4 ResultFragColor;<br>
uniform vec3 viewPos;<br>
uniform Material material;<br>
uniform float matAlpha;<br>
<br>
//Function prototype<br>
vec4 SurfaceColor (in Material mat, in vec4 texel);<br>
<br>
void main()<br>
{<br>
<br>
texel0 = texture2D(MeshTexture, TexCoords);<br>
<br>
vec3 norm = normalize(normalf);<br>
vec3 viewDir = normalize(viewPos - FragPos);<br>
vec3 lightDir = normalize(-dirLight.direction);<br>
<br>
// Diffuse shading<br>
float diff = max(dot(norm, lightDir), 0.0);<br>
<br>
// Specular shading<br>
vec3 reflectDir = reflect(-lightDir, norm);<br>
float spec = pow(max(dot(viewDir, reflectDir), 0.0),<br>
material.shininess);<br>
<br>
vec4 surfaceColorValue ;<br>
surfaceColorValue = mix(material.diffuse, texel0, texel0.a);<br>
surfaceColorValue.a = min(matAlpha*( 1 + texel0.a) , 1);<br>
<br>
vec4 ambient = vec4(dirLight.ambient, 1) * surfaceColorValue ;<br>
vec4 diffuse = vec4(dirLight.diffuse, 1) * diff * surfaceColorValue ;<br>
vec4 specular = vec4(dirLight.specular, 1) * spec * material.specular ;<br>
<br>
vec4 result = ambient + diffuse + specular ;<br>
<br>
ResultFragColor = result;<br>
<br>
}<br>
<br>
vec4 SurfaceColor (in Material mat, in vec4 texel)<br>
{<br>
vec4 SurfColor;<br>
<br>
SurfColor = mix(mat.diffuse, texel, texel.a);<br>
SurfColor.a = min(matAlpha*( 1 + texel.a) , 1);<br>
return SurfColor;<br>
}<br>
<br>
}<br>
<br>
<br>
<br>
<br>
Thanks & Regards,<br>
Vikram<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>