Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

EDGELib try for iPhone


EDGELib try for iPhone

Postby Orion_ » Jan 28, 2009 @ 5:02pm

Hello,

I'm currently trying EDGELib before buying it for an iPhone game project.
I've some troubles with the sound engine, using hekkus on PC with VC++2008 I've a delay of 1 second before the sound actually plays using ecd.snd->PlaySound(0);
On the iPhone side I've 2 malloc/free error showing in the console when exiting the application whenever I use the ecd.snd->Open(); function and even if I do not call ecd.snd->Close(); (The error is about freeing not aligned pointers)
Also, I've a question about 2DSurface, Is there any function or trick to use paletted surfaces and with the ability to dynamically change or swap some colors of the palette ?

Thanks.
Orion_
pm Member
 
Posts: 20
Joined: Jan 28, 2009 @ 4:51pm
Location: Paris, France


Postby edge » Jan 29, 2009 @ 8:46am

Hi Orion,

If Hekkus doesn't work for you, I recommend using OpenAL. Also, your PC build will be more similar to the iPhone version (that also uses OpenAL) this way. You can remove the memory error by editing the OpenAL wrapper. Remove these lines (they are in ESound_Close and ESound_FreeDriver):

Code: Select all


delete driver;
delete ctx;
2 lines; 2 keywds; 0 nums; 2 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  



For paletted surfaces you can do several things. The first is running into a simulated palette display mode (which can be slow on the iPhone, also you can't use OpenGL).

Another method is by loading surfaces as palette, and another temporary surface in true color mode. When blitting the loaded surface to the temporary surface, it will do a color conversion and read the display palette. You can alter the display palette by using ClassEDisplay :: SetPalette.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Orion_ » Jan 29, 2009 @ 1:01pm

Thank you !

That fixed all my problems :)
Orion_
pm Member
 
Posts: 20
Joined: Jan 28, 2009 @ 4:51pm
Location: Paris, France


Postby Orion_ » Feb 9, 2009 @ 3:54pm

Hi again,
Finally I've switched to OpenGL ES because the palette mode or even the default framebuffer mode was too slow on iPhone.
So, my question is, how can I do some realtime tint or color change with BltFast with OpenGL ES ?
Or something like that for the DrawFont function for example, the default edgelib internal font is White, how can I draw text using another color ? I tried glColor3f but it does nothing :/

edit: Another question, is there any function to unload a texture uploaded with display->UploadTexture function ? can my_surface.Free(); do the job ?

edit2: I noticed that the orientation flag doesn't work in OpenGL mode. Do you plan to implement it ?

Thanks.
Orion_
pm Member
 
Posts: 20
Joined: Jan 28, 2009 @ 4:51pm
Location: Paris, France


Postby edge » Feb 11, 2009 @ 9:07am

Hi Orion,

Using the OpenGL function glColor3f is the correct way to handle this. You also need to change the texture drawing mode with the following function:

Code: Select all

glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1 lines; 0 keywds; 0 nums; 5 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


This will blend the texture with the OpenGL color value. Don't forget to change it back afterwards, otherwise the rest of the rendering could go wrong.

Regarding your other questions:
- Yes, when freeing the surface it also de-uploads it from OpenGL
- Changing orientation in OpenGL is planned for one of the upcoming EDGELIB releases
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Orion_ » Feb 11, 2009 @ 12:13pm

I tried glTexEnvx and it doesn't work, at least on PC using glTexEnvi

My code is like this:
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
in OnDisplayInit:

display->CreateSurface(...
display->UploadTexture(...

#if defined(DEVICE_IPHONE)
    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#else
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#endif

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);


in OnNextFrame:

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    display->Perspective2D(SCREEN_WIDTH, SCREEN_HEIGHT, false);
    display->SetShading(E3D_TEXTURE);

    display->BltFast(...

    glColor3ub(0, 255, 0);
    display->DrawFont(16, 400, &display->fontinternal, "test");
25 lines; 5 keywds; 5 nums; 71 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


either glColor3ub/glColor3i/glColor3f or specifying glTexEnvi before the createsurface/uploadtexture, doesn't change anything to the render :(

can you tell me around when the next release of edgelib with opengl orientation support will be released ?
because this option is really useful and would save me a lots of time, else I would have to do it myself :/
Orion_
pm Member
 
Posts: 20
Joined: Jan 28, 2009 @ 4:51pm
Location: Paris, France


Postby edge » Feb 12, 2009 @ 9:55am

Hi Orion,

Please try the following sample for colored blending. It works in our applications:

Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
#if defined(EGL_USEGL)
    #if defined(DEVICE_DESKTOP)
        glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    #else
        glColor4x(65536, 0, 0, 65536);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    #endif
#endif
display->DrawFont(0, 0, &display->fontinternal, "Hello");
#if defined(EGL_USEGL)
    #if defined(DEVICE_DESKTOP)
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    #else
        glColor4x(65536, 65536, 65536, 65536);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    #endif
#endif
19 lines; 14 keywds; 26 nums; 71 ops; 1 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  


The orientation fix will probably be added in EDGELIB 4.0. Unfortunately, we can't give an estimate on the release date (first a 3.96 version will be released soon). In the meantime, it's best to handle the display rotation in OpenGL directly using the following sample:

Code: Select all


glTranslatef(480.0f, 0, 0);
glRotatef(90.0f, 0, 0, 1.0f);
2 lines; 0 keywds; 10 nums; 14 ops; 0 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby Orion_ » Feb 27, 2009 @ 11:10am

Just a quick question, I was surprised that all the graphics I was displaying on iPhone device with edgelib was converted to 16bits, I thought that the iPhone screen was actually 16bits, then I tried to draw a texture using native iPhone SDK code and the graphics appeared smooth like if it was 24bits, so I found a flag to change in EDGELib to get the same result, and it worked but I don't know if it's the right way to do it and if it's not getting slower because of this flag (even if it's rendered using OpenGL)
here is what I used in the OnDisplayConfig function:
config->emulvideotype = EDSP_TRUE32;
config->videotype = EDSP_TRUE32; // not sure if this one is effective
Orion_
pm Member
 
Posts: 20
Joined: Jan 28, 2009 @ 4:51pm
Location: Paris, France


Postby edge » Mar 2, 2009 @ 9:48am

Hi Orion,

The best solution to force your textures in a specific color format, is to specify it in the CreateSurface call. Pass EST_DSPTRUE32_INV as the flag parameter.

Using EST_DSPTRUE32_INV is faster than EST_DSPTRUE32, because it swaps the red and blue color channels when loading the image (to make it in the same internal format as OpenGL).
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

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