• C++ Module backward headers
    14 replies, posted
Sorry for some many questions recently but does anyone have the backwards_headers ([url]http://blackawps-glua-modules.googlecode.com/svn/trunk/backwards_headers[/url]). It now 404's so I cannot get them, Or, Alternaticly does anyone have any good infomation on stack programming eg [CODE]LUA->CreateTable(); LUA->PushCFunction( gcDeleteWrapper ); LUA->SetField( -2, "__gc" ); LUA->PushCFunction( toStringWrapper ); LUA->SetField( -2, "__tostring" );[/CODE]
[url]https://bitbucket.org/breakpointservers/bkacjios-glua-modules/src/c2d54eb24ba98c90911c88e01a9a4f6da3660526/backwards_headers/?at=default[/url] [url]http://www.lua.org/manual/5.1/manual.html#3.1[/url] [url]http://wiki.garrysmod.com/page/C_Lua:_Functions[/url]
[QUOTE=man with hat;50354194][url]https://bitbucket.org/breakpointservers/bkacjios-glua-modules/src/c2d54eb24ba98c90911c88e01a9a4f6da3660526/backwards_headers/?at=default[/url] [url]http://www.lua.org/manual/5.1/manual.html#3.1[/url] [url]http://wiki.garrysmod.com/page/C_Lua:_Functions[/url][/QUOTE] Thanks man! Would you recomend me use the backward headers or learn stack?
[QUOTE=0V3RR1D3;50354230]Thanks man! Would you recomend me use the backward headers or learn stack?[/QUOTE] Really there's not much difference between garry's frankenstein backwards headers and the raw lua C API. [code] LUA->SetField(A, B); [/code] maps to [code] lua_setfield(LuaState, A, B); [/code] and so on, and besides. There's more documentation about the lua C api online than there is for the custom headers.
[QUOTE=0V3RR1D3;50354230]Thanks man! Would you recomend me use the backward headers or learn stack?[/QUOTE] I prefer not to use the backwards headers.
[QUOTE=cartman300;50354380]Really there's not much difference between garry's frankenstein backwards headers and the raw lua C API. [code] LUA->SetField(A, B); [/code] maps to [code] lua_setfield(LuaState, A, B); [/code] and so on, and besides. There's more documentation about the lua C api online than there is for the custom headers.[/QUOTE] Awesome [editline]20th May 2016[/editline] One last question if anyone knows, Is there a way to access opengl from a module nativly with gmod or do I have to include it in my project?
[QUOTE=0V3RR1D3;50354530]Awesome [editline]20th May 2016[/editline] One last question if anyone knows, Is there a way to access opengl from a module nativly with gmod or do I have to include it in my project?[/QUOTE] Well, you certainly wouldn't want to interface with opengl directly (unless you intend on creating a new window and context). If your module needs to render something in-game, you can use Source's renderer to do it. [code] #include <tier1.h> #include <materialsystem/imaterialsystem.h> CDllDemandLoader materialsystem_module("materialsystem"); IVRenderView* render = NULL; IMatRenderContext* pRenderContext = NULL; void GetInterfaces() { CreateInterfaceFn func = materialsystem_module.GetFactory(); materials = (IMaterialSystem*)func(MATERIAL_SYSTEM_INTERFACE_VERSION, 0); pRenderContext = materials->GetRenderContext(); } GMOD_MODULE_OPEN() { GetInterfaces(); // blah blah code } [/code] Though, you should really only use this to provide Lua bindings for renderer functions that gmod doesn't already provide, and render stuff with Lua scripting.
[QUOTE=Jcw87;50355834]Well, you certainly wouldn't want to interface with opengl directly (unless you intend on creating a new window and context). If your module needs to render something in-game, you can use Source's renderer to do it. [code] #include <tier1.h> #include <materialsystem/imaterialsystem.h> CDllDemandLoader materialsystem_module("materialsystem"); IVRenderView* render = NULL; IMatRenderContext* pRenderContext = NULL; void GetInterfaces() { CreateInterfaceFn func = materialsystem_module.GetFactory(); materials = (IMaterialSystem*)func(MATERIAL_SYSTEM_INTERFACE_VERSION, 0); pRenderContext = materials->GetRenderContext(); } GMOD_MODULE_OPEN() { GetInterfaces(); // blah blah code } [/code] Though, you should really only use this to provide Lua bindings for renderer functions that gmod doesn't already provide, and render stuff with Lua scripting.[/QUOTE] What about if I need to "capture" the current frame, Or ever re-render with a different camera angle?
What you're looking for is probably possible with lua... render.Capture, render.RenderView, rendertargets, etc. You should really only ever make a module if you know you need one, and even then it's probably a bad idea.
[QUOTE=MadParakeet;50358887]What you're looking for is probably possible with lua... render.Capture, render.RenderView, rendertargets, etc. You should really only ever make a module if you know you need one, and even then it's probably a bad idea.[/QUOTE] I Do need one as im using other api's with it, They are only in C#. But basicly to output with the api I need either a framebuffer or a texture of what is rendered in game with rendertargets. I Have no clue how I can convert a render target in Lua to a framebuffer or texture in c++
[QUOTE=0V3RR1D3;50359063]I Do need one as im using other api's with it, They are only in C#. But basicly to output with the api I need either a framebuffer or a texture of what is rendered in game with rendertargets. I Have no clue how I can convert a render target in Lua to a framebuffer or texture in c++[/QUOTE] It sounds like you're doing something similar to what I'm planning to do. I saw some info on how to do this in another facepunch thread a while ago: [url]https://www.facepunch.com/threads/1082965-Gmod-lua-modules-and-render-targets[/url].
[QUOTE=ph:lxyz;50359455]It sounds like you're doing something similar to what I'm planning to do. I saw some info on how to do this in another facepunch thread a while ago: [url]https://www.facepunch.com/threads/1082965-Gmod-lua-modules-and-render-targets[/url].[/QUOTE] No, that thread is about creating procedural textures, and writing data to them. He wants to get rendered images from Source, possibly for stereoscopic 3d or a VR headset. [QUOTE=0V3RR1D3;50359063]I Do need one as im using other api's with it, They are only in C#. But basicly to output with the api I need either a framebuffer or a texture of what is rendered in game with rendertargets. I Have no clue how I can convert a render target in Lua to a framebuffer or texture in c++[/QUOTE] Well, there's IMatRenderContext::ReadPixels(), which will get the image data from the current render target, but it's likely to be very slow. What exactly are you trying to do?
[QUOTE=Jcw87;50361959]No, that thread is about creating procedural textures, and writing data to them. He wants to get rendered images from Source, possibly for stereoscopic 3d or a VR headset. Well, there's IMatRenderContext::ReadPixels(), which will get the image data from the current render target, but it's likely to be very slow. What exactly are you trying to do?[/QUOTE] I want to output to my Vive. Of course I need 2 images to do that, I got all the render targets set up and stuff just not sure how to translate it from a render target to a frame buffer (Which from what I can see each eye requires a frame buffer to display)
[QUOTE=0V3RR1D3;50362628]I want to output to my Vive. Of course I need 2 images to do that, I got all the render targets set up and stuff just not sure how to translate it from a render target to a frame buffer (Which from what I can see each eye requires a frame buffer to display)[/QUOTE] I did a little research on the openvr api, and it appears that you need to use a native D3D or OpenGL texture handle. The only sane, performance-friendly way of making that work would be to get access to a native texture handle that Source can also draw to. Unfortunately, Source appears to keep these buried somewhere in its shader api, with little to no chance of prying it out.
[QUOTE=Jcw87;50362993]I did a little research on the openvr api, and it appears that you need to use a native D3D or OpenGL texture handle. The only sane, performance-friendly way of making that work would be to get access to a native texture handle that Source can also draw to. Unfortunately, Source appears to keep these buried somewhere in its shader api, with little to no chance of prying it out.[/QUOTE] Thanks for that. I got it all working except the rendering, it was fun and I learnt new thing anyway.
Sorry, you need to Log In to post a reply to this thread.