Tnx to all........

I wanted to thank everyone who has helped me learn the basics of Opengl. My game is progressing rapidly now. I expect it to be complete within 6 months, and I will most probably not need to visit this site for at least 3 months.

If any member of this site is interested in the Game , I will be glad to send it to you. Just email me at zadeh79@hotmail.com

The game, “Stone of Arenius”, is of the Adventure/RPG type, and is reminicint of old-school classics such as NES/SNES ZELDA and FINAL FANTASY SERIES.

HERE ARE A FEW IMAGES…

GAME IMAGE 1

GAME IMAGE 2

GAME IMAGE 3

I am interested in the source code, if it still looks like it did, then I am going to use it as an example “how not to use OpenGL” :slight_smile:

zadeh79:
These images require acount at myspace to view. Can you do something about it?

Zengar:
Why don’t you dig some of your own old code? My archive would be full of “how not do do it” examples if I had old files in it. :smiley:

In the meantime you can have a look at my current coding practices. Perhaps you will have a suggestion or two for me? This is part of my framework, but I think I’ll just release these vector classes separately:

template <typename T1> class vec2t;
template <typename T1> class Swizzle2
{
protected: T1 _X, _Y;
};

#define VEC2TEMPL_OPERATORS_DECL1 \
vec2t<T1> operator=(const vec2t<T1>& src); \
vec2t<T1> operator+=(const vec2t<T1>& src); \
(...)

#define VEC2TEMPL_SWIZZLE_DECL1(a,b) \
template <typename T1> class Swizzle2 ## a ## b : public Swizzle2<T1> \
{ \
public: \
  VEC2TEMPL_OPERATORS_DECL1 \
  operator vec2t<T1>(void); \
};
#define VEC2TEMPL_SWIZZLE_DECL2(a) VEC2TEMPL_SWIZZLE_DECL1(a,X) VEC2TEMPL_SWIZZLE_DECL1(a,Y)
#define VEC2TEMPL_SWIZZLE_DECL VEC2TEMPL_SWIZZLE_DECL2(X) VEC2TEMPL_SWIZZLE_DECL2(Y)
VEC2TEMPL_SWIZZLE_DECL

#define VEC2TEMPL_SWIZZLE1(v1,v2,v3,v4,v5,v6,v7,v8) \
Swizzle2 ## v1 ## v5 <T1> v2 ## v6; \
Swizzle2 ## v1 ## v5 <T1> v3 ## v7; \
Swizzle2 ## v1 ## v5 <T1> v4 ## v8;
#define VEC2TEMPL_SWIZZLE2(v1,v2,v3,v4) VEC2TEMPL_SWIZZLE1(v1,v2,v3,v4,X,x,r,s) VEC2TEMPL_SWIZZLE1(v1,v2,v3,v4,Y,y,g,t)
#define VEC2TEMPL_SWIZZLE VEC2TEMPL_SWIZZLE2(X,x,r,s) VEC2TEMPL_SWIZZLE2(Y,y,g,t)

template <typename T1> class vec2t
{
public:
  union
  {
    struct
    {
      T1 x, y;
    };
    struct
    {
      T1 r, g;
    };
    struct
    {
      T1 s, t;
    };
    VEC2TEMPL_SWIZZLE
  };
(...)

That’s fragment of my vec2.h file. Guess (or work it out if you prefer) what it does… :slight_smile:
I’m still working on it - implementation is in asm, since I want to replace all unnecessary stuff that compiler would put in my code with my own unnecessary stuff :smiley:

I am so lucky I don’t work with C++ :eek:

To be honest, I don’t see what your code is supposed to do (but I can guess :wink:

Zadeh posted his code quite often, just look for it. It is a jewel. Not that I want to insult him, just a bit of sane irony.

:slight_smile:
The code I posted here actually generates class template.
The result is, that you can use GLSL’s vec2 directly in C++ application - the fragment above defines vec2t template which then I use to create GLSL’s vec2 and ivec2 types, so in your C++ application you can just use:

vec2 a = vec2(1.0f, 2.0f);
vec2 b = vec2(3.0f, 4.0f);
b.yx += a.yy + b.gr;

So, I say that I’m lucky to work with C++. What other language would let me define syntax I want to use?

Note that this example is vec2 class. With vec4 class number of operators (about 20) multiplied by number of possible swizzlers (xxxx+xxx+xx+no swizzler = 256+64+16+1 = 327) gives thousands of functions to implement, which I’m capable to put into 300-400 lines of code.

Ok, but we’re getting off topic. I just wanted you to have some laugh.

>What other language would let me define syntax I >want to use?

Boo with it’s syntax macros. But you are right, your code is quite effective. Still, I find C++ very erratic.

> I just wanted you to have some laugh.

I got it :smiley:

Yep, the images load now…

I must disagree a little bit with both zadeh79 and k_szczech (mostly with zadeh79).

Shortest comment first, for k_szczech:
Your piece of code there is a nice bit of C++. I really think so. This shows the power of the language in a brilliant way. The problem I have with this power is that it sometimes becomes hard for people to work together, because the “unlimited” control makes it hard to read other’s code. And having large projects means having very, very strict rules for coding practices. Not saying you should simplify your code for my sake! But I do agree a little bit with people who say that some functionality in C++ is over the top (there is a reason why you cannot overload operators for builtin types, imagine the chaos…). By the way, is assembler hacking not terrible for portability? :slight_smile:

zadeh79, knowing your language IS important. There are many caveats in a language such as C++. Take pass-by-value/pass-by-reference for instance. A lot of people miss that one. I am not going to ramble on. If you have the creative part of coding going for you, there is a lot for you to collect by learning the language properly!

Hrm… the shortest turned out to be the longest.

the “unlimited” control makes it hard to read other’s code
Imagine that you write documentation for vec3 class. You can write that you can use the following operators:

And having large projects means having very, very strict rules for coding practices
Have you looked at STL implementation? Most of people using it would have problems understanding that source code, but it’s usage is easy. And that’s the idea behind these vector classes - to provide a class that’s easy to use and gives good performance - no compromises here.

By the way, is assembler hacking not terrible for portability? :slight_smile:
Well, it’s 32-bit x86 assembler - it’s compatible with anything starting from 386 with FPU.
Sure if I want to switch to other platforms (consoles, etc) it will require replacing a few blocks of assembler code, but there aren’t many of them and they’re all about 10-15 instructions long and that’s thanks to these macros.
I’m using Visual C++ 2003 Standard, which has no optimizations in compiler. My own asm code is 3-4 times faster that equivalent code produced by my compiler. Need to say more? :slight_smile:

In the case of STL, I agree that the implementations are complex (template me to hell and back…), but they are hidden behind intuitive (well not always…) interfaces. Further, even though STL is easy to use, it is not always easy to maximize its potential and speed. This is why many books have been written on the topic.

Look, I am not saying that documentation and coding practices are important everywhere. For instance, if you are making a library that very likely you are the only one who will ever use, the need for documentation is obviously a lot less than for public libraries.

Back to swizzling: In this case you are actually trying to implement a syntactical feature of C++ that doesn’t exist previously. One would expect this to require some effort, but of course short-cuts are good if possible. By the way, why do you need shader syntax in your main program? Is it a GPU emulator? Given that GLSL has far less functionality than C++, why would you want to emulate a weaker language in a stronger one? Why not wait until GLSL becomes object-oriented etc. and shaders will look like C++ code instead… :slight_smile:

All I am saying is that there is a trade-off between complexity, extendability and readability. Making the right design choices are important. In later stages of development readability probably becomes less important though…

This thread is no horribly of topic… :slight_smile:

Zadeh, I am not talking about C++ coding style, although I find it important. I am talking about such things as drawing and coding efficiency. You were(are?) using the system in one of the most inefficient ways. Your character drawing code is a horrible thing, as well as your loading code! Have you ever heard of procedural programming? My guess is just that you have no good knowledge of programming in general and OpenGL in particular, actually it appeared to me as you were to lazy to read tutorials. I have a habit to study how the library I am going to use works before I start a project, from what I have seen, you start coding right afraid without even thinking about the design.

There is one thing my math teacher in the school liked to say: “There are two possible ways to scratch your nose, you can just lift your hand and do it, or you can wring your arm around your head and try to reach it”. I guess you prefer the second way.

Well, I don’t want to insult or or anything, I just find it common sense to have a minimal design in your code, and you have none. On the other hand, I had a friend one who was a true mathematical genius (no kidding here) and he wrote even more horrible programs. He didn’t use line breaks at all! But his programs worked, it’s true :slight_smile: Well, have luck and fun with your game, don’t take me too seriously, I hope you are not angry or something.

you start coding right afraid without even thinking about the design.
Now where do I know that from… My first programs were badly designed, too. Perhaps I didn’t have such obvious code structure errors, but still I remember I thought that moving forward in 3D game can be implemented through zooming :smiley:

In the case of STL, I agree that the implementations are complex (…), but they are hidden behind intuitive (…) interfaces. Further, even though STL is easy to use, it is not always easy to maximize its potential and speed.
These vector classes I present are hidden behind GLSL-style syntax. They’re easy to use and they do increase speed.
Whoever wants to use my classes only need to put one #include in his code and he can use vec3, ivec3 and other types known from GLSL like they were built in C++ types without having a single look at my header file or any documentation whatsoever (assuming he knows GLSL).

why would you want to emulate a weaker language in a stronger one? Why not wait until GLSL becomes object-oriented etc. and shaders will look like C++ code instead…
Now wait just a minute! :slight_smile: What makes you think I’m trying to write my applications in GLSL? :eek:
The only thing I do is to take GLSL’s built in vector and matrix types and make them available in C++ applications. That’s what object-oriented programming is for - to create your own types and operators to make your application code look cleaner and more high-level.

Look at it this way - every (reasonable) engine has vector and matrix classes. The question is what will they look like? Mine will look exactly like these we all know from GLSL.
Look at vector classes in Ogre or Crystal Space. They’re pure C++. When I compile Ogre, Crystal Space or ODE on my compiler I’ll get a bit slow code.
Also, they don’t support swizzlers. When working on my game I found swizzlers to be usefull in C++ application, so I thought vector class should have them.

This is why I want to release these classes when I’m done - I believe many people will find them usefull. Especially if I add type casters for OGRE and Crystal Space vectors.

Uh, ok…

k_szczech: If you decide to release the basic LinAlg of your library I would be very interested! :slight_smile: I looked at your boat game and it looks really nice btw…

zadeh79: Is it not also so that if you want to help humanity intellectualy, then you must know exactly what is already known, in order to avoid reinventing the wheel? Trying to come up with everything yourself is both arrogant and time-consuming.

“Is it not also so that if you want to help humanity intellectualy, then you must know exactly what is already known, in order to avoid reinventing the wheel?”

Read between the lines…

“Trying to come up with everything yourself is both arrogant and time-consuming”

Yeah, for certain people that might be true. And not trying to come up with anything yourself, may be cowardly and lazy.

Seems like thinks understands zadeh79’s philosophy as:
1.“not trying to come up with everything yourself, may be cowardly and lazy”
This is why he wrote:
2.“Trying to come up with everything yourself is both arrogant and time-consuming”

Seems like zadeh79 wanted to state that this is false:
3.“Trying to come up with anything yourself is both arrogant and time-consuming”
This is why he wrote:
4.“not trying to come up with anything yourself, may be cowardly and lazy”

I think you’ll all agree that:

  1. false
  2. true
  3. false
  4. true

And since #1 is not what zadeh79 had in mind then why did thinks presented opinion opposite to #1?
And since #3 is not what thinks had in mind then why did zadeh79 presented opinion opposite to #3?
:smiley:

This topic got pretty entertaining, but that’s a good thing - having some laugh is what kept me going yesterday, when I spent 25 hours at work…

“When I compile Ogre, Crystal Space or ODE on my compiler I’ll get a bit slow code.”

They are open source/free stuff so performance is not always the best with such software.

I had been using ODE and the philosophy was “let the compiler generate the SSE code”
Unfortunatly, it was still terribly slow while NovodeX is ultra tuned up and costs money and I don’t need to compile it.

You might write great code and release it but most other OSS stuff is not optimized.

Ogre:
I asked on the forums why it generated GL errors relating to FBO. One of the principal coders gave an argument about that’s how it does some tests.

Later I asked why it is so slow. The response was ATI sucks. They make many redundent GL calls so I think it’s Ogre’s fault.

Later, I asked why does the skinning shader show problems on ATI. They were using ARB_vp/fp stuff.
It’s suppose to be a ATI bug.

The fact is, I have seen other skinning examples and they work fine on ATI, using GLSL or those older interfaces.

So if it doesn’t work well, I can’t use it.

k_szczech: How long are your days over there? 25 hours? :slight_smile: Sounds more like two days to me…

You have the philosophy wrong. We don’t agree according to your list of four. I think instead the point is that we think that our own statements are true, and the other’s are not, hence the conflict. Anyway, I am not the one to try to push philosophy onto someone else, everyone is free to have their own. So the discussion seems a little pointless… It was fun though! :slight_smile:

I had been using ODE and the philosophy was “let the compiler generate the SSE code”
Unfortunatly, it was still terribly slow while NovodeX is ultra tuned up and costs money and I don’t need to compile it.
I try to write these classes in pure asm with C++ interface and I don’t mean C++ layer over asm code.

So if it doesn’t work well, I can’t use it.
That was the thought that got me to write my own vector and matrix classes.
Most of these were in pure C++ and therefore relied on compiler. A good compiler will produce better code than average programmer, since it can optimize for out of order execution and other CPU features. Unfortunately, some compilers can generate unnecessary code by calculating field address in class, creating temporary objects and then using copy constructors to return these objects and blindly adding prolog/epilog to every method.

As for SSE I intend to add it later. Right now I want to finish vectors and release them for test drive. Then matrices. I’ll create a topic and we can discuss these classes there. Revealing source code is often the best way to improve it. I guess I’ll learn a thing or two after some comments.

For now, I assume it makes not much sense to discuss this further, until I actually release it.