OpenGL Coverflow

Discuss any 3rd-party tools and code that may be of interest to other Juce users

Re: OpenGL Coverflow

Postby maxprod » Tue Jan 19, 2010 5:23 pm

jules wrote:Thanks Max, you've been posting some impressive stuff! Nice job on the UI!


Yes jules ;) Thanks a lot ... If the boss say that's nice, I'm proud!

Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby alimjan » Tue Jan 19, 2010 5:39 pm

Hi! Very nice idea and perfect examlpe. But I've found some strange behavioral on my PC, it's a Asus G1S with Windows XP + SP3. So, when i ran your example, precompeled (i've try build CoverFlow myself, the same results) .exe, i've notice that the CPU useage reaches 50% (dual core - 1 CPU its a 100%).. And it is strange, that 50% usage when i do not touch the app, e.g. not moving a mouse or dragging images in the cover. During application manipulation, CPU usage goes down, then it is going to 0 and then with a few seconds of IDLE reaches 50% (100% for single CPU).
May be i'm doing something wrong? :(

Bye..
Thanks to Jules for The Juce.
User avatar
alimjan
JUCE Geek
 
Posts: 42
Joined: Sat Dec 05, 2009 6:08 pm

Re: OpenGL Coverflow

Postby maxprod » Tue Jan 19, 2010 5:59 pm

@alimjan

Take a look at the thread part of CoverFlowContext :

Code: Select all
//=============================================================================
void CoverFlowContext::start ()
{
   startThread (5);
}
//=============================================================================
void CoverFlowContext::run ()
{
   while (!threadShouldExit())
   {
      Thread::sleep (jlimit(10, 100, roundFloatToInt(_threadLatency-(_ticks-_moveTicks))));

      /* MessageManagerLock is absolutly needed here !
         because we call repaint() */
      const MessageManagerLock mmLock (Thread::getCurrentThread());

      if (!mmLock.lockWasGained())
         return; // another thread is trying to kill us;

      _ticks = Time::getMillisecondCounterHiRes ();

      /* refresh the OpenGL context */
      repaint ();

      // Compute distance between current cover and selected
        double dx = _selected - _current;

      if (dx != 0 && (_ticks-_moveTicks) > EFFECT_SPEED)
      {
         // Move the current cursor
         if (jabs(dx) > 0.001)
         {
            _current += dx / 15;
         }
         else
         {
            _current = _selected;
         }

         // Record last tick
         _moveTicks = Time::getMillisecondCounterHiRes ();
      }

      if (_animSelected > 0)
      {
         if (_ticks - _ticksSelected > EFFECT_SPEED_SELECTED)
         {
            _animSelected += 5;
               // is the end of animation ?
               if (_animSelected > 100)
               _animSelected = 0;
               _ticksSelected = Time::getMillisecondCounterHiRes ();
         }
      }
   }
}
//=============================================================================


That use a intensive UI repaint. Maybe my computers are very powerfull (I think not) and don't see a problem with that ? Don't know ?

Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby alimjan » Tue Jan 19, 2010 6:08 pm

Hm.. Strange to me :( When minimizing the app, it is true that CPU usge goes down to 0. But when it is active, e.g. window active? In my tests i'm using ProcessExplorer from sysinternals.com. ProcessExplorer placed in background, Coverflow is on the foregraound, so i'm able to see CPU usage when manipulatin the app. So, hm, i guess i'm wrong.. By the way, it is 4 threads i've notice in the Coverflow. May be some one else post their results?
Thx.
Thanks to Jules for The Juce.
User avatar
alimjan
JUCE Geek
 
Posts: 42
Joined: Sat Dec 05, 2009 6:08 pm

Re: OpenGL Coverflow

Postby maxprod » Tue Jan 19, 2010 6:12 pm

alimjan wrote:By the way, it is 4 threads i've notice in the Coverflow.


Surely some Juce & OpenGL thread. What are their names ? The only one I start myself is simply called "CoverFlow" :

Code: Select all
//=============================================================================
CoverFlowContext::CoverFlowContext ()
:   Thread (T("CoverFlow")),


Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby alimjan » Tue Jan 19, 2010 6:20 pm

Thanks for reply. Names? Not checked, right now i'm on the different machine and OS.. I remember that is offset of the Thread "routine" (that thread that ate so much) begans with 0xf... I'll try to check more closely. maxprod, i saw some of your post with empressive UI (LookAndFeel) is that your design(code)? Would you be so kind to post a source code, if that is possible ? Or may be some snapshots? Thank you a lot.
Thanks to Jules for The Juce.
User avatar
alimjan
JUCE Geek
 
Posts: 42
Joined: Sat Dec 05, 2009 6:08 pm

Re: OpenGL Coverflow

Postby vishvesh » Tue Jan 19, 2010 6:24 pm

maxprod wrote:
vishvesh wrote:Looks like I have got a bug for you.
http://i50.tinypic.com/2lnverm.jpg

Unfortunately I still haven't been able to get it working.


Yes, this is a strange problem ? Don't have time to search why because i've a lot of development to do. But I think it's a OpenGL initialization problem. Maybe i call some texture loading not in time. If someone read that and found solution, you can post here and will update the project with a correction patch.

Sorry for you man :(

Regards,
Max


The posts are growing at exponential rate now!!!!!!!!!!!!!

I intend to install Visual Studio and get working on this issue.
Best Regards,
Vishvesh
User avatar
vishvesh
JUCE UberWeenie
 
Posts: 504
Joined: Fri Aug 01, 2008 10:16 am
Location: Bangalore, India.

Re: OpenGL Coverflow

Postby maxprod » Tue Jan 19, 2010 6:35 pm

alimjan wrote:maxprod, i saw some of your post with empressive UI (LookAndFeel) is that your design(code)? Would you be so kind to post a source code, if that is possible ? Or may be some snapshots? Thank you a lot.


Yes, all of the UI are from my current work. For now, I don't have a clear LookAndFeel to publish, first because I use multiple short LookAndFeel for some parts of the UI, and second because this is the actual look of my app. As i've say, I've found a good graphist (because I don't like my own work :)) to design with me. When the UI will be redesign, I will publish some of my old code. If you need something in particular, maybe I can help you, but not more for the time.

vishvesh wrote:The posts are growing at exponential rate now!!!!!!!!!!!!! I intend to install Visual Studio and get working on this issue.


Hé,hé ... vishvesh ! You're the man !!!

Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby Dub » Tue Jan 19, 2010 11:02 pm

Hi Max,

OK, I still don't have a working app, but I may have a (little) clue.
If I resize the app, I (sometimes) see a quick flash of an album cover image (it's very brief - much less than a frame's worth) - Does this help at all?

Could it be that the white "background" is over writing the display or "always on top" or something? -
Dub
Dub
JUCE UberWeenie
 
Posts: 158
Joined: Wed Jun 28, 2006 10:45 pm
Location: London

Re: OpenGL Coverflow

Postby maxprod » Tue Jan 19, 2010 11:16 pm

Dub wrote:Could it be that the white "background" is over writing the display or "always on top" or something? -


Hi Dub,

There's no white background filled by my app. But I have had this thing during coding. Maybe you can add a little temporisator (few seconds) in the CoverFlowContext constructor (or CoverFlowOpenGL, that's the same). I'm pretty sure that come because OpenGL is long to init on certain graphics cards.

Let me know,
Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby Dub » Wed Jan 20, 2010 3:05 am

I've sent you an e-mail with what I see (in case it helps)
Dub
Dub
JUCE UberWeenie
 
Posts: 158
Joined: Wed Jun 28, 2006 10:45 pm
Location: London

Re: OpenGL Coverflow

Postby maxprod » Wed Jan 20, 2010 3:18 am

@Dub

Ok, i see. Try to comment :

Code: Select all
drawBackground ();
&
drawForeground ();

in CoverFlowOpenGL void repaintGL ();

Maybe it's a problem with the 2D textures initialization in :
Code: Select all
GLuint CoverFlowOpenGL::loadTexture (Image* textureImg);
&
GLuint CoverFlowOpenGL::loadTextureAlpha (Image* textureImg);

Try to find information about : GL_BGR_EXT & GL_BGRA_EXT for the color mode in OpenGL :
Code: Select all
glTexImage2D  (GL_TEXTURE_2D,
            0, 4, textureImg->getWidth(), textureImg->getHeight(),
            0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,
            pixels);
A little test by inverting BGR to RGB & BGRA to RGBA will probably resolve your problem. Let me know

Regards,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby zamrate » Wed Jan 20, 2010 1:05 pm

just tried the exe on XP pro, get the same white area. I haven't checked the sources, but I do remember that I had some problems like that too when I started messing around with the OpenGLComponent of JUCE. Don't remember what it was (I did a special Timer Thread for the OpenGL for ultra-smooth animations, so it was kind of a special case there).. I eventually got it fixed.
User avatar
zamrate
JUCE UberWeenie
 
Posts: 1082
Joined: Mon Sep 24, 2007 5:33 pm

Re: OpenGL Coverflow

Postby maxprod » Wed Jan 20, 2010 1:10 pm

zamrate wrote:I eventually got it fixed.


Hi zamrate,

All fixes are welcome ! If you find a solution about that, I will update the sources and the project.

Thanks man,
Max
User avatar
maxprod
JUCE UberWeenie
 
Posts: 100
Joined: Fri Mar 14, 2008 2:12 pm
Location: Lille, France

Re: OpenGL Coverflow

Postby Dub » Wed Jan 20, 2010 2:40 pm

maxprod wrote:@Dub

Ok, i see. Try to comment :

Code: Select all
drawBackground ();
&
drawForeground ();

in CoverFlowOpenGL void repaintGL ();


Right, if I comment-out calls to both drawForeground and drawBackground it works beautifully (very smooth) - albeit with a black "backdrop" and "floor" - (Although on my system, two of the images are just blank white rectangles - could be I didn't copy a file or something)

I'll have more of a play later
Dub
Dub
JUCE UberWeenie
 
Posts: 158
Joined: Wed Jun 28, 2006 10:45 pm
Location: London

PreviousNext

Return to Useful Tools and Components

Who is online

Users browsing this forum: No registered users and 0 guests