klepto2 Posted June 6, 2011 Share Posted June 6, 2011 Hi, I have started a small project called Leadwerks.Extensions. The goal is to provide some deeper functionality from Blitzmax to other languages (not Blitzmax commands directly, but eg missing commands from the provided dll. I have started a test dll which should made my realtime cubemap code available to all languages. Unfortuntly I become errors in the code itself. The function access itself works well, but in the buffer creation function i get access violation errors (protected memory) when using glGenFramebuffersEXT. Here is my current Blitzmax code: SuperStrict Framework leadwerks.ENGINE Const COMPILE_DLL:Int = True Private Function ObjectPointer:Byte Ptr(o:Object) If o=Null Return Null Local p:Byte Ptr p=o p:-8 Return p EndFunction Public Type TCubeBuffer Field texture:TTexture Field buffer:TBuffer Field rb:Int[1] Field fb:Int[1] Field sb:Int[1] Field db:Int[1] Function Create:TCubeBuffer(texture:TTexture,buffer:TBuffer) Local cb:TCubeBuffer = New TCubeBuffer Notify "Debug 1" cb.Texture = texture Notify "Debug 2" cb.Buffer = buffer Notify "Debug 3" cb._BuildBuffer() Notify "Debug 4" cb.Buffer.Framebuffer = cb.fb[0] Notify "Debug 5" cb.Buffer.colorbuffer[0] = texture Notify "Debug 6" Return cb End Function Method _BuildBuffer() Notify "Debug 3.1" Local w:Int = texture.reference._Width Notify "Debug 3.2" Local h:Int = texture.reference._Height Notify "Debug 3.3" glBindTexture(GL_TEXTURE_CUBE_MAP , texture.reference._index) Notify "Debug 3.4" glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_X,0,GL_RGBA8 ,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Null glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_Z,0,GL_RGBA8 ,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Null glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_X,0,GL_RGBA8 ,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Null glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,0,GL_RGBA8 ,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Null glTexImage2D GL_TEXTURE_CUBE_MAP_POSITIVE_Y,0,GL_RGBA8 ,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,Null glTexImage2D GL_TEXTURE_CUBE_MAP_NEGATIVE_Y , 0 , GL_RGBA8 , w , h , 0 , GL_RGBA , GL_UNSIGNED_BYTE , Null glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE) ; glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP , GL_TEXTURE_MIN_FILTER , GL_LINEAR) ; Notify "Debug 3.5" glGenFramebuffersEXT(1 , fb ) Notify "Debug 3.5.1" glGenRenderbuffersEXT(1 , rb) Notify "Debug 3.5.2" glGenRenderbuffersEXT(1 , sb) Notify "Debug 3.6" glBindFramebufferEXT(GL_FRAMEBUFFER_EXT , fb[0]) ; glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT , GL_TEXTURE_CUBE_MAP , texture.reference._index, 0) ; Notify "Debug 3.7" glBindRenderbufferEXT(GL_RENDERBUFFER_EXT , rb[0]) ; glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24 ,W, H); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT , GL_DEPTH_ATTACHMENT_EXT , GL_RENDERBUFFER_EXT , rb[0]) Notify "Debug 3.8" glBindFramebufferEXT(GL_FRAMEBUFFER_EXT , 0) glBindRenderbufferEXT(GL_RENDERBUFFER_EXT , 0) ; End Method Method Set(cubeface:Int) SetBuffer(buffer) Select cubeface Case 0 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_POSITIVE_X,texture.reference._index,0) Case 1 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_NEGATIVE_X,texture.reference._index,0) Case 2 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_POSITIVE_Y,texture.reference._index,0) Case 3 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,texture.reference._index,0) Case 4 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_POSITIVE_Z,texture.reference._index,0) Case 5 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,texture.reference._index,0) End Select End Method Method Unset() glBindFramebufferEXT(GL_FRAMEBUFFER_EXT , 0) End Method Method CheckFBOStatus:Int(index:Int = 0) Local status:Int = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) Select status Case GL_FRAMEBUFFER_COMPLETE_EXT Print index + ": FBO Complete" Case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT Print index + ": Incomplete attachment" Case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT Print index + ": Missing attachment" Case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT Print index + ": Incomplete dimensions" Case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT Print index + ": Incomplete formats" Case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT Print index + ": Incomplete draw buffer" Case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT Print index + ": Incomplete read buffer" Case GL_FRAMEBUFFER_UNSUPPORTED_EXT Print index + ": Framebufferobjects unsupported" EndSelect Return Status End Method End Type Function CubeBuffer_Create:TCubeBuffer(cubemap:TTexture , cubemapbuffer:TBuffer) "win32" If COMPILE_DLL Then GCEnter() Notify "Create_Start" If cubemap <> Null Then Notify "Cubemap valid" If cubemapbuffer <> Null Then Notify "cubemapbuffer valid" Local b:TCubebuffer = TCubeBuffer.Create(cubemap , cubemapbuffer) Notify "buffer created" Return b End Function Function CubeBuffer_ActivateFace(cubebuffer:TCubebuffer , face:Int = 0) "win32" If COMPILE_DLL Then GCEnter() cubebuffer.Set(face) End Function Function CubeBuffer_Deactivate(cubebuffer:TCubebuffer) "win32" If COMPILE_DLL Then GCEnter() cubebuffer.UnSet() End Function Function CreateCubemap:TTexture(width:Int , height:Int) "win32" If COMPILE_DLL Then GCEnter() Return Leadwerks.Engine.CreateCubemap(width , height) End Function I have added some debug notfiies to check where the error occurs. The same code called from Blitzmax works. Using it from C# it fails and throws the error in line 64. (glGenFramebuffersEXT(1 , fb ) ) The CreateCubemap command works well. Does anybody know what is causing this and maybe how to solve this issue? thx in advance Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.