POV-Ray : Newsgroups : povray.advanced-users : movie within Server Time
29 Jul 2024 02:20:04 EDT (-0400)
  movie within (Message 81 to 90 of 100)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Dan P
Subject: Re: movie within
Date: 4 Feb 2004 20:23:30
Message: <40219b12$1@news.povray.org>
"Patrick Elliott" <sha### [at] hotmailcom> wrote in message
news:MPG.1a8b3cdca47d8a80989996@news.povray.org...
> In article <402125e4@news.povray.org>, dan### [at] yahoocom says...
> > try
> > {
> >     Do something
> > }
> > catch (Exception ex)
> > {
> >     Failure
> > }
> >
> > Are you saying all these people are wrong?
>
> Just my two cents here, but this isn't exactly the same things.
> However... If you opened the file, then tested to see if it worked and
> intentionally throw an exception, then it would be the same. What you are
> doing is manually handling an event that languages like Java can
> sometimes automatically generate an error event for. When this is the
> case, it is a real good idea to make sure things happen in the correct
> order. There are quite a few cases where checking after the fact can be
> flat out lethal to your program. In fact when dealing with Windows, the
> damn API is so flaky that it may actually appear to work and only crash
> your program, and the OS, *after* you try to shut down the program.
> Believe me, I have had it happen. lol

That's a really good point about the order. Also, I've been really diving
deep into the Windows API and I've noticed two things: 1. it's really,
really poorly documented, and 2. you have to do everything precisely the way
they want you to or it's going to crash and not pretty-like. It only makes
sense what those components are doing after you trace it using the debugger.
And even then, it's not obvious. I'm really worried about writing code that
works great on my PC but crashes elsewhere because of that. What I had to do
to handle window-resizing in an instant, efficient manner best not be said
in mixed company :-)

What I'm really surprised about is that they haven't put all those structs
into convenient-to-use classes. I struggled for an entire night to get
version info from my VS_VERSION_INFO resource. It turns out I have to create
two HGLOBALS, then lock the resource, and then use VerQueryInfo, and it
/still/ didn't work -- I guess they just don't want you reading that
resource directly, and I tried passing the executable file name and it
didn't work /then/ either. I did massive searches on the net to see other
people doing this and I couldn't find a single, consistent explanation of
how to get this information. Why the couldn't just make a class called
CVersionInfo and throw the data in there it is beyond me. I also had to make
some REALLY ugly code to read PNGs from the resource instead of a seperate
file. Here it is:

     IStream *p_objStream;
     HRSRC objResource;
     HGLOBAL objSrc;
     HGLOBAL objData;

     // Load the about image.
     objResource = FindResource(NULL,
MAKEINTRESOURCE(IDR_TITLE_TRANSPARENT), "PNG");
     objSrc = LoadResource(NULL, objResource);
     objData = GlobalAlloc(GMEM_FIXED, SizeofResource(NULL, objResource));
     CopyMemory(LPVOID(objData), LockResource(objSrc), SizeofResource(NULL,
objResource));
     CreateStreamOnHGlobal(objData, TRUE, &p_objStream);
     m_imgAbout.Load(p_objStream);

Why they create a CImage class and not enable it to load image data from a
resource like this:

    m_imgAbout.Load(IDB_PNG_FILE);

is beyond me. And even though I have the PNG now, and have set the window
transparent, and have overridden OnErase, I still wind up getting opaque
white where the alpha=0 area is. The rest of the shadowing and stuff works
(I'm looking to make an AboutBox like Photoshop does), yet when it is
alpha=0, it screws up. I'm still trying to get that to work and haven't
found anything on the web about it.

I've only been on this journey for a week now and already I can understand
why so many of my Windows programs crash. It isn't that the programmers are
bad, it's that Microsoft can't seem to get their act together. From what TF
said, I'm really expecting that to be true about DirectX as well. If anybody
has an suggestions on how to deal with this, I'd really appreciate hearing
them (and don't listen to those guys -- if those suggestions don't contain
blatant insults, I don't bite -- the proof is in the thread.) At least .NET
is cleaning a lot of things up now, although I have yet to figure out how to
use a .NET specific class (like MemoryStream) in my C++ code.

> -- 
> void main () {

>     call functional_code()
>   else
>     call crash_windows();
> }

LOL :-) Take good care of that cat!!!


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 4 Feb 2004 20:32:59
Message: <40219d4b$1@news.povray.org>
"Darren" <dne### [at] sanrrcom> wrote in message
news:40219931$1@news.povray.org...
> Mike Raiford wrote:
> > Essentially you have this:
> >
> If you're a "structured programming" fan, the first makes more sense.
> What if a requirement comes up "by the way, print a message just before
> returning from this routine"? In that case, the former has a definite
> advantage.
>
> The cleverest solution I've seen is
>     still_good = true
>     if (still_good) {
>         still_good = operation1();
>         if (!still_good) handle it,
>             possibly setting still_good to true again.
>      }
>      if (still_good) {
>          still_good = operation2();
>          if (!still_good) handle it;
>      }
>      if (still_good) {
>          still_good = operation3();
>       and so on.
> Of course, with some languages, this can turn into
>      still_good = still_good && op1();
>      still_good = still_good && op2();

I like that approach because it forces the person to handle every case and
not be lazy about the way they do it. What that is doing is kind of like
what Java does, only the test is more implied in Java. For example, the same
code in Java-esque would be:

    try
    {
        operation1();
    }
    catch (Exception e)
    {
        handle it
    }
    ... and so forth.

If you are really smart about your exceptions, a big try block can be a lot
more compact:

    try
    {
        operation1();
        operation2();
        operation3();
    }
    catch (Operation1Exception e)
    {
        handle it
    }
    catch (Operation2Exception e)
    {
        handle it
    }
    catch (Operation3Exception e)
    {
        handle it
    }

or, even better, if they all send the same exception and the toString()
method on the exception contains useful output, this is nice too:

    try
    {
        operation1();
        operation2();
        operation3();
    }
    catch (OperationException e)
    {
        System.err.println(e.toString());
    }

What you described is a really concise way of doing it in C, I think. Also,
Visual C++ .NET has the try{} catch{} structure now. I'm not sure if the
latest version of g++ has something like that yet, but I wouldn't be
surprised if it did or does soon.

Thanks for the feedback, Darren, fellow RoadRunner enthusiast! :-)


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: movie within
Date: 4 Feb 2004 21:54:42
Message: <4021b072@news.povray.org>
In article <40219d4b$1@news.povray.org> , "Dan P" 
<dan### [at] yahoocom> wrote:

> What you described is a really concise way of doing it in C, I think. Also,
> Visual C++ .NET has the try{} catch{} structure now. I'm not sure if the
> latest version of g++ has something like that yet, but I wouldn't be
> surprised if it did or does soon.

Sorry, I cannot resist:

Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha,
ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha,
ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!!!!!


Oh, and for anybody else wondering why I am laughing, the "try{} catch{}
structure", correctly called exception handling, has been around for much
longer (since the mid-1980s) than he claims to have been a programming
(since 1989).  Visual C++ as well as g++ (the gcc C++ compiler) have
supported exception handling for as long as they have supported C++.  And
exception handling has been mentioned in any C++ book in the last decade.
Very hard to miss for anybody who has ever written a single line of C++
code!

Thus, there is no longer any doubt that he is just a troll who has wasted
our time in the past few days :-(

q.e.d.


So, I have to apologise to every serious visitor around for having fed this
troll for such a long time!  Seriously!  I should have just really killfiled
him, not just said so.  Sorry!

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 4 Feb 2004 22:13:30
Message: <4021b4da$1@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:4021b072@news.povray.org...
> In article <40219d4b$1@news.povray.org> , "Dan P"
> <dan### [at] yahoocom> wrote:
>
> So, I have to apologise to every serious visitor around for having fed
this
> troll for such a long time!  Seriously!  I should have just really
killfiled
> him, not just said so.  Sorry!
>
>     Thorsten

Okay, I just figured out what is going on here.
Good one, guys, I'll admit, you actually got me hot-and-bothered for a while
there.

Warp, I apologize for going off on you. You never stopped being a hero of
mine.
And TF? Great job at baiting me, man. You got me good.


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: movie within
Date: 5 Feb 2004 08:35:53
Message: <opr2wf4fo1zjc5hb@news.povray.org>
On Wed, 4 Feb 2004 19:23:30 -0600, Dan P <dan### [at] yahoocom> wrote:
> Also, I've been really diving
> deep into the Windows API and I've noticed two things: 1. it's really,
> really poorly documented, and 2. you have to do everything precisely the 
> way they want you to or it's going to crash and not pretty-like.

That's funny. I've always found the Windows API to have very extensive and 
detailed documentation; much better than most other APIs I've encountered. 
It takes a little while to get accustomed to the style of documentation 
though.
As for your second point, I can agree to some extent. For me the problem 
isn't so much the conseqeunces of doing something wrong, so much as the 
fact that the "right" way of doing things is sometimes unnecessarily 
complicated and archaic. Part of the price you pay for backwards 
compatibility I guess; the core of the API is very, very old.


> It only makes
> sense what those components are doing after you trace it using the 
> debugger.
> And even then, it's not obvious. I'm really worried about writing code 
> that
> works great on my PC but crashes elsewhere because of that. What I had 
> to do
> to handle window-resizing in an instant, efficient manner best not be 
> said
> in mixed company :-)

Actually, I'd be interested in hearing more about this. Just about the 
only reason I ever use the WinAPI directly these days is that I'm 
confident it will work as intended on other machines (running Windows). 
Problems arise only when using stuff like DirectX or OpenGL; differing 
hardware capabilities and driver versions can really wreak havoc then.


> What I'm really surprised about is that they haven't put all those 
> structs
> into convenient-to-use classes. I struggled for an entire night to get
> version info from my VS_VERSION_INFO resource. It turns out I have to 
> create
> two HGLOBALS, then lock the resource, and then use VerQueryInfo, and it
> /still/ didn't work -- I guess they just don't want you reading that
> resource directly, and I tried passing the executable file name and it
> didn't work /then/ either. I did massive searches on the net to see other
> people doing this and I couldn't find a single, consistent explanation of
> how to get this information.

Version info is supposed to be retrieved with GetFileVersionInfo & 
VerQueryValue, is it not?
The only time I've had to load a resource explicitly was when I had 
resources containing custom data. All the standard resource types have 
special functions for retrieving the data.


> Why the couldn't just make a class called
> CVersionInfo and throw the data in there it is beyond me.

The WinAPI is a C-based API. If you want class wrappers, you need to find 
a C++ framework, e.g. wxWindows, QT, FOX, gtkmm, etc.. Note that I do not 
include MFC in that list; I personally find MFC to be utterly useless.


> I also had to make
> some REALLY ugly code to read PNGs from the resource instead of a 
> seperate
> file. Here it is:
>
>      IStream *p_objStream;
>      HRSRC objResource;
>      HGLOBAL objSrc;
>      HGLOBAL objData;
>
>      // Load the about image.
>      objResource = FindResource(NULL,
> MAKEINTRESOURCE(IDR_TITLE_TRANSPARENT), "PNG");
>      objSrc = LoadResource(NULL, objResource);
>      objData = GlobalAlloc(GMEM_FIXED, SizeofResource(NULL, 
> objResource));
>      CopyMemory(LPVOID(objData), LockResource(objSrc), 
> SizeofResource(NULL,
> objResource));
>      CreateStreamOnHGlobal(objData, TRUE, &p_objStream);
>      m_imgAbout.Load(p_objStream);
>
> Why they create a CImage class and not enable it to load image data from 
> a resource like this:
>
>     m_imgAbout.Load(IDB_PNG_FILE);
>
> is beyond me.

As I said, I don't use MFC myself, but it seems to me that 
CImage::LoadFromResource would fit the bill. Did that not work for you?


> I've only been on this journey for a week now and already I can 
> understand
> why so many of my Windows programs crash. It isn't that the programmers 
> are
> bad, it's that Microsoft can't seem to get their act together. From what 
> TF
> said, I'm really expecting that to be true about DirectX as well.

If you think the regular WinAPI is bad, you'll really hate DirectX. It's 
more of the same, except now you have to deal with COM interfaces as well. 
If you intend to use DirectX, you'll want to write/find/steal some good 
wrappers to encapsulate the nitty-gritty stuff. I managed to get some 
fairly smooth usage out of DirectSound that way. DirectDraw/3D is a little 
tougher to wrap, mainly because those interfaces are pretty huge.


__
FE


Post a reply to this message

From: Patrick Elliott
Subject: Re: movie within
Date: 5 Feb 2004 17:28:12
Message: <MPG.1a8c6fb548f52222989999@news.povray.org>
In article <40219b12$1@news.povray.org>, dan### [at] yahoocom says...
> is beyond me. And even though I have the PNG now, and have set the window
> transparent, and have overridden OnErase, I still wind up getting opaque
> white where the alpha=0 area is. The rest of the shadowing and stuff works
> (I'm looking to make an AboutBox like Photoshop does), yet when it is
> alpha=0, it screws up. I'm still trying to get that to work and haven't
> found anything on the web about it.
> 

Well. The only C++ I ever did was a few weeks in some class called 
'current concepts' at college. I need to get into it and figure out how 
to code in it, but never really liked the issues involved with trying to 
figure it out. Since recently trying to code something in VB that 
required accessing the Windows API to do some stuff VB doesn't allow, 
this has gone from dislike to borderline fear. lol

However, I would be quite happy to try, even if the first basic project 
was nothing but a replacement for the damn Hotbar gadget I use with IE. 
Hotbar only makes what on my machine is an unstable IE into a disaster 
and the new version for some damn reason integrates into Outlook and 
screws with it too. The problem...? I can't for the life of me find 
usable documentation of how to create the sub-resource for the coolbar 
(or rebar as some call it) interface as IE uses it. It isn't the same as 
a normal coolbar, but is a dll encapsulated subbar or whatever they call 
it that gets placed on a rebar. It needs to implement special intefaces 
for IE besides and then has to be registered in some goofy way to work. I 
am surprised Hotbar and a few others figured out how the hell to do it. 
lol

Most people btw take the cheap way out and just alter a single registry 
key, so it points to a bmp file. But IE literally doesn't know how to 
stretch to fit this image and what idiot uses jpg (which sometimes refuse 
to display properly under 98 as background or desktop images) or bmp, 
which in the case of something like the desktop, can take up more room 
than some complete program installations. :(

Bloody pain in the ass finding decent, let alone usable documentation for 
how anything on windows works. :p Could you imagine the screams of pain 
if MS convinced motherboard manufacturers to install the API as part of 
the system bios, the way Apple does? People would be jumping out of 
windows like when the stock market crashed. lol

I have to agree with you. Most stuff written for windows runs like crap 
and only well under XP, because no one actually has a clue how to make 
any of it work right in the first place. They just use the same defective 
code over and over. After all, is did work once, 'sort of', so it should 
be fine to leave it in the next version too, 'more or less'. lol

-- 
void main () {

    call functional_code()
  else
    call crash_windows();
}


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 6 Feb 2004 20:32:43
Message: <4024403b@news.povray.org>
"Patrick Elliott" <sha### [at] hotmailcom> wrote in message
news:MPG.1a8c6fb548f52222989999@news.povray.org...
> In article <40219b12$1@news.povray.org>, dan### [at] yahoocom says...
> > is beyond me. And even though I have the PNG now, and have set the
window
> > transparent, and have overridden OnErase, I still wind up getting opaque
> > white where the alpha=0 area is. The rest of the shadowing and stuff
works
> > (I'm looking to make an AboutBox like Photoshop does), yet when it is
> > alpha=0, it screws up. I'm still trying to get that to work and haven't
> > found anything on the web about it.
> >

> However, I would be quite happy to try, <snip />

Thanks, man!

Here is the code for the about box:
http://<broken link>/coldsuite/coldstitch/about.shtml

Here is the source PNG
http://<broken link>/coldsuite/coldstitch/title_transparent.png

And here is the executable (go to About):
http://<broken link>/coldsuite/coldstitch/COLDstitch.exe

I've currently just started stubbing out the application so nothing else
works but the about box.
Thanks for your help!!!


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 6 Feb 2004 20:34:02
Message: <4024408a$1@news.povray.org>
Just for kicks, here is the code I used to create the snowflakes in case
anybody might find it useful:


#include "colors.inc"
#include "shapes.inc"
#include "rand.inc"



#declare BAR_WIDTH = 0.04;
#declare BAR_EDGE = 0.04;



background
{
 color rgb <0, 0, 0>
}



camera
{
 location <0, 0, -1>
 look_at <0, 0, 0>

 up y
 right image_width / image_height * x
}



light_source
{
 <-100, 100, -100>
 color White
}



#macro FlakeBar(n)

 merge
 {
  cone { <0, 0, 0>, BAR_WIDTH, <0, 1, 0>, 0 }

  #local i = 0;

  #local RN = seed(n);

  #while (i < 4)

   #local by = rand(RN);
   #local bl = rand(RN) * 0.3 + 0.1;

   cone { <0, 0, 0>, BAR_WIDTH, <0, bl, 0>, 0 rotate 45*z translate by*y }
   cone { <0, 0, 0>, BAR_WIDTH, <0, bl, 0>, 0 rotate -45*z translate by*y }

   #local i = i + 1;

  #end
 }

#end




#macro Flake(n)

 object { FlakeBar(n) }
 object { FlakeBar(n) rotate 60*z }
 object { FlakeBar(n) rotate 120*z }
 object { FlakeBar(n) rotate 180*z }
 object { FlakeBar(n) rotate 240*z }
 object { FlakeBar(n) rotate 300*z }

#end



#macro SnowFlake()

 merge
 {
  Flake(ceil(rand(RdmA)*65535))

  pigment
  {
   color rgbf <0.5, 0.5, 0.5, 1>
  }


  finish
  {
   specular 1
  }


  scale <0.05, 0.05, 0.05>
 }

#end



#local i = 0;

#while (i < 1024)

 object { SnowFlake() rotate <RRand(-30, 30, RdmA), RRand(-30, 30, RdmA),
RRand(-30, 30, RdmA)> translate VRand_In_Sphere(RdmA) }

 #local i = i + 1;

#end


Post a reply to this message

From: Tom Galvin
Subject: Re: movie within
Date: 7 Feb 2004 01:53:48
Message: <Xns94881314FA449tomatimporg@203.29.75.35>
"Dan P" <dan### [at] yahoocom> wrote in news:4024403b@news.povray.org:

> http://<broken link>/coldsuite/coldstitch/COLDstitch.exe

MFC71D.DLL could not be found...And it is too late at night for me to go 
look for it ;)

-- 
Tom
_________________________________
The Internet Movie Project
http://www.imp.org/


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 7 Feb 2004 11:27:38
Message: <402511fa@news.povray.org>
"Tom Galvin" <tom### [at] imporg> wrote in message
news:Xns94881314FA449tomatimporg@203.29.75.35...
> "Dan P" <dan### [at] yahoocom> wrote in
news:4024403b@news.povray.org:
>
> > http://<broken link>/coldsuite/coldstitch/COLDstitch.exe
>
> MFC71D.DLL could not be found...And it is too late at night for me to go
> look for it ;)

Ah, I learned something -- to distribute the program, I need to statically
link the MFC library, not load it as a shared DLL. Also, I uploaded the
debug version, which is 2M, but this time, I uploaded the release version,
which is only 600K.

I'll work now (I'm excited; this is exactly what is great about coding in a
community!)


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.