# Point Sprites

**URL:** <https://forums.imgtec.com/t/point-sprites/926>\
**Category:** PowerVR Insider\
**Created:** [November 25, 2010, 8:54am UTC](https://forums.imgtec.com/t/point-sprites/926 "2010-11-25T08:54:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvalea](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/alvalea/32/81_2.png) [@alvalea](https://forums.imgtec.com/u/alvalea)\
**Post date:** [November 25, 2010, 8:54am UTC](https://forums.imgtec.com/t/point-sprites/926/1 "2010-11-25T08:54:05Z")

</div>

Hi,  
  
  
  
  
  
I’m trying to do a particles system with point sprites. But I’ve got an error in the windows emulator  
  
  
when I use the gl\_PointCoord variable. The output is:  
  
  
  
  
  
"Fragment shaders uses varying gl\_TexCoord but vertex shader does not write to it."  
  
  
  
  
  
The source code of my shaders is the following:  
  
  
  
  
  
[vertex shader]  
  
  
attribute highp&nbsp;&nbsp;&nbsp;vec4 inVertex;  
  
  
  
  
  
uniform mediump mat4 MVPMatrix;  
  
  
  
  
  
void main()  
  
  
{  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gl\_PointSize = 200.0;  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gl\_Position = MVPMatrix \* inVertex;  
  
  
}  
  
  
  
  
  
  
  
  
[fragment shader]  
  
  
uniform sampler2D sTexture;  
  
  
  
  
  
void main()  
  
  
{  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;gl\_FragColor = texture2D(sTexture, gl\_PointCoord);  
  
  
}  
  
  
  
  
  
As a first approach I was only trying to draw a textured point on the screen:  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GLfloat vertex[] = {0.0f,0.0f,0.0f};  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glEnableVertexAttribArray(VERTEX\_ARRAY);  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glVertexAttribPointer (VERTEX\_ARRAY, 4, GL\_FLOAT, GL\_FALSE, 0, vertex);  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glDrawArrays(GL\_POINTS, 0, 1);  
  
  
  
  
  
If I use a vec2 coordinate instead of the gl\_PointCoord, it draws a point sprite with uniform color.  
  
  
But with the gl\_PointCoord it fails.  
  
  
  
  
  
Am I missing something?  
  
  
  
  
  
Thanks

---

<div class="post-metadata">

**Author:** ![martin-kraus](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@martin-kraus](https://forums.imgtec.com/u/martin-kraus)\
**Post date:** [November 26, 2010, 8:59am UTC](https://forums.imgtec.com/t/point-sprites/926/2 "2010-11-26T08:59:20Z")

</div>

Hi alvalea,  
  
strange error. What is your hardware? Do you know which OpenGL version and which extensions your driver supports?  
  
Could you try this fragment shader:  
  
void main()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
&nbsp; &nbsp; gl\_FragColor = vec4(gl\_PointCoord.x, gl\_PointCoord.y, 0.0, 1.0);   
}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![alvalea](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/alvalea/32/81_2.png) [@alvalea](https://forums.imgtec.com/u/alvalea)\
**Post date:** [November 29, 2010, 8:59am UTC](https://forums.imgtec.com/t/point-sprites/926/3 "2010-11-29T08:59:36Z")

</div>

I’m trying it with an Intel integrated chip Q45/Q43. The supported OpenGL version is 2.0.  
  
  
The gl\_PointCoord coordinates are always (0,0).

---

<div class="post-metadata">

**Author:** ![martin-kraus](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@martin-kraus](https://forums.imgtec.com/u/martin-kraus)\
**Post date:** [November 29, 2010, 11:52am UTC](https://forums.imgtec.com/t/point-sprites/926/4 "2010-11-29T11:52:33Z")

</div>

Strange.   
  
  
  
Well, "gl\_PointCoord" is a feature of GLSL 1.20; thus, you might have to add the line  
  
  
  
#version 120  
  
  
  
at the start of your fragment shader. (Of course, you should also check whether GLSL 1.20 is supported on your hardware/driver. OpenGL 2.0 only requires GLSL 1.10; thus, this might be an issue.)  
  
  
  
If this doesn't work, I would suggest that you try to get the fragment  
shader to work in (desktop) OpenGL. If it doesn't work in (desktop)  
OpenGL on your hardware/driver, I would assume that it also doesn't work  
in the OpenGL ES emulator. (In desktop OpenGL you probably have to  
glEnable GL\_POINT\_SPRITE and GL\_VERTEX\_PROGRAM\_POINT\_SIZE but apart from  
this, the code should be very similar.)  
  
  
  
If the code works in (desktop) OpenGL but not in the OpenGL ES emulator, I would assume it's a bug in the emulator. :/  
  
  
  
  
  
  
  
Martin Kraus2010-11-29 13:02:17

---

<div class="post-metadata">

**Author:** ![alvalea](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/alvalea/32/81_2.png) [@alvalea](https://forums.imgtec.com/u/alvalea)\
**Post date:** [November 30, 2010, 11:56am UTC](https://forums.imgtec.com/t/point-sprites/926/5 "2010-11-30T11:56:36Z")

</div>

If I add the line ‘#version 120’ the function PVRTShaderLoadFromFile fails.  
  
  
I guess that the problem is that the hardware doesn’t support GLSL 1.20.  
  
  
I will try to test it in another hardware.

---

<div class="post-metadata">

**Author:** ![martin-kraus](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@martin-kraus](https://forums.imgtec.com/u/martin-kraus)\
**Post date:** [November 30, 2010, 1:35pm UTC](https://forums.imgtec.com/t/point-sprites/926/6 "2010-11-30T13:35:57Z")

</div>

alvelea,   
  
I just tested it and the OpenGL ES emulator seems to reject anything but version “#version 100”. Actually, GLSL version 1.00 for OpenGL ES appears to be based on GLSL version 1.20 for OpenGL.   
  
Thus, I guess you have to make sure to run the emulator on hardware that supports GLSL 1.20.

---

<div class="post-metadata">

**Author:** ![alvalea](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/alvalea/32/81_2.png) [@alvalea](https://forums.imgtec.com/u/alvalea)\
**Post date:** [November 30, 2010, 3:51pm UTC](https://forums.imgtec.com/t/point-sprites/926/7 "2010-11-30T15:51:34Z")

</div>

Ok, thanks a lot 🙂
