VB.NET Restrictions? Real-Time Rendering?

Joined
Apr 14, 2006
Messages
9
Programming Experience
1-3
I love how easy it is to design forms with VB.NET - But I can't seem to do anything else? I am trying to draw bezier splines in realtime, like building an editor.

Basically, is it possible to design things like MAP EDITORS, SPLINE EDITORS, ART PROGRAMS, ETC?

Because all the controls seem to be event based and not real-time based? Where are the real-time controls? I can't even seem to find any documentation on this either, does anyone know if VB.NET is even capable of any realtime rendering?
 
Gdi+

Ok? Do you know where I can look at GDI+ Tutorials etc? If I can figure out how we do real-time rendering, then the sky is the limit! I'll be able to draw splines, etc on this GDI+ Module and everything related to buttons a user clicks? Excellent! Please get back with me on this!!

Later,
Matt
 
Thanks but I'm still very much lost!

I'm used to programming languages that iterate through a main loop! I dont understand this other stuff!! It just doesnt make sense to me! Where do I put these codes? They dont say? Why can't I have a main loop that it iterates through. That is very important when designing bezier splines, I dont want to use their code, I want to iterate through each section of the spline as speed differentiates depending on the spline design.

It's hard to explain if you dont know much about Bsplines, but through each iteration a dot can be drawn at different locations from the last dot if you increment time by one step. This means that you might have dots farther apart from each other, hence, speed differentials.

Using VB Bsplines, they just draw full solid curves, and I dont want to do it that way.

I'm trying to design a Bezier Spline Editor for GAMES. I have already done so in BLITZMAX (my current language of choice) which uses MAIN LOOPS etc instead of this weird EVENT-BASED VB stuff (which seems highly limited!!!)

I hope that there is a way to do REAL-TIME RENDERING like MAIN LOOP stuff.

Do you guys know what I'm saying? If you have any questions on my explanations let me know. If you know what I'm talking about and have overcame this similar issue please help me with your insight.

I hope that there is REAL-TIME rendering available. So far I dont see a MAIN LOOP deal at all in VB.NET - Which sucks because its a great GUI builder, but that seems to be about it :-(
 
There are many events associated with a loop too: loop start and loop end are events, every iteration of a loop is an event, any changes to the properties of the loop itself are events for example if number of iterations is prolonged or shortened.

Of course you can start your program with a Main method, you can choose any entry point for the application you want, and you can do loops there. Check up on the basic language statements 'For.. Next' and 'Do..Loop' http://msdn2.microsoft.com/en-US/library/ezk76t25(VS.80).aspx

DirectX and OpenGL is perhaps familiar for you from Blitz and can be used from VB.Net too.
 
No offense

No offense to you but you are just very ignorant to .NET programming and or object oriented programming. I used to do wireframe graphics myself in QBASIC and it ran through a continuous loop. However; with VB now adays it's not limited but rather more flexible. Anything you were doing can still be done and better but at a different point of view. You really can't jump into OOP (Object Oriented Programming) and try to do the same ole thing. And just a quick tutorial, events are just calls to routines that don't yet exist. You can choose to catch the call to the routine in other ares of your code. Here's a small example that I think you may understand that makes an event.
VB.NET:
[SIZE=2][COLOR=#008000]
'Declare the event first
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Event[/COLOR][/SIZE][SIZE=2] Past_Marker()
[/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] RunLoop()
REPEAT:
[/SIZE][SIZE=2][COLOR=#008000]'do code here
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'drawing ect....
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]'raise an event
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]RaiseEvent[/COLOR][/SIZE][SIZE=2] Past_Marker()
[/SIZE][SIZE=2][COLOR=#008000]'do more code
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]GoTo[/COLOR][/SIZE][SIZE=2] REPEAT
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

That code runs a continous loop. It's not how you should program but I figured it would help you grasp what's going on.
Now when you raise the event, you probably wondering what's happening. Well, nothing is happening. We have to have code else where that catches the event. Here is the code that catches the event.

VB.NET:
[SIZE=2][COLOR=#0000ff]
Sub[/COLOR][/SIZE][SIZE=2] Marker() [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Class1.Past_Marker
[/SIZE][SIZE=2][COLOR=#008000]'you can run the code here now anytime your previous code raises the Past_Marker event.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

This probably still looks lame but you have to remember that this code is for jumping from form to form or control to form basically file to file. When you want to possibly run code in another file at that time. You can also have as many routines as you want handling the Past_Marker event. In this case you can have many differenent things happen when the Past_Marker event is risen. This is whats going on everytime an event is thrown. And as you have probably seen you can pass parameters with events or variable(information).

VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Declare the event first
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Event[/COLOR][/SIZE][SIZE=2] [COLOR=black]Past_Marker[/COLOR]([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] [COLOR=black]Mark[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] [COLOR=black]RunLoop()[/COLOR]
[COLOR=black]REPEAT:[/COLOR]
[/SIZE][SIZE=2][COLOR=#008000]'do code here
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'drawing ect....
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'raise an event
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] [COLOR=black]x[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]' x can be a specific coordinate
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]RaiseEvent[/COLOR][/SIZE][SIZE=2] [COLOR=black]Past_Marker(x)[/COLOR]
[/SIZE][SIZE=2][COLOR=#008000]'do more code
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]GoTo[/COLOR][/SIZE][SIZE=2] [COLOR=black]REPEAT[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE]

Then use the information.

VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Marker([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] Mark [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Class1.Past_Marker
[/SIZE][SIZE=2][COLOR=#008000]'you can run the code here now anytime your previous code raises the Past_Marker event.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Mark = 79 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] MsgBox([/SIZE][SIZE=2][COLOR=#800000]"You've reached your destination!"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

This is just a simple low down version of what is possible to help you get on your way. I really hope I can help you out somehow, I understand graphics and I am about as much up to date with VB 2005 as any decent programmer can be. I still have a lot to learn myself though. Remember, I don't recommend the GOTO statement by all means, I just was useing it to help you see the loop in action with events.


You can choose to catch else where in the code or let alone. Your best bet is to get a good Begginning VB .NET book and learn hte modern way to program. I would love to help you with this as well if you want. I do alot of graphic programming and it's anything but limited. But u have to start with the basics first. Programming has changed so much. I honestly think u will be more happy once you learn some basic VB 2005 or 2002+ and start understanding it. E-mail me anytime. KeeblerShadowHaje@sbcglobal.net or get me on Y! msger.
 
Last edited:
Um And Or OOP? Hardly! I know OOP very well, so I do take offense to that. But I do thank you very much for everything else you typed :)

As far as OOP Compared to .NET Uhh how? Main loops have OOP for instance.

Main Loop:
VB.NET:
Repeat
     Object1.Update()
     Object2.Update()
     Object3.Update()
Forever
See? There is still a MAIN LOOP.
Whereas Object1 can have serveral routines, one of them being update. C++ and SDL, along with BLITZMAX, etc are by far way different and both use OOP then .NET - So I hope you see the difference. I already understand that OOP itself is highly flexible, but I dont see how .NET is at all flexible when it comes to real-time rendering. Instead of Rendering in real-time .NET seems to be limited to waiting for user input, instead of updating regardless.

I'm just totally ignorant to .NET and also MSDN's tutorials dont even show a main loop or anything they just show how to drop objects into the forms and put EVENT BASED CODE ONLY in them. .NET seriously reminds me of ACCESS lol. That doesnt help me at all if I'm trying to do something every cycle.

ANYWAYS, I'll read the rest of your post now :rolleyes:
 
Another Note:

Read your post. Just wondering where I could put the drawings. I put in some drawing stuff in an event but I dont think it worked because the drawing would only work if I called the specfic event? So I gotta have it draw no matter what the user is doing, so I need to put it in a loop that runs at all times. Where do I put the code? Not the form? Hopefully that doesnt slow down the app?

About VB .NET Beginner books and tutorials, they really frustrate me because they seem to go over drag and dropping stuff like input boxes and combo boxes which have nothing to do with calling a function constatnly no matter what the user is doing. In fact, I'd rather not read about how to use input boxes, etc as they are extremely self-explanitory.

THIS IS WHAT IM TRYING TO DO:

1) Run a function over and over again no matter what the user does.
2) The function itself does different things based on what the user does (moves points etc)
3) The function is basically drawing many things like grids, vectors, etc (much like a 3d map editor)
4) Know WHERE the function goes? In the form.vb? Where!??!?
5) Where do we draw the stuff?!?!? On controls?!?! on the form!?!! No x and y?!?!?!

Please understand that the MSDN Tutorials dont go over anything remotely what I'm trying to do :(
 
"Use a Do...Loop structure when you want to repeat a set of statements an indefinite number of times"

And you don't call an objects event, an event is something that happens within some object and you can subscribe to it by adding a handler routine.

If you want to do both this and that at the same time you should read about threads and asynchronous programming.
 
I would love to help you out with this project but I'm not totally sure where your going with it. If you just want code to run contiuously there are several solutions. One could be a simple timer. In a timer every second or whatever the routine would automatically run. I don't think this is however what you are looking for. Honestly I would suggest multithreading. I will show you some sample code on how to use multiple threads if you don't alredy know how. The user can go about his business and the thread will always run. You can make changes to variables via the user that effect the thread but REMEMBER you need to make the variables THREADSAFE. This means the computer dosn't let the user and the thread make changes to the variable at the same time. This causes nasty errors and sometimes they run for a long time before they occurr and they are hard to catch....

Here's some code for multithreading. O and btw. I wasn't insulting you. But I still think your nieve as to what I am saying. Hopefully as we work together on this you will see the flexibility I am bragging about. I love to teach and help not put people down.

VB.NET:
[SIZE=2][COLOR=#0000ff]
Dim[/COLOR][/SIZE][SIZE=2] Mover_Thread [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Threading.Thread
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Y [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_FormClosing([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.FormClosingEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].FormClosing
   Mover_Thread.Abort()
   Mover_Thread.Join()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load
   Control.CheckForIllegalCrossThreadCalls = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2]  Mover_Thread = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Threading.Thread([/SIZE][SIZE=2][COLOR=#0000ff]AddressOf[/COLOR][/SIZE][SIZE=2] MOVE_BUTTON)
   Mover_Thread.Priority = Threading.ThreadPriority.BelowNormal
   Mover_Thread.Start()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] MOVE_BUTTON()
[/SIZE][SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][SIZE=2] X [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(0, Y)
[/SIZE][SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][SIZE=2] swap [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 1
[/SIZE][SIZE=2][COLOR=#0000ff]  Do
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]     Me[/COLOR][/SIZE][SIZE=2].Button1.Location = X
      X.X += swap
      X.Y = Y
[/SIZE][SIZE=2][COLOR=#0000ff]     If[/COLOR][/SIZE][SIZE=2] (X.X < 0) [/SIZE][SIZE=2][COLOR=#0000ff]OrElse[/COLOR][/SIZE][SIZE=2] (X.X > [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Size.Width) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]        swap *= -1
[/SIZE][SIZE=2][COLOR=#0000ff]     End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]     Threading.Thread.Sleep(10)
[/SIZE][SIZE=2][COLOR=#0000ff]  Loop
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_MouseMove([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.MouseEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].MouseMove
   Y = e.Y
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE]


That is all the code you need to see what I am talking about. Notice however, that Y is not thread safe but it appears to work great for me. This dosn't mean it always will. We can make Y thread safe in a few different ways but let's focus on this for now. Also, notice the load event where I tell the program it's ok to use the button in threads. Then I assign other values of the thread. Make sure to put the thread as a lower priority if you want it running in real time. If not this may bogg down your system and the user won't be able to do anything.

This Code will cause a button to continuously move back and forth across the screen no matter what the user is doing. However; if the user moves the mouse across the form the location of the mouse Y axis changes the buttons Y axis.

Also notice that when closing the form we kill the thread then wait for it. This is because threads can keep forms and other objects alive even after the program is killed. To test this just take the thread.abort and thread.join out of the form closing event and run it in your IDE. You will notice that you still have to kill the program with the IDE even after you closed the form.

Hope this helps some.
 
Ah, I was typing up my Threading post as John was posting his Threading comment. I also hope that you didn't think I meant use Events to make the loop, I was trying to clear up Events b/c you sounded weary of them a little bit. Anyways, hit me back up when you get this and test that code.
 
I agree with JohnH. Threading make alot more sense. If you just loop continuously then animations, or whatever is being done, will speed up or slow down depending on processor workload. If threading is used, there is a guaranteed rate at which the animations are done. It also allows for better control of the animation itself should you want to change animation speed.

EDIT: I left the browser tab open so long I didnt see YOUR post http://www.vbdotnetforums.com/member.php?u=5334ImDaFrEaK!
 
You guys have really posted some helpful topics. I might contact you freak :D

I'm really enjyoing VB.NET's form design, although its code doesnt look that friendly to me. I thought Goto's were a thing of the past :p

I was raised on GWBASIC to QBASIC to BLITZBASIC (which I use BLITZMAX, it uses OOP)

So let me get a few things straight.

1) The Form Load is where I'd put in the threading stuff
2) So when you create a thread? how exactly do you activate and manage it? Is it still in form load? (confused here)
3) Where do you draw your graphics at? In the thread? on what objects you draw them on?
 
Last edited:
GOTO's are a thing of the past. I've only used it once recently for an odd situation. But, they can be helpful in loops. However; I was just using GOTO to demonstrate the loop as basic as I could. Sorry if my first post was misleading, I broke off topic to demonstrate Events b/c you gave the impression you were totally lost. I apologize and will use correct coding from now on. I was only hoping not to lose you if you were new.
 
Back
Top