# Colours turn to Black on using Print3D

**URL:** <https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834>\
**Category:** PowerVR Insider\
**Created:** [July 2, 2013, 8:42am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834 "2013-07-02T08:42:18Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 8:42am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/1 "2013-07-02T08:42:18Z")

</div>

Hi,  
  
  
  
I had got all the colourful objects in my scene. Then, I started using Print3D class to print information like FPS etc on the screen. But, when I run the program, every object turns black although the text is printed correctly on the screen. During running, I also get the following warnings :  
  
  
  
PVR:(Warning): UnpackRevision: The SGX core flag is 0x535 but we expected 0x544. [312, /binshader.c]  
  
PVR:(Warning): UnpackRevision: The GLSL compiled Uniflex interface revision flag is 0x0 but we expected 0x2. [1138, /binshader.c]  
  
PVR:(Warning): UnpackRevision: The Unipatch input revision flag is 0x0 but we expected 0x25. [1145, /binshader.c]  
  
PVR:(Warning): UnpackRevision: Couldn’t find a revision that matches the current hardware and driver. [1176, /binshader.c]  
  
  
  
Can someone help ?

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [July 2, 2013, 9:43am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/2 "2013-07-02T09:43:00Z")

</div>

Hello  
  
  
  
did you define the usageof the default texture  
  
m\_Print3D.SetTextures(NULL, uiWidth, uiHeight, bRotate);  
  
did you FLush ?  
  
m\_Print3D.Flush();  
  
what will be your clear color :  
  
// Clears the color and depth buffer  
  
glClear(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT);  
  
  
  
like describe in the sample **OGLES2IntroducingPrint3**?  
  
  
  
regards  
  
david

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 10:06am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/3 "2013-07-02T10:06:15Z")

</div>

Yes, I did all the above things. I will give you a brief overview of the code :  
  
  
  
InitView()  
  
{  
  
//Compiling shaders  
  
  
  
rotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);  
  
  
  
if(m\_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), rotate) != PVR\_SUCCESS)  
  
{  
  
PVRShellSet(prefExitMessage, “ERROR: Cannot initialise Print3Dn”);  
  
return false;  
  
}  
  
}  
  
  
  
RenderScene()  
  
{  
  
glClear(GL\_COLOR\_BUFFER\_BIT | GL\_DEPTH\_BUFFER\_BIT);  
  
  
  
//Camera Calculations  
  
  
  
for(i=0;i\<nummeshes;i++)  
  
{  
  
glBindBuffer(GL\_ARRAY\_BUFFER, m\_ui32Vbo_);_  
  
_glBindBuffer(GL\_ELEMENT\_ARRAY\_BUFFER, m\_ui32Ibo);_  
  
   
  
_glEnableVertexAttribArray(VERTEX\_ARRAY);_  
  
_glVertexAttribPointer(VERTEX\_ARRAY, 3, GL\_FLOAT, GL\_FALSE, 0, 0);_  
  
_glEnableVertexAttribArray(COLOUR\_ARRAY);_  
  
_glVertexAttribPointer(COLOUR\_ARRAY, 3, GL\_FLOAT, GL\_FALSE, 0, 0);_  
  
   
  
_glDrawElements(GL\_TRIANGLES, facecount \* 3, GL\_UNSIGNED\_SHORT, NULL);_  
  
   
  
_glBindBuffer(GL\_ARRAY\_BUFFER, 0);_  
  
_glBindBuffer(GL\_ELEMENT\_ARRAY\_BUFFER, 0);_  
  
_}_  
  
   
  
   
  
_m\_Print3D.DisplayDefaultTitle(“HELLO”, “”, NULL);_  
  
_m\_Print3D.Flush();_  
  
_}_

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [July 2, 2013, 10:32am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/4 "2013-07-02T10:32:23Z")

</div>

can you set a clear color in the InitView to see  
  
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 10:47am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/5 "2013-07-02T10:47:56Z")

</div>

Right now, I have set it to be :  
  
  
  
glClearColor(0.7f, 0.85f, 1.0f, 1.0f);  
  
  
  
I can see the blue sky. Only the objects have turned black.

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [July 2, 2013, 11:04am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/6 "2013-07-02T11:04:00Z")

</div>

so it s the color array that you set then

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 11:24am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/7 "2013-07-02T11:24:57Z")

</div>

I didn’t get you.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [July 2, 2013, 12:57pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/8 "2013-07-02T12:57:59Z")

</div>

Hi,  
  
  
  
**Q1:** Are your objects still black when you remove Print3D from your render (i.e. disable _m\_Print3D.Flush();_)?  
  
  
  
**Q2:** The “PVR:(Warning): UnpackRevision: …” output sounds like an issue with shader binaries. Are you compiling shaders from GLSL ES source on each application run, or are you trying to use shader program binaries you’ve pre-compiled?  
  
  
  
Thanks,  
  
Joe

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 1:14pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/9 "2013-07-02T13:14:15Z")

</div>

When I comment every line containing the Print3D variable, the colours are fine. I compile the shaders on each run.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [July 2, 2013, 1:21pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/10 "2013-07-02T13:21:46Z")

</div>

Print3D has to change the OpenGL ES renderstate before it can render, for example enable blending if it is disabled. Print3D _should_ revert the renderstate once it has finished rendering.  
  
  
  
As a test, can you reset your renderstate at the start of your _RenderScene()_ function? If this fixes the problem, then this suggests that there is a bug in Print3D’s renderstate revert mechanism.  
  
  
  
Thanks,  
  
Joe

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 2:25pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/11 "2013-07-02T14:25:11Z")

</div>

I will do that first thing tomorrow…

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [July 2, 2013, 2:33pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/12 "2013-07-02T14:33:21Z")

</div>

something is probably wrong in the shader implementation then no?

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 2, 2013, 3:46pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/13 "2013-07-02T15:46:56Z")

</div>

The shader codes are merely 2 lines of code. What can be wrong in them ?

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 3, 2013, 7:51am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/14 "2013-07-03T07:51:52Z")

</div>

Joe, what did you mean exactly by resetting the render state of OpenGL ES ?

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [July 3, 2013, 11:40am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/15 "2013-07-03T11:40:11Z")

</div>

You need to reset anything that has been toggled with glEnable/glDisable and bind shaders, textures & buffers needed by your draw calls.  
  
  
  
Based on the code snippets you’ve supplied, it may just be _glUseProgram()_ that needs to be set again. To be safe, you should reset all of your render state and bindings.  
  
  
  
Thanks,  
  
Joe

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 3, 2013, 12:38pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/16 "2013-07-03T12:38:42Z")

</div>

I did reset every thing in my RenderScene(). After that, both the colours and the text were visible, but after 1 second, the application hangs and exits abruptly with many error messages like glBuffer can’t allocate space, etc.

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 3, 2013, 12:46pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/17 "2013-07-03T12:46:32Z")

</div>

These are the error messages :  
  
  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff97: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff99: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9b: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9d: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9f: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa1: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa3: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa5: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa7: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa9: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffab: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffad: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffaf: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb1: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb3: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb5: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb7: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb9: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbb: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbd: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbf: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffc1: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffc3: Cannot allocate memory [133, /pvr\_mmap.c]  
  
PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged\_pvr\_glue.c]  
  
PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]  
  
PVR:(Fatal): Debug assertion failed! [1324, /drawvarray.c]

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [July 3, 2013, 2:40pm UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/18 "2013-07-03T14:40:39Z")

</div>

Hi,  
  
  
  
Have you moved your buffer creation code to _RenderScene()_? From the errors, I think you may be creating new buffers every frame without releasing any existing memory, which is causing the graphics driver to run out of memory.  
  
  
  
You should only move the bind operations to the _RenderScene()_ function to make sure the correct shaders, buffers & textures are bound when your draw calls are submitted.  
  
  
  
Thanks,  
  
Joe

---

<div class="post-metadata">

**Author:** ![hellboy](https://avatars.discourse-cdn.com/v4/letter/h/48db29/32.png) [@hellboy](https://forums.imgtec.com/u/hellboy)\
**Post date:** [July 4, 2013, 3:52am UTC](https://forums.imgtec.com/t/colours-turn-to-black-on-using-print3d/1834/19 "2013-07-04T03:52:47Z")

</div>

Thanks Joe. That was the problem indeed. I mistakenly copied the buffer creation code too. Now it’s working fine.
