Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Tue Mar 19, 2024 7:58 am

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 

What programmation language do you use with raydium
C 100%  100%  [ 4 ]
C++ 0%  0%  [ 0 ]
PHP 0%  0%  [ 0 ]
Other 0%  0%  [ 0 ]
Total votes : 4
Author Message
 Post subject: C++ comments
PostPosted: Sun Nov 11, 2007 3:01 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
English version at bottom

Salut à tous,

J'étais en train d'essayer d'utiliser Raydium pour faire une petite application. J'ai enfin réussi à le compiler (ne pas oublier de prendre la toute dernière version...).

Je voulais donc faire un petit programme en C pour tester, il se trouve qu'il y a plein de commentaire à la C++ ("//") dans le code et donc ça ne compile pas (gcc -ansi -pedantic -Wall ...).

Serait-il possible de remplacer les commentaires C++ par des commentaires C ( "/*" "*/" ) ? (Je le fais chez moi, mais pouvez vous le faire officiellement ?)

Merci !

Vincent

PS : En tout cas bravo pour le travail déjà effectué

----------------------------------------------
English version:

Hey everyone

I was trying to use Raydium to create a small application. I finally managed to compile it (do not forget to use the latest version...).

I wanted to make a small program in C to test Raydium, but there are a lot of C++ comments ("//") in the code, therefore it doesn't compile (gcc -ansi -pedantic -Wall ...).

Is it possible that you replace C++ comments to C comments ("/*" "*/") in the official version.

Thanks,

Vincent

PS : well done for the already done work


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 10:57 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Hi !

First of all, thanks for your post.
About comments, Raydium is supposed to be used as a library (Shared Object for Linux and DLL for win32), so your coding style and compiler options should not "collide" with our choices.

Are you using the engine with Linux or Windows ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 11:24 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
Hi,

I am using the engine with Linux (withouy the SDK...). I compiled the engine as a shared object and used it in a test program. It works well.

The problem occurs when I try to compile my project with gcc -Wall -ansi -pedantic. It checks for strict ANSI-C syntax. My code is correct, but the header raydium/index.h includes some headers with C++ comments.

I used Vim to correct some files with the command :%s#\/\/\(.*\)$#\/*\1*\/# that replaces C++ comments with C comments. But there were too much files, so I removed the -ansi -pedantic, and my code compiles well.

Is it possible to replace every C++ comment with C comments in our code ? (I know this may not be easy...)



By the way, I have another question, about the textures of the box. I downloaded raydium to a directory and comiled it. I created my project in another directory. But when I run it, it looks for textures for the box. How can I configure where to find these textures ? (I want to put them in a texture directory)

See ya,
Vincent


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 11:37 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
OK, your problem is headers. Missed that point when reading your first message.

This is quiet a big trouble, since (you said it right) there a lot of C99 comments in headers, and, to make thing worst, this syntax is used by the documentation system for doc generation ! :)

Is someone mad enough to start a manual change of headers ? It should be done carefully, and I must then update the raydoc.php script for documentation generation. "Commented comments" (like in raydium/headers/parser.h line 23) should remain as is. If anyone wants to do that job, contact me for an SVN account ...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 11:48 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
I forgot your last question. See the "media path" feature of the engine. In short, create a "texture" directory, and give it to Raydium with raydium_path_add("texture") during init. This is an example, see the doc for more informations, this feature may do even more to help you on this subject.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 2:12 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
Here is a small awk script to change the comments :

Code:
# if we are in a C comment, remember it
$0 ~ /\/\*/ {
    in_c_comments = 1;
}

# if we are in a C++ comment
$0 ~ /\/\// {
    # and not in a C comment
    if( in_c_comments == 0 )
    {
        # embrace with /* */
        sub( /\/\/.*/, "/* & */", $0 );
        # remove //
        sub( /\/\//, "", $0 );
    }
}

# if we are going out of a C comment, remember it
$0 ~ /\*\// {
    in_c_comments = 0;
}

# for every (modified or not) line
{
    # print the line
    print $0;
}


Here is a sample header :

Code:
#ifndef _HEADER_TEST_H
#define _HEADER_TEST_H

//TODO changer ce commentaire

/* celui là est bon */

/*

// celui là aussi
// et aussi celui là
*/

//mais pas celui là


#endif /* _HEADER_TEST_H */


And with the command:
awk -f PATH_TO_THE_AWK_SCRIPT PATH_TO_THE_HEADER_TO_MODIFY

the result is:

Code:
#ifndef _HEADER_TEST_H
#define _HEADER_TEST_H

/* TODO changer ce commentaire */

/* celui là est bon */

/*

// celui là aussi
// et aussi celui là
*/

/* mais pas celui là  */


#endif /* _HEADER_TEST_H */


I let you create a script that modify every header file, but now that shoul be simple.

See ya,
Vincent

PS: I am quite new to awk, may be my script is not the best solution, but it does what we want it to do...

_________________
Try Ubuntu (or Debian)! It is an order!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 4:19 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Interesting ! Two solutions then:

1) We provide your AWK script in the Raydium source tree so users can switch to C comments if they want.
2) We apply your script on all headers, check the result and commit the changes after having having changed the raydoc.php documentation generation script.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 5:46 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
I don't understand why do you have to change your documentation script ? I thought it uses // comments in /* */ comments. But those comments are left intact by my script. May I modify the script for a need I don't know yet ?

So explain me why you need to change your documentation script, so that I adapt mine...

See ya,
Vincent

_________________
Try Ubuntu (or Debian)! It is an order!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 6:51 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
When raydoc.php finds a doc marker (/**), it looks at the previous line, supposed to be a comment (//), a macro (#) or some function prototype.

Quote:
// Introduction
/**
Raydium provides its own atexit function, since Win32 DLL requires a bit
of magic for such things. This support is mainly here for internal reasons,
you can continue to use regular atexit() in your applications.
**/


The current code is probably compatible with start of C comments (/*) but not the end (*/) that will be append to the title "Introduction" in the previous example. So wee need a small check to remove the trailing "*/" when the comments starts with "/*". Nothing impossible, for sure :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 7:46 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
Ok, I look at raydoc.php

Code:
   if($title[0]=="/")
       {
       $type=1;
       $title=trim(substr($title,2));
       }


Should now be replaced by:
Code:
    if( $title[0] == '/' )
    {
        $type = 1;
        $title = trim( str_replace( "*/", "", substr( $title, 2) ) );
    }


But I don't know whether there are other modifications...

See ya,
Vincent

_________________
Try Ubuntu (or Debian)! It is an order!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 26, 2007 3:43 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Sort of. We need to be a bit more distinctive, so we'll remove only the trailing */, and only if the comment started by /*. I'll do it soon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 26, 2007 10:12 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 2:49 pm
Posts: 6
Location: Bordeaux (France)
Don't be in a hurry for me, but I think that it is important to respect norms and standards.

See ya,
Vincent

_________________
Try Ubuntu (or Debian)! It is an order!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 02, 2007 6:34 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
C99 is a standard, isn't it ? :)

edit: raydoc.php modified in rev 588.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group