Graphics.NewbieCubeHelloPlugin - lordmundi/wikidoctest GitHub Wiki
Newbie Cube Hello Plugin
« Decoration | NewbieIndex | Spin The Cube »
Goal
Make a small and useless plugin. A detailed description of plugin development is here
EDGE 2.4.1 Guide
| Make The "Hello, Cube" Plugin (hellocube.c) | || | #include "doug.h"
// The only mandatory function
DSP_InitializePlugin( DSS_PLUGIN *plugin )
{
fprintf(stderr, "HELLO, CUBE\n");
return 1;
} |
| * * *
% cd ${DOUG_HOME}/src.dist/plugins
% mkdir helloPlugin # Container folder for user's plugins
% vi helloPlugin/hellocube.c ; # <contents above>
% cp examples/Makefile helloPlugin #Use the makefile from the example folder for now |
We're copying the Makefile directly from the example directory, but as-is it will compile to the same directory as the Makefile. We have to change it to compile the plugin somewhere EDGE knows to look, such as the plugin directory in EDGE_HOME. (Another place you may want to compile to would be the USERDATA directory.)
| Edit the Plugin's Makefile | || | 16 DIR_OBJ := object_${HOST_CPU} 17 DIR_PLUGIN := plugin_${HOST_CPU} #Change these lines to compile to the directories in EDGE_HOME 16a DIR_OBJ := ../../../object_${HOST_CPU} 17a DIR_OBJ := ../../../plugin_${HOST_CPU} #There may be a better way to do this. If you have one, feel free to edit this!
#We also need to edit the clean function. As is, it removes the directory. But the one in EDGE_HOME is shared with other plugins.
36 $(RM) -rf $(DIR_OBJ) $(DIR_PLUGIN)
#Change this line to remove the individual files instead of the directories
36a $(RM) -f $(OBJ) $(PLUGIN) |
| * * *
% vi helloPlugin/Makefile ; # <changes above> |
Next, we'll want to add this makefile to compile from the src.dist makefile. This step is optional, but helps keep everything organized under a single makefile.
| Edit src.dist/Makefile | || | 16 common: 17a $(MAKE) -C plugins/helloPlugin # Add this make command 18 $(MAKE) -C plugins/common/libcsv
41 clean:
42a $(MAKE) -C plugins/helloPlugin clean # Add this make clean command
43 $(MAKE) -C plugins/common/libcs clean |
| * * *
% cd ${DOUG_HOME}/src.dist
% vi Makefile ; # <contents above> |
If you've followed all these steps properly, making src.dist should compile the plugin correctly. Lastly, we just need to tell EDGE that we're using the plugin.
| Mod Config File | || | CUBE { plugins { cube hellocube }
channel1
{
view.MAIN NewbieCam perspective(...)...
}
}
% cd ${USERDATA}
% vi user.cfg ;
% Add "plugin block" contents above to CUBE block |
| Launching "Hello, Cube" | || | ... GL_MAX_VERTEX_ATTRIBS_ARB = 16 GL_MAX_COLOR_ATTACHMENTS_EXT = 4 Calling plugin 'hellocube' DSP_InitializePlugin procedure HELLO, CUBE Reload_Tree Largest geom has 20 unique verticies ........... 20 unique verticies in scene ........... 20 unique normals in scene ........... ...
% cd ${DOUG_HOME}
% ./run_graphics
The printout "HELLO, CUBE" should appear as seen above |
| Currently Loaded Plugins | || |
You should see "hellocube" in list
On main doug window, select: Help->About Doug
Press: "Plugins" |
For EDGE 2.3 and Before
| Make The "Hello, Cube" Plugin (hellocube.c) | || | #include "doug.h"
// The only mandatory function
DSP_InitializePlugin( DSS_PLUGIN *plugin )
{
fprintf(stderr, "HELLO, CUBE\n");
return 1;
} |
| * * *
% cd ${DOUG_HOME}/src.dist/plugins
% vi hellocube.c ; # <contents above>
% make ; # this will create a hellocube.so, as well as a bunch of other shared objects! |
You should now have hellocube.so in ${DOUG_HOME}/plugin_..yourOShere…/ If you have trouble building your plugin, see some common issues in Troubleshooting under Plugin Building issues.
| Mod Config File | || | CUBE { plugins { cube hellocube }
channel1
{
view.MAIN NewbieCam perspective(...)...
}
}
% cd ${USERDATA}
% vi user.cfg ;
% Add "plugin block" contents above to CUBE block |
| Launching "Hello, Cube" | || | ... GL_MAX_VERTEX_ATTRIBS_ARB = 16 GL_MAX_COLOR_ATTACHMENTS_EXT = 4 Calling plugin 'hellocube' DSP_InitializePlugin procedure HELLO, CUBE Reload_Tree Largest geom has 20 unique verticies ........... 20 unique verticies in scene ........... 20 unique normals in scene ........... ...
% cd ${DOUG_HOME}
% ./run_graphics
The printout "HELLO, CUBE" should appear as seen above |
| Currently Loaded Plugins | || |
You should see "hellocube" in list
On main doug window, select: Help->About Doug
Press: "Plugins" |
« Decoration | NewbieIndex | Spin The Cube »