Beta release 3.1b

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

Post Reply
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I compared the resulting matrix from the glOrtho call and the function above and found a difference which I tried fixing. Please download the beta again.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Ville, ortho camera is working very well also in ES2/GL3 mode now. Thanks!

Question: would it be possible to change the OrthoZoom parameter to use some "better" values? I want to display larger objects (of dimensions several hundredths) and the OrthoZoom parameter is usually set to values 0.000*** (10^-4 - 10^-6). Some larger values would be more practical.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi guys,

Works fine now yes :)
Rado1 wrote:Would it be possible to change the OrthoZoom parameter to use some "better" values?
I wouldn't be opposed to inverting the behavior ( by removing the "1.0/" here ) .. i guess in this case practicality is more important than being conceptually sound.

K
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell wrote: I wouldn't be opposed to inverting the behavior ( by removing the "1.0/" here )
I've made this change now, beta updated.

Btw, it is good that Ortho works now. However I would like to know what the problem really was.

When I did glGetMatrix directly after glLoadIdentity/glOrtho in GL fixed mode I got this:

Code: Select all

((0.64, 0, 0, 0), 
 (0, 1, 0, 0), 
 (0, 0, -0.02, 0), 
 (0, 0, -1.002, 1))
But with my previous Ortho in GL programmable mode I got this:

Code: Select all

((0.64, 0, 0, 0), 
 (   0, 1, 0, 0), 
 (0, 0, -0.02, -1.002), 
 (0, 0, 0, 1))
So I moved the -1.002 to fourth row, third column instead, like this:

Code: Select all

  M[0] := Vector4f(2/m_rl,       0,          0,         p_rl/m_lr);
  M[1] := Vector4f(0,            2/m_tb,     0,         p_tb/m_bt);
  M[2] := Vector4f(0,            0,          2/m_nf,    0);   //<<- moved "p_fn/m_nf" from this line
  M[3] := Vector4f(0,            0,          p_fn/m_nf, 1);  //<<- to this line changed
However all references I can find on glOrtho indicates that the first implementation is correct. What is going on here? :D
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:facepalm
VilleK wrote:What is going on here? :D
Can't believe i didn't notice this earlier .. but you're assigning Vector4's per column, which essentially "rotates" the layout of elements in your source. In other words, this is the correct matrix ..

Code: Select all

M[0] := Vector4f(2/m_rl   ,         0,         0,         0); 
M[1] := Vector4f(0        ,    2/m_tb,         0,         0); 
M[2] := Vector4f(0        ,         0,    2/m_nf,         0);
M[3] := Vector4f(p_rl/m_lr, p_tb/m_bt, p_fn/m_nf,         1);
.. but your version already worked because "p_rl/m_lr" and "p_tb/m_bt" are always 0 anyway.

K
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Ah, of course. I thought I had checked that already. Facepalm indeed. Thanks for explaining!
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Updated today.

- Fixed the division by zero problem reported by Rado1

- Added support for declaring global variables directly in ZLibraries (as an alternative to using Variable-components).

For example, this is now valid syntax:

Code: Select all

//These are global variables
int x;
int[5,5] xx,yy;
string s;
string[10] ss;

void f() {
  //The global variables can be used in functions or anywhere in the application (after they have been declared)
  x=0;
  xx[0,0]=42;
  s="hugo";
  ss[0]="test";
}
Download here: http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Auxiliary global variables put to ZLibrary is quite a useful concept if used for internal processing accessible mainly by a facade of functions. Variable components can then be used just for important global variables commonly used in other components. This would make a project more comprehensive.

Does it make sense also to declare usually used local iterators and variables as global? For instance, iterator i in for(int i; ...) to be global, so each expression with such a command does not need to declare its local variable. What's the runtime processing overhead of declaring local variables? Are they allocated each time a ZExpression is running, or are variables pre-allocated and reused each time an expression is running?
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:Does it make sense also to declare usually used local iterators and variables as global?
Nah, the overhead is neglectable .. and you don't want to ( accidentally ) run into situations where both a function and the scope from which that function is called use the same global variable.

Even when coding in assembly for 8-bit systems you generally keep a stack ( virtually all CPU's support it on a hardware level anyway ), it's simply not worth it.

K
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Declaring global variables directly in the code also makes it easier to convert OpenGL examples from C, this was the main reason I implemented the feature.
Rado1 wrote:Does it make sense also to declare usually used local iterators and variables as global?
Not really, because local variables are accessed faster than globals.

edit: what Kjell said.
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Small maintenance update:
- Fix for bug reported by Kjell when inserting items from "Add from library"
- Temporary hide hints while app preview is active as workaround for render problem experienced by Rado1

Download here: http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Returning back to an older request of Jph, would it be possible to build ZGE application as android live wallpaper?
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Rado1 wrote:Returning back to an older request of Jph, would it be possible to build ZGE application as android live wallpaper?
The problem is that last time I checked the docs for Live Wallpaper it required very different Java-classes and manifest file compared to when making a normal App. So we would need to have two sets of Java code etc which is a maintenance problem. Maybe it is easier now, if you find any resources on the net on how to convert an app to live wallpaper please post it here.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Of course Ville, live wallpaper would require different generating of the android building directory with different manifest file, res/xml directory for wallpaper description xml file, java class for wallpaper service instead of activity class, etc.

There's an example of creating OpenGL live wallpapers with GLWallpaperService. Some explanation can be found also here. Another explanation how to make OpenGL ES live wallpaper here. I'm not sure it can be useful for you.
User avatar
VilleK
Site Admin
Posts: 2371
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

GLWallPaperService looks potentially like it would work to adapt the existing ZGE Java classes (Zge.java and ZgeActivity.java) to use that instead. I'm up to my neck in other work at the moment though so I don't have much time to investigate. But if you or anyone else feel like trying it out I can help if you get stuck.
Post Reply