View Full Version : Tnx to all........
03-04-2007, 05:01 PM
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 firstname.lastname@example.org
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 (http://alkaspace.com/is.php?i=15478&img=stones.JPG)
GAME IMAGE 2 (http://alkaspace.com/is.php?i=15479&img=stones1.JPG)
GAME IMAGE 3 (http://www.alkaspace.com/is.php?i=15480&img=stones3.JPG)
03-05-2007, 03:11 AM
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" :-)
03-05-2007, 04:02 AM
These images require acount at myspace to view. Can you do something about it?
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. :D
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> \
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)
#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
T1 x, y;
T1 r, g;
T1 s, t;
(...)That's fragment of my vec2.h file. Guess (or work it out if you prefer) what it does... :)
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 :D
03-05-2007, 04:16 AM
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 ;)
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.
03-05-2007, 06:43 AM
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.
03-05-2007, 11:39 AM
>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 :D
03-05-2007, 05:39 PM
SORRY ABOUT THE IMAGES, TRY VEIWING THEM NOW...........
Zengar, I don't usually care for my OGL (or C++) etiquitte. There are many practices that appear only theoretically beneficial (for example, the use of pointers or avoiding globals); advantages in a minute percentage of scenerios. I also believe that understanding these practices, in itself, does not make one a 'good programmer'. When I code, I often find my self finding solutions to arcane problems (such has how to generate a shadow without matrix manipulation), problems that require deeper insights, and may demand knowledge from the fields of mathematics and physics. In my mind, this is the 'other' qualifier for being a 'good programmer'. Basically, being able to use 'whatever you know' to solve a complicated problem (real problems, of course, do not have obvious solutions).
Of course, this all isn't to say that I don't respect coders with more formal knowledge of a language.
03-06-2007, 01:55 PM
Yep, the images load now..
03-06-2007, 03:17 PM
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? :-)
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.
03-06-2007, 04:59 PM
the "unlimited" control makes it hard to read other's codeImagine 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 practicesHave 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? :-)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? :)
03-06-2007, 06:17 PM
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... :)
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... :)
03-07-2007, 01:47 AM
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 :-) Well, have luck and fun with your game, don't take me too seriously, I hope you are not angry or something.
03-07-2007, 02:44 AM
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 :D
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! :) 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.
03-07-2007, 07:59 PM
No Zengar, I am not insulted, neither was I trying to insult you or anyone else....I was just trying to make a broader point. I do understand that having knowledge of the formal rules and procedures of programming may fuel any potential creative ability that becomes so often necessary in finding solutions. This creative ability, as I have stated, is what is to me the essence of a 'good programmer' (as well as the most powerful indicator of human intellectual productivity - as creativity requires the highest powers of abstraction). But it is a common assumption of many self-proclaimed 'experts', throughout all scientific fields, that having sufficient knowledge of any subject, is the sole qualifier for 'expertise'. This is certainly ridiculous, since the majority of significant advances of the human species has required some peculiar pattern of thoughts, and of course, knowledge in itself can not provide us with such thoughts. Believe it or not, learning that all men are mortal, and learning the fact that I am a man, does not entirely explain the process of deducing.....that I will one day die.
But what exactly are the other processes involved in drawing such conclusions? It is interesting to know that cognitive scientists have recently discovered a new role for GLIAL cells....the aid of synaptic transmission. Thus, any conventional models for human thought and learning have been proven, at least, incomplete, if not entirely wrong. In more detail, the seperate and distant neuronal circuits (which store knowledge) communicate via glial bodies. (Thus, it is glial cells that, in part, allow me to conclude...that I will one day die). WOW, this explains E.L. Thorndike's 0 correlation between power and altitude around 70 years go, and the loss of correlation between stimulus complexity and RT (reaction time, which is the best indicator of general intelligence when stimulus complexity is minimum).
So what is my point exactly.......the average high school teacher should stop confusing themselves with the likes of Richard Feynman, that society shouldn't be as biased in favor of those demonstrating lower powers of analysis, and that human intelligence is most likely a state function ,which no conventional test can measure.
I usually do not learn the best by reading books or going through tutorials, but rather prefer seeing examples that are set to simple scenerios with analogies used for clarification.
03-08-2007, 06:51 AM
03-09-2007, 05:27 AM
k_szczech: If you decide to release the basic LinAlg of your library I would be very interested! :) 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.
03-09-2007, 07:19 PM
"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.
03-10-2007, 07:45 PM
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:
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?
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...
03-10-2007, 09:17 PM
"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.
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.
03-12-2007, 05:35 AM
k_szczech: How long are your days over there? 25 hours? :) 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! :)
03-12-2007, 07:22 AM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.