Monday, April 28, 2008

A new tag is born

After the lack of success cloning the canvas tag I decided to try and do the same with a less "complicated" tag. The canvas tag involves more files than most tags therefore making it more difficult to setup all the dependencies correctly in the build system. The best tag to clone after the canvas was the button tag. It is simple yet it requires a custom rendering module. I started from scratch once again and followed the same procedure to clone it. I also decided to call the new tag opengl instead of WebOpenGL because it followed the tag naming convention more closely.
The project built successfully and I could see the opengl tag files in the build log. However, the opengl tag did not render like a button but as a label instead. To ensure that the opengl tag was actually being created I inserted print statements in the constructors of both the tag and the tag's custom renderer. I was disappointed to see that nothing was printed when an opengl tag was created. I examined each of the files were I had made entries to inform the builder to create this new tag. I realized that there was one place in which the button tag was referenced but not the opengl tag. I made the appropriate entry and tried again. Viola! This time both print statements were executed. I had created a new HTML tag.
Even though an instance of the custom renderer was being created, the tag was still not displaying as a button. However, because the ultimate goal was to display a pixel map, I knew that further tweaking was involved so I wasn't too worried.
Next: play around with the custom render in order to display a fixed pixel map when the opengl tag is created.

2 comments:

Mike said...

Congrats! So I guess my question now is, will you need to put your entire code between an opengl tag? Because that would be a LOT of code to write out and put into an html tag.

Andres said...

All the code would be written in Javascript. A typical webopengl application would look a lot like an OpneJSGL application (http://openjsgl.sourceforge.net).