Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Paslowo on September 23, 2006
-
I've worked with FreeBasic for a while but I have never released any projects with it, and also currently working on a retro 3D engine with fbgfx right now, and so far I was able to get quaternion rotations and wireframe clipping fully working.
I was also taking looking at TinyPTC and it's example programs too and I must say I was impressed by the speed of it compared to fbgfx. The bottom line is, I'm not an advanced programmer when it comes to having to know about memory pointers and such so pretty much it's a bit harder to use without the help of sub routes or libraries to perform the basic functions like drawing lines, boxes, circles(filled or hollow), pixels, and so on.
Toyed around with PTC for a while and ended up getting a bunch of funky results something bizzare compared to fbgfx. Sometimes it crashes even when using the TinyPTCLib.bi.
As for pixeltoaster, will it be the same thing like PTC or would I trust it more than what I'm using now?
Because sometimes the program crashes when I do this:
#Include "TinyPTCLib.bi"
Graphics 640,480, "test app"
DO
ColorSet 255,0,0
E=E+1
F=F-1
DrawLine E,F,200,200
FlipSurf
ClsSurf
Loop
-
First rule of thumb if using TinyPtc, from my experience is that in a main loop to have PTC_Update @DrawingBuffer(0) otherwize you wont see anything.
Btw your using the wrong syntax / command structures for setting up TinyPTC dude. I'll try and knock you up an example, at the moment Im in the middle of Reinstalling my PC as I had a big error whilst installing an SDK that sent my computer nuts. Someone else will probably beat me to it, but if not I'll post something up As soon as I am able to dude.
Cheers and all the best,
Clyde.
-
Here's an example done from memory ( as I havent installed FB yet ) of how I setup and use the TinyPTC library.
Notice how different it is to GFXLib setting up, you will also more often then not have to create your own Drawing Subroutines; like boxes, lines, Text, etc. But the results I find are far better, plus it also gives you the excuse to develope your own custom routines.
'
' TinyPTC Setup Example.
' By Clyde Radcliffe.
'
Option Static
Option Explicit
#Include Once "Tinyptc.bi"
Const ScreenW=640
Const ScreenH=480
Const ScreenArea=ScreenW * ScreenH
Dim Shared ScreenBuffer( ScreenArea ) ' this is used for storing / updating pixel info with tinyptc
'
' Subroutine Initialization and setup.
'
Declare Sub DrawLine ( ByVal PosY As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer )
Declare Sub FeedPixels( Byval x As Integer, Byval y As Integer, Byval col As Integer)
'
' Setup TinyPTC / Screen Resolution.
'
If( PTC_Open( "Example", ScreenW, ScreenH ) = 0 ) Then
End -1
End if
'
' Main Program Loop.
'
Dim Key As String
Dim LinePosY
While Key<>Chr(27)
'
' Update Lines Y Position.
'
LinePosY=LinePosY+1
If LinePosY>ScreenH Then LinePosY=0
'
' Send info to Subroutine And feed results to the Screen Buffer.
'
DrawLine( LinePosY,255,0,0)
PTC_Update @ScreenBuffer(0)
Key=Inkey()
'
' Quick Way To Clear / Empty The Screen Buffer.
'
Erase ScreenBuffer
Wend
'
' Shutdown.
'
Ptc_Close()
End
Sub DrawLine( ByVal PosY As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer )
Dim X, Col
Col=(R Shl 16 ) Or ( G Shl 8 ) Or ( B Shl 0 )
For X=0 To ScreenW-1
FeedPixels( X, PosY, Col )
Next
End Sub
Sub FeedPixels( Byval x As Integer, Byval y As Integer, Byval col As Integer)
If X>0 and X<ScreenW-1 and Y>0 and Y<ScreenH-1 Then
ScreenBuffer(Y * ScreenW + X) = col
End If
End Sub
Hope it helps.
Clyde.
-
Hi Paslowo, welcome to the board and you'll do well to check Clydes nice example of how to use tinyptc.
There are some things to remember about using ptc in your programs.
First of all like Clyde says, it will be necessary to make your own drawing routines, this is because Tinyptc doesn't have many functions.
All you can do is basically open a screen, update a screen from an array, close the screen.
So anything you code is going to have to work on a per-pixel level.
So far, everything I have done in FB is using tinyptc, the results have been very satisfying.
If you can think of any specific questions on what you'll need help doing, such as plots, lines, rects, polygons, circles etc then please post the questions and we'll point you in the right direction.
-
I really don't mind working pixel by pixel in a matter of fact, I really enjoy doing that. Because if I can find a way to get the RGB color(which may be way harder in PTC) from an X,Y location then I can do some special transparent or even glowing effects with it.
-
I will do a little bit of code for you later to do just that.
-
Hi,
Where can i find the file ptc.bi and/or tinyptc.bi?
-
Hi Rens, the tinyptc lib should be already there for you in your freebasic installation. It can be found in freebasic/inc/
However, I suspect that you are upgrading the lib? If you are after the new ptc lib developed by Rbraz and Jim, you should read this whole topic;
**CLICK** (http://dbfinteractive.com/index.php?topic=633.0)
There are various versions of it including examples of how to use it and instal it at various places in the topic.
If you have any questions about using tinyptc, ask away, and btw :hi: to the forum.