Liberty BASIC Community Forum
« Search Results »

Welcome Guest. Please Login or Register.
Jul 22nd, 2014, 8:38pm


Rules|Home|Help|Search|Recent Posts|Notification

--Liberty BASIC Resources--
Yahoo Code Repository (source must be included)
Liberty BASIC Community WikiSpace
Liberty Labs
Bay Six Software Forum
Liberty BASIC Home Page

Official Liberty BASIC Support
Liberty BASIC Programmer's Encyclopedia
Liberty BASIC 5 Handbook
Liberty BASIC on Rosetta Code

Search Results

Total results: 10


 1   Game and Graphic Programming / Re: open gl  on: Jul 19th, 2014, 12:01pm
Started by bluatigro | Post by Stefan Pendl
on Jul 19th, 2014, 04:04am, bluatigro wrote:
i got a :

runtime error protection violation


This is mostly cased by incorrectly translated API functions and origins in accessing memory that is not allocated by the process or already freed.

In general it means that there was garbage returned from or feed to the API function.
 
  Reply Quote Notify of replies

 2   Game and Graphic Programming / Re: open gl  on: Jul 19th, 2014, 04:04am
Started by bluatigro | Post by bluatigro

i got a :

runtime error protection violation


this was whit the example :
www.cabinetplanner.com/files/OpenGL%20in%20LB.zip


does anyone know what this means
and how to find and corect the error
 
  Reply Quote Notify of replies

 3   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 19th, 2014, 01:00am
Started by Roger Thomas | Post by Stefan Pendl
The problem might have been that the launch of the separate process was not finished yet, but you instructed LB to move on by a callback.

If you run an external program make sure to give the main program enough time to spawn the process.
 
  Reply Quote Notify of replies

 4   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 18th, 2014, 09:35am
Started by Roger Thomas | Post by Roger Thomas
It works now. By releasing it, I meant that the main code wouldn't quit running my.tkn so that when the main program ended, the process in Task Manager wouldn't quit.

The tkn should have ended by itself but for some reason it wouldn't do it while scanning.

It works the last way that I posted. My program does a lot more than the example so there is more code to run while its scanning.

I forgot to zero the timer in the example. I had already posted when I saw it.

Everything is working great now.
Thanks for all the help.

Roger
 
  Reply Quote Notify of replies

 5   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 18th, 2014, 03:41am
Started by Roger Thomas | Post by Rod
When you use the words "to release my .tkn" I wonder if there is a fundamental confusion.

I am still a little confused about what you are trying to achieve. But that may be because you believe you have to do something to release a .tkn. You don't.

If you run a .tkn from within a program it runs completely autonomously from the main program. There is no interaction at all. The .tkn wil run and close as it is scripted.

The main program is autonomous also and as soon as it has initiated the .tkn it is free to do whatever it is scripted to do. Simply wait for further user input or close with an END statement, programmers choice.

SO I am confused by your scanning and timing routines. The timer needs zeroed once it has fired else it will repeat and misdirect the program.

If you have an event or callback outstanding simply waiting to be redirected may suffice?

Not sure if I am helping.
 
  Reply Quote Notify of replies

 6   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 18th, 2014, 12:29am
Started by Roger Thomas | Post by Roger Thomas
I believe I have it here.

Main program code:
Code:
'nomainwin'dont open main window

dim info$(10,10)

firstrun = 1
if firstrun = 1 then
   if fileExists(DefaultDir$, "My.tkn") then
      run "My.tkn"
     else
      firstrun = 0
   end if
end if

WindowWidth = 300
WindowHeight = 175

button #main.default, "Quit",[quit],UL,20,100

open "Window" for window as #main
#main "trapclose [quit]"

timer 100, [wait]

[wait]
if firstrun <> 1 then goto [Scan]
print "waiting"
firstrun = 0
wait

[Scan] ' Scan here for input
print "scanning"
Scan
CallDLL #kernel32, "Sleep", 1 As ulong, ret As Void
   GoTo [Scan]

[quit]
close #main :end

function fileExists(path$, filename$) 'Tests for file existance
    files path$, filename$, info$(
    fileExists = val(info$(0, 0)) > 0
end function

 


my.tkn code:
Code:
nomainwin

open "Advapi32.dll" for dll as #Advapi32

confirm$ = "This is the first run" + chr$(13)
confirm$ = confirm$ + "Do You want to Run the code?" + chr$(13)
confirm$ = confirm$ + "If you choose No, Code will not be run." + chr$(13)
confirm confirm$; answer$
if answer$  = "no" then goto [end]

'Code to run.

[end]
if answer$  = "yes" then notice "Yes."
if answer$  = "no" then notice "No."
close #Advapi32
end
 


I've got a few callbacks in my program so it can't wait a lot.
I didn't want to use the sleep but on the last callback I used, I couldn't detect the message fast enough to switch to scan so I had to start scanning and using sleep for that one callback.

Anyways I believe this will work for me. It waits just long enough to release my.tkn

Thanks.
 
  Reply Quote Notify of replies

 7   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 17th, 2014, 1:40pm
Started by Roger Thomas | Post by Roger Thomas
Actually, it's my media player that I'm working on. Everything's fine with it. I can't go into detail here because the tkn that I'm running is to give the user the option to associate files and it writes to the registry.

I was just going to run a different tkn to try to keep my main .bas filefrom getting so big.

I can implement it into my main.bas file and it works fine.

I'll probably do that until I find the problem.

Thanks, Roger
 
  Reply Quote Notify of replies

 8   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 17th, 2014, 1:19pm
Started by Roger Thomas | Post by Rod
Well you are not making any provision to end the main program. You can call a .tkn from within one program and that .tkn will run as a separate process. Your .tkn then ends with an end statement.

However your main program just loops endlessly. We would need to better understand the whole process to offer advice.

If you need the main program to stay alive to offer other options then that's what you have now. If you need it to end, end it immediately after calling the .tkn.

If you need to know what is still running then perhaps read some flag files that the .tkn's write.
 
  Reply Quote Notify of replies

 9   Liberty BASIC Code / Re: Run command not releasing process  on: Jul 17th, 2014, 12:42pm
Started by Roger Thomas | Post by Roger Thomas
This code here does the same thing. You'll have to build it and run it by itself.

Main program code:
Code:
nomainwin'dont open main window

dim info$(10,10)

firstrun = 1
if fileExists(DefaultDir$, "my.tkn") then
   if firstrun = 1 then run "my.tkn"
end if

WindowWidth = 300
WindowHeight = 175

open "Window" for window as #main
#main "trapclose [quit]"

[Scan] ' Scan here for input
Scan
CallDLL #kernel32, "Sleep", 1 As ULong, ret As Void
   GoTo [Scan]

[quit]
close #main
end

function fileExists(path$, filename$) 'Tests for file existance
    files path$, filename$, info$(
    fileExists = val(info$(0, 0)) > 0
end function

 


my.tkn code:
Code:
nomainwin

open "Advapi32.dll" for dll as #Advapi32

confirm$ = "This is the first run" + chr$(13)
confirm$ = confirm$ + "Do You want to Run the code?" + chr$(13)
confirm$ = confirm$ + "If you choose No, Code will not be run." + chr$(13)
confirm confirm$; answer$
if answer$  = "no" then goto [end]

'Code to run.

[end]
if answer$  = "yes" then notice "Yes."
if answer$  = "no" then notice "No."
close #Advapi32
end
 


Roger
 
  Reply Quote Notify of replies

 10   Game and Graphic Programming / 2D OBB OBB colision detection  on: Jul 17th, 2014, 06:49am
Started by bluatigro | Post by bluatigro
i m trying to translate a c++ example into LB
c++
Code:
class OBB2D {
private:
    /** Corners of the box, where 0 is the lower left. */
    Vector2         corner[4];    /** Two edges of the box extended away from corner[0]. */
    Vector2         axis[2];    /** origin[a] = corner[0].dot(axis[a]); */
    double          origin[2];    /** Returns true if other overlaps one dimension of this. */
    bool overlaps1Way(const OBB2D& other) const {
        for (int a = 0; a < 2; ++a) {
            double t = other.corner[0].dot(axis[a]);            // Find the extent of box 2 on axis a
            double tMin = t;
            double tMax = t;
            for (int c = 1; c < 4; ++c) {
                t = other.corner[c].dot(axis[a]);
                if (t < tMin) {
                    tMin = t;
                } else if (t > tMax) {
                    tMax = t;
                }
            }            // We have to subtract off the origin

            // See if [tMin, tMax] intersects [0, 1]
            if ((tMin > 1 + origin[a]) || (tMax < origin[a])) {
                // There was no intersection along this dimension;
                // the boxes cannot possibly overlap.
                return false;
            }
        }        // There was no dimension along which there is no intersection.
        // Therefore the boxes overlap.
        return true;
    }
    /** Updates the axes after the corners move.  Assumes the
        corners actually form a rectangle. */
    void computeAxes() {
        axis[0] = corner[1] - corner[0];
        axis[1] = corner[3] - corner[0];         // Make the length of each axis 1/edge length so we know any
        // dot product must be less than 1 to fall within the edge.

        for (int a = 0; a < 2; ++a) {
            axis[a] /= axis[a].squaredLength();
            origin[a] = corner[0].dot(axis[a]);
        }
    }
public:
    OBB2D(const Vector2& center, const double w, const double h, double angle)
{
        Vector2 X( cos(angle), sin(angle));
        Vector2 Y(-sin(angle), cos(angle));
        X *= w / 2;
        Y *= h / 2;
        corner[0] = center - X - Y;
        corner[1] = center + X - Y;
        corner[2] = center + X + Y;
        corner[3] = center - X + Y;
        computeAxes();
    }
    /** For testing purposes. */
    void moveTo(const Vector2& center) {
        Vector2 centroid = (corner[0] + corner[1] + corner[2] + corner[3]) / 4;        Vector2 translation = center - centroid;        for (int c = 0; c < 4; ++c) {
            corner[c] += translation;
        }        computeAxes();
    }    /** Returns true if the intersection of the boxes is non-empty. */
    bool overlaps(const OBB2D& other) const {
        return overlaps1Way(other) && other.overlaps1Way(*this);
    }    void render() const {
        glBegin(GL_LINES);
            for (int c = 0; c < 5; ++c) {
              glVertex2fv(corner[c & 3]);
            }
        glEnd();
    }
};
 

i got this far
Code:
dim obb( 10 , 13 )
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global pi , tx1 , ty1 , tx2 , ty2 , tx3 , ty3 , tx4 , ty4 , tax1 , tay1 , tax2 , tay2 , tcx , tcy
pi = atn( 1 ) * 4
tx1 = 0
ty1 = 1
tx2 = 2
ty2 = 3
tx3 = 4
ty3 = 5
tx4 = 6
ty4 = 7
tax1 = 8
tay1 = 9
tax2 = 10
tay2 = 11
tcx = 12
tcy = 13


nomainwin
open "OBB 2D test" for graphics as #m
  #m "trapclose [quit]"
  call obb 0 , 512 , 350 , 30 , 50 , 30
  call drawobb 0
wait
[quit]
  close #m
end
function obbhit( a , b )
end function
sub drawobb no
  #m "down"
  #m "line " ; obb(no,tx1) ; " " ; obb(no,ty1) ; " " ; obb(no,tx2) ; " " ; obb(no,ty2)
  #m "line " ; obb(no,tx2) ; " " ; obb(no,ty2) ; " " ; obb(no,tx3) ; " " ; obb(no,ty3)
  #m "line " ; obb(no,tx3) ; " " ; obb(no,ty3) ; " " ; obb(no,tx4) ; " " ; obb(no,ty4)
  #m "line " ; obb(no,tx4) ; " " ; obb(no,ty4) ; " " ; obb(no,tx1) ; " " ; obb(no,ty1)
  #m "up"
end sub
function rad( x )
  rad = x * pi / 180
end function
sub obb no , cx , cy , w , h , angle
  ax = cos( rad( angle ) ) * w
  ay = 0-sin( rad( angle ) ) * w
  bx = sin( rad( angle ) ) * h
  by = cos( rad( angle ) ) * h
''compute corner[ 4 ]
  obb(no,tx1) = cx - ax - bx
  obb(no,ty1) = cy - ay - by
  obb(no,tx2) = cx - ax + bx
  obb(no,ty2) = cy - ay + by
  obb(no,tx3) = cx + ax + bx
  obb(no,ty3) = cy + ay + by
  obb(no,tx4) = cx + ax - bx
  obb(no,ty4) = cy + ay - by
''compute axis[ 2 ]
  obb(no,tax1) = obb(no,tx2) - obb(no,tx1)
  obb(no,tay1) = obb(no,ty2) - obb(no,ty1)
  obb(no,tax2) = obb(no,tx4) - obb(no,tx1)
  obb(no,tay2) = obb(no,ty4) - obb(no,ty1)
  obb(no,tax1) = obb(no,tax1) / sqrlen( obb(no,tax1) , obb(no,tay1) )
  obb(no,tay1) = obb(no,tay1) / sqrlen( obb(no,tax1) , obb(no,tay1) )
  obb(no,tax2) = obb(no,tax2) / sqrlen( obb(no,tax2) , obb(no,tay2) )
  obb(no,tay2) = obb(no,tay2) / sqrlen( obb(no,tax2) , obb(no,tay2) )
''compute origen[ 2 ]
end sub
function sqrlen( x , y )
  sqrlen = x ^ 2 + y ^ 2
end function
function dot( ax , ay , bx , by )
  dot =  ax * bx + ay * by
end function
 

this can be useful in a race game for example
 
  Reply Quote Notify of replies


Rules|Home|Help|Search|Recent Posts|Notification



Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls