Oxygen Basic
Programming => Problems & Solutions => Topic started by: kryton9 on March 22, 2011, 07:53:24 PM
-
Charles as you know in C, you need to include the gl.h and also link to libopengl32.a. I don't understand how you are using opengl without linking to the lib files as you do in C?
-
Hi Kent,
There is a set of Opengl headers in inc/glo2/gl. These are original MS & Khronos c headers. I only provide a couple of dummy H files in inc/glo2 to make it useable for Oxygen.
Oh - and I borrowed Petr's thinBasic WGL.inc :)
Charles
-
So we don't need to lib files? Just c header files and the dynamic dll Charles?
-
No Kent. Oxygen does not use libs. Only the headers are needed with an indication of which DLL are being referred to and a few typedefs where necessary.
This is how Opengl headers are utilised in PortViwer1. (I've tidied it a little :) )
'OPENGL HEADERS
'==============
#define WINGDIAPI
#define APIENTRY
#define const
typedef word wchar_t
typedef sys ptrdiff_t
'
includepath "..\..\inc\glo2\"
library "opengl32.dll"
include once "gl\gl.h"
'include once "gl\glext.h"
library "glu32.dll"
include once "gl\glu.h"
library ""
'
include once "gl\thinbasic_wgl.inc"
Charles
-
Thanks Charles, I will try to get SDL working if I can using your example here.
-
I have not studied SDL headers. Often C headers have symbols with the same characters but different case - OpenCL for example. For these vexing situations, it becomes necessary to make Oxygen at least partially case sensitive. Usually the style is to put all equates into upper case and everything else in mixed case.
To make Oxygen sensitive to all-capitalised SYMBOLS and distinguish them from others use:
#case capital
other options:
#case sensitive
#case insensitive (default)
Charles
-
Thanks Charles, those tips are very important. I hope to start tonight when I get home. When I run into a problem I can't resolve after a few hours I will be posting for help :)
-
I just don't understand this stuff. I have to give up on the conversion Charles, sorry about that.
-
Hi Kent,
C headers are not a bundle of joy, nor is raw Opengl for that matter. The best I can offer is examples to play with. I always start with a working example and then gradually morph it into something new, hopefully creating a few useful abstractions in the process.
The GDIplus "WinImage" image example is a case in point. I adapted it from one of José's Multimedia examples which in turn came from an MS C++ example.
Charles
PS: Which SDL were you looking at Kent?
-
Actually now I found out that SFML also has c header versions and it is nicer than SDL. SFML (Simple Fast Multimedia Library) is in C++, and that is how I used it before. But I noticed the C version when I was looking at the Ruby and Python versions.
SFML c++ version also provides both dynamic and static versions in the download. So it is a really nice library. I have not played with the C version yet.
http://www.sfml-dev.org/download.php
...Just downloaded C version, it too has static and dynamic libraries. Here is an example of the c code using it. As you can see really well done and easy.
#include <SFML/Audio.h>
#include <SFML/Graphics.h>
int main()
{
sfWindowSettings Settings = {24, 8, 0};
sfVideoMode Mode = {800, 600, 32};
sfRenderWindow* App;
sfImage* Image;
sfSprite* Sprite;
sfFont* Font;
sfString* Text;
sfMusic* Music;
sfEvent Event;
/* Create the main window */
App = sfRenderWindow_Create(Mode, "SFML window", sfResize | sfClose, Settings);
if (!App)
return EXIT_FAILURE;
/* Load a sprite to display */
Image = sfImage_CreateFromFile("cute_image.jpg");
if (!Image)
return EXIT_FAILURE;
Sprite = sfSprite_Create();
sfSprite_SetImage(Sprite, Image);
/* Create a graphical string to display */
Font = sfFont_CreateFromFile("arial.ttf", 50, NULL);
if (!Font)
return EXIT_FAILURE;
Text = sfString_Create();
sfString_SetText(Text, "Hello SFML");
sfString_SetFont(Text, Font);
sfString_SetSize(Text, 50);
/* Load a music to play */
Music = sfMusic_CreateFromFile("nice_music.ogg");
if (!Music)
return EXIT_FAILURE;
/* Play the music */
sfMusic_Play(Music);
/* Start the game loop */
while (sfRenderWindow_IsOpened(App))
{
/* Process events */
while (sfRenderWindow_GetEvent(App, &Event))
{
/* Close window : exit */
if (Event.Type == sfEvtClosed)
sfRenderWindow_Close(App);
}
/* Clear the screen */
sfRenderWindow_Clear(App, sfBlack);
/* Draw the sprite */
sfRenderWindow_DrawSprite(App, Sprite);
/* Draw the string */
sfRenderWindow_DrawString(App, Text);
/* Update the window */
sfRenderWindow_Display(App);
}
/* Cleanup resources */
sfMusic_Destroy(Music);
sfString_Destroy(Text);
sfFont_Destroy(Font);
sfSprite_Destroy(Sprite);
sfImage_Destroy(Image);
sfRenderWindow_Destroy(App);
return EXIT_SUCCESS;
}
-
Hi Kent,
Big download! (27Meg) but that includes all kinds of binary stuff.
At first glance the headers look nice and clean.
I don't think we would have any difficulty in using SFML or SDL for that matter.
Charles
-
I think what happened is that Oxygen Alpha is so powerful and usable, but for guys like you who know things inside and out.
I studied the code you have in the headers and elsewhere and I can see that you were also using that code for testing purposes on syntax, clever idea, but it makes it very hard to study for the uninitiated. I am not complaining, just observing. It makes me appreciate all that has to be handled and how you even got it to come together.
-
I think what happened is that Oxygen Alpha is so powerful and usable, but for guys like you who know things inside and out.
I agree Kent.
With my memory worse than ever and 10 different ways to do the same thing I'm afraid I'll have to wait until a Beta with advanced documentation before I can get involved again.
James
-
It's mostly qbasic syntax with additional flexibility. I find the greatest burden is wading through endless libraries - system graphics audio, kernel. This is the most serious challenge to one's long suffering brain cells.
This is why I think a rich variety of working examples are more useful and instructive than the reference material. Biology works this way - mutations -> evolution!
Charles
-
I think I will try to take your approach Charles and try to develop my game/experimental engine using the winapi and opengl instead of third party libraries.
-
There are about 160 examples in the package so far and we are reaching a stage where some kind of database would be helpful to locate code relevant to a task.
We could tag programs with keywords for this purpose, and also tag individual procedures.
A dictionary of keywords like "jpg" or "wave" could also be established for autotagging.
It is quite feasible to bed a static version of this database into the helpfile each time it is updated.
Any thoughts?
Charles
-
Have you thought about using the OyxgenBasic wiki?
-
Not in this case John. I think it needs to be part of the offline package. But I have thought of autogenerating wiki content from the manual and other resources.
Charles
-
But I have thought of autogenerating wiki content from the manual and other resources.
Let me know if you need help with the translation.
FYI: Open Office will export to Mediawiki format.
Where can one find the current O2h manual? Is it included with the download of the builds?
It would be helpful if you were to do a side-by-side comparison to FreeBASIC syntax. I think you would attract more users if folks didn't have to work so hard to figure out how to use the compiler. You could generate a suite of examples that show how major features of the Basic work and could be used as a test suite to make sure nothing breaks.
-
Where can one find the current O2h manual? Is it included with the download of the builds?
It would be helpful if you were to do a side-by-side comparison to FreeBASIC syntax. I think you would attract more users if folks didn't have to work so hard to figure out how to use the compiler. You could generate a suite of examples that show how major features of the Basic work and could be used as a test suite to make sure nothing breaks.
John,
This is an ALPHA meaning things WILL change daily. Let Charles work on the details of the compiler and stop pestering him with wiki woki wooki.
James
-
;D
Everything is included in the zip file (almost). It includes the Manual, the Manual generator, the Manual source data and all the code examples used to test the compiler. That is why many of the small examples are a bit arid at this stage. With the source code included the only extras required are "HTML Help Workshop" and FreeBasic 0.21 and you have the complete development system.
My intention is to add Wiki generating capability to the Manual generator and I am reaching a stage where most of the syntax is stable. Unfortunately all of this takes 100% of my capacity so I have to navigate along the development path very carefully.
Charles
-
Everything is included in the zip file (almost). It includes the Manual, the Manual generator, the Manual source data and all the code examples used to test the compiler. That is why many of the small examples are a bit arid at this stage. With the source code included the only extras required are "HTML Help Workshop" and FreeBasic 0.21 and you have the complete development system.
Thanks Charles for confirmation that your documentation efforts are included with the distribution. I will take a peek and see if I can find a quick way to move to the wiki. If you come up with something, let us know so there isn't a duplicate effort.
-
I am going to develop the web pages and try to incorporate some of the material we have produced here on this forum and the thinBasic forum. Web pages are quite fun to do and there is a direct synergy between web site building and manual generation.
Charles
-
Trying to understand things. I went back to SFML and downloaded the C library. I took a minimal window code and made an oxygen basic version. I worked through each problem while compiling, till I got to this problem. I have no idea how to resolve this. It goes through lots of code if you look at the build output window, I don't know what it wants here.
I made a zip file that extracts to a folder kentSFML with everything inside. I just put that folder in the projects window in oxygen and it should be fine. He is using namespaces in c code, I didn't think c had namespaces... maybe it is a new addition?
You can download the zip from:
kentSFML.7z (http://www.kryton9.com/forweb/oxy/kentSFML.7z)
-
Hi Kent
I just download this SFML and unpack files into project folder and try to compile
your test program but not work...
-
I was having problems with it Aurel and asking for help. Sorry you misunderstood and downloaded it.
After sleeping, I see that it is going to be more work than it is worth to convert it over without knowing how reliable it will be.
-
There are 2 paths that I see with OxygenBasic as of 2013 for possible cross-platform non obsolescence.
1. Is write code using the winapi. This allow Linux users to run the programs under Wine. And, via virtual machines or emulators on other platforms.
...not ideal, but it seems to work right now.
2. Use cross-platform c libraries now and when the oxygen c emitter is finished you can compile your programs on the device of your choice.
this to me seems the ideal solution.
Let me know if any of you have other ideas.
Here is a test program written in c using sfml2 c libraries. I will also attach a screenshot of all the sfml2 dlls after they were shrunk via upx.
You don't need to distribute all of them, but just the ones needed. But this will give you and idea of their sizes for all of them.
These libraries will give cross-platform support for windows, 2d accelerated graphics (opengl), truetype fonts, all popular image formats, popular sound formats including ogg.
Joystick and gamepad input and networking.
.