New topic: C++ to RB
<http://forums.realsoftware.com/viewtopic.php?t=34252> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message Blake Post subject: C++ to RBPosted: Sat Jun 12, 2010 12:17 pm Joined: Fri Sep 30, 2005 8:39 pm Posts: 361 Location: Arlington, TX I'm having some trouble converting this code and I was hoping that someone here could point me in the right direction. Here is the C++ code: Code:char sourcecode[] = "varying vec3 color;\n" "void main(void)\n" "{\n" " color = vec3(gl_Vertex.x, 0.25, gl_Vertex.y);\n" " gl_Position = ftransform();\n" "}\n"; glShaderSource(*shader,1,(const GLcharARB **)&sourcecode,0); Here is what I have so far in RB: Code:Dim smb As New MemoryBlock( 4 ) Dim sourcecode As String sourcecode = "varying vec3 color;\n" + _ "void main(void)\n" + _ "{\n" + _ " color = vec3(gl_Vertex.x, 0.25, gl_Vertex.y);\n" + _ " gl_Position = ftransform();\n" + _ "}\n"; smb.Ptr( 0 ) = sourcecode ' sourecode is a memoryblock containing a string glShaderSource( shader, 1, smb, Nil ) Edit: The problem lies in glShaderSource, the string (memoryblock) isn't being passed for some reason. _________________ Open Source OpenGL Classes: Camera (1.1), Light (1.0), Texture (1.2), Font (1.2), Mesh (1.7), Models (1.0) Top timhare Post subject: Re: C++ to RBPosted: Sat Jun 12, 2010 5:41 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7886 Location: Portland, OR USA Quote:smb.Ptr( 0 ) = sourcecode ' sourecode is a memoryblock containing a string You say sourcecode is a memoryblock, yet you have dimmed it as a string. Also, you don't show how you have declared the glShaderSource function. It looks like you should be able to declare that parameter as Ptr and pass the memoryblock directly, without using a second smb memoryblock. Top Blake Post subject: Re: C++ to RBPosted: Sat Jun 12, 2010 7:24 pm Joined: Fri Sep 30, 2005 8:39 pm Posts: 361 Location: Arlington, TX Yeah, I figured it out, there was another topic on this exact problem: http://forums.realsoftware.com/viewtopic.php?f=4&t=26399, I should have searched before posting _________________ Open Source OpenGL Classes: Camera (1.1), Light (1.0), Texture (1.2), Font (1.2), Mesh (1.7), Models (1.0) Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
