[syphon-implementations] r227 committed - avoid glitches when server goes online

8 views
Skip to first unread message

syphon-impl...@googlecode.com

unread,
Jul 14, 2013, 1:40:58 AM7/14/13
to syphon-de...@googlegroups.com
Revision: 227
Author: connec...@gmail.com
Date: Sat Jul 13 22:40:41 2013
Log: avoid glitches when server goes online
http://code.google.com/p/syphon-implementations/source/detail?r=227

Modified:
/trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/Syphon.cs
/trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/SyphonObject/SyphonClientObject.cs
/trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/SyphonServerAndClient.unity
/trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityPlugin/SyphonClientUnity.m

=======================================
--- /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/Syphon.cs
Fri Jul 12 15:00:14 2013
+++ /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/Syphon.cs
Sat Jul 13 22:40:41 2013
@@ -543,7 +543,7 @@

public void OnPreRender(){
//call 1 to cache context.
- GL.IssuePluginEvent(updateContext);
+ GL.IssuePluginEvent(updateContext);
}

}
=======================================
--- /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/SyphonObject/SyphonClientObject.cs
Fri Jul 12 15:00:14 2013
+++ /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/Plugins/SyphonObject/SyphonClientObject.cs
Sat Jul 13 22:40:41 2013
@@ -86,7 +86,7 @@
boundName = server.SyphonServerDescriptionName;
//initialize the texture
if(attachedTexture == null){
- attachedTexture = new RenderTexture(128, 128, 0,
RenderTextureFormat.ARGB32);
+ attachedTexture = new RenderTexture(16, 16, 0,
RenderTextureFormat.ARGB32);
attachedTexture.filterMode = FilterMode.Bilinear;
attachedTexture.wrapMode = TextureWrapMode.Clamp;
}
@@ -124,8 +124,9 @@
attachedTexture.Release();
attachedTexture.width = width;
attachedTexture.height = height;
- Graphics.Blit( Syphon.NullTexture,attachedTexture);
-
+ RenderTexture.active = attachedTexture;
+// Graphics.Blit( Syphon.NullTexture,attachedTexture);
+ GL.Clear(false, true, new Color(0, 0, 0, 0));

//every GameObject that is using this syphon server might want to know
that the size changed.
if(UpdateClientTextureSize != null){
@@ -143,7 +144,8 @@
attachedTexture.Create();
Syphon.SafeMaterial.SetPass(0);
RenderTexture.active = attachedTexture;
- Graphics.Blit( Syphon.NullTexture,attachedTexture);
+ GL.Clear(false, true, new Color(0, 0, 0, 0));
+// Graphics.Blit( Syphon.NullTexture,attachedTexture);
RenderTexture.active = null;

//this does not allocate GL resources- it simply creates a
SyphonCacheData object on the heap
@@ -214,13 +216,14 @@
else return false;
}

+
public void Render(){
if(syphonClientPointer != 0 && initialized){
//you need to render once per frame for each texture.
- Syphon.SafeMaterial.SetPass(0);
+ Syphon.SafeMaterial.SetPass(0);
RenderTexture.active = attachedTexture;
GL.IssuePluginEvent(syphonClientPointer);
- RenderTexture.active = null;
+ RenderTexture.active = null;
}
}

=======================================
--- /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/SyphonServerAndClient.unity
Sat Jul 13 21:41:18 2013
+++ /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityExample/Assets/SyphonServerAndClient.unity
Sat Jul 13 22:40:41 2013
Binary file, no diff available.
=======================================
--- /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityPlugin/SyphonClientUnity.m
Sat Jul 13 21:41:18 2013
+++ /trunk/Syphon
Implementations/Unity3D/Unity3D-3_5/SyphonUnityPlugin/SyphonClientUnity.m
Sat Jul 13 22:40:41 2013
@@ -111,13 +111,40 @@
glDepthFunc (GL_LEQUAL);
glEnable (GL_DEPTH_TEST);
glDepthMask (GL_FALSE);
-

//get image!
SyphonImage* image = [ptr->syphonClient
newFrameImageForContext:cachedContext];

if(!image){
// NSLog(@"nil image.");
+ //SAVE MATRIX STATE CODE
+// glActiveTexture(GL_TEXTURE0);
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+ // Setup OpenGL coordinate system
+ glViewport(0, 0, ptr->textureWidth, ptr->textureHeight);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, ptr->textureWidth, 0, ptr->textureHeight, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glColor4f(0, 0, 0, 0);
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+
+ //POP MATRIX STATE CODE
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, previousDrawFBO);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, previousReadFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER, previousFBO);
@@ -129,6 +156,9 @@
}


+
+
+

//SAVE MATRIX STATE CODE
glActiveTexture(GL_TEXTURE0);
@@ -162,8 +192,7 @@
// ptr->updateTextureSizeFlag = true;
handleTextureSizeChanged(ptr);

- if(ptr->textureWidth == 0 || ptr->textureHeight == 0){
-
+ if(ptr->textureWidth == 0 || ptr->textureHeight == 0){
glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0);
glDisable(GL_TEXTURE_RECTANGLE_EXT);

Reply all
Reply to author
Forward
0 new messages