Launchpad Usage

Started by Dabzy, Oct 19, 2024, 01:28 PM

Previous topic - Next topic

Dabzy

Using The Launchpad IDE

Using Launchpad is pretty much a breeze, not really much difference when it comes to IDE's at their basic level really, you write code in a text box, click a few things to compile code, run code etc etc... Peasy!!!

So lets begin... We'll quickly look at how to create a new project, so first off, when you open Launchpad, you'll see the main home tab.



Nothing major, this just displays a nice logo and some version history you cannot see in the window grab, anyway, go to the menu bar and click 'File->New...->New Project'. Now you should see the new project dialog box.



I've already filled mine out as you can see, a quick breakdown on what the dialog box elements mean:-

Project Name : The name of your project, but, also the name of your main .bb source file, more on that below.

Developer : Your name, your nick name, your company name, your hairdressers name if you want.

Project Path : The path to the root directory of your project and its related files, here, mine is "C:\UsageTest"

When your all done filling in your own doings... Click the 'Done' button.



If everything is tickety boo, you should now see something similar to the above, the big blue bit is where we add and edit our code, the pot that creates the magic.

A quick note about the Dialect command there, this tells BlitzCC what "style" of Blitz BASIC you want it to accept when it's building your source code, by default in Launchpad, we like it set to modern, but there is 3 options in total, "classic", "secure" and "modern", please refer to the documentation for more info on each one.

Another thing to note, the .bb file that's first created, and shares the projects name IS the main file in the project, every file after that is complimentary to this file. Why I mention this is in old skool Blitz, you can create, open whatever file in it's native IDE and compile/run that file as an individual piece of source code, in Launchpad, the main project file is concentrated on predominantly.

Okay, one last thing to do before we can have a good old play is to include an Include file relating to the DX9Lib library.

Open the the userlibs folder by clicking this toolbar icon:



The userlib folder should now appear, next, copy the file named "LP_INCLUDE_DX9.bb" to the clipboard, close the window if you wish, then open the project folder by clicking this little number:



Your project folder will open, so paste the copied file above into there, you can close the folder if you want to.

Lets get this baby motoring... In the pot of many magics, copy the code below into the IDE:-

Include "LP_INCLUDE_DX9.bb"

;DX9 window creation constants
Const resWidth:Int = 1024
Const resHeight:Int = 768
Const resDepth:Int = 32
Const resVSync:Int = True 
Const windowed:Int = True            

Local result:Int = DX9_Graphics(resWidth,resHeight,resDepth,resVSync,windowed)
DX9_SetWindowTitle("DX9Lib Example")

DX9_SetEventMode(DX9_EVENT_IMMEDIATE)
DX9_SetClsColor(0,0,0)

Local font:Int = DX9_LoadFont("Terminal",30,30,False)

Repeat
    DX9_Cls()
   
    If DX9_IsKeyDown(VK_ESCAPE)
        DX9_End()
    EndIf
   
    DX9_DrawText("Howdley Doodley",0,0,false,font)
   
    DX9_Flip()
Forever

Remember to keep the Dialect line in.



If you copied and pasted that, you would of missed a couple of Launchpad tricks, so, pick a line of code and start copying it underneath. As your typing, auto complete would of kicked in, a little list of available commands that match what your writing, and the more you write, the more the matches narrows down. You don't have to spell the whole lot, if the selection in autocomplete is the one you want, you can insert the whole lot automagically by hitting the tab key, or adding an open bracket, pressing space or even return. If though, the command you specified requires brackets, aka arguments, then as soon as you add an opening bracket, a nice little argument list tip will pop up showing what the command expects... Handy! 🙂 If you want the little list to bugger off, just tap the ESC key.

Moving on, get rid of your little edits there so the code goes back to the original you copied in. Our source code is all ready to go so lets run it... Go the menu and click 'Project->Run Project'.

The program will build, and you should get a little black window popping up saying "Howdley Doodley". Congrats, you ran your very first Launchpad project! \o/ yay



To exit the application, either click the {x} title button, or tap the ESCAPE key. Once shut down, a little message will pop up saying the application closed, and a nice little jingle will play to confirm that.

Launchpad will also tell you if something is wrong when it tries to run the program with an error, as a test, change the line:

DX9_DrawText("Howdley Doodley",0,0,false,font)

to

DX9_DrawText(Howdley Doodley",0,0,false,font)

Here, we can see there is no starting double quote character encompassing our message, so, with that edit, try and run the application again... The error will be flagged, and info will be displayed in a message box, or more specific info will be displayed in Launchpads status bar.

Sometimes, when it comes to commands, we may need a little more info on what a specific command does, or reminding what it's arguments are. For this, make sure the text area caret is on a command (By default, these are highlighted in yello), then, hit the F1 key on your keyboard. When you have done that, you'll notice that text in the main windows status bar has changed, and will show you a little tip, for more info, hit the F1 key again, and a HTML window with more specific help will open, this is connected to the online help. Many Blitz related stuff is heavily documented, but, it is work in progress, some stuff might change, hey, my website might throw a tit fit and go down, or more then likely, I've forgot to add stuff! :D

With the meat of the usage of Launchpad out of the way, we'll look at other items in Launchpad. Most stuff is your age old notepad stuff like copy and paste and all that, and other stuff speaks for itself just by looking at it (Like 'Open Project Folder').

First off, the menu item 'Project->Project Information' is a little window that shows some details about the project, obviously...



The main aspect in this is basically just for peeping sake, though, if you require a project to be a 'default' project, as in, want a project to open when you open Launchpad, then check the "Set As Default Project" checkbox.

Next up, we have 'Project->Project Explorer', this is just a dialog that shows what files are in your project, and you can open said files into Launchpad from here to... Nothing much really.

In the menu, if you click Tools->TestPad, a new window will pop up with a text editing control just like the main one you use when writing code for your project, think of it as a programmers jot pad. This is a little test area where you can write and run little snippets of code without affecting your main project code. There isn't much in it in regards to features, menus and other guff... Any text/code in there is saved.

One final thing to note, when you first run the Launchpad IDE, the colours and font used may not be your cup of tea, so, before you do anything really, head into the menu item Edit->Edit Area Options... bit, and twiddle the knobs to get the text area font and colours how you like them.

And that's pretty much it for that me auld fruit.

Dabzy
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Dabzy

#1
Building Blitz compatible DDL's in Visual Studio 2022 Community Edition

First off, if you don't know what a Blitz 'userlib' is, before moving on, please read the UserLibs.txt file located in the '/userlib' folder to get a general idea of them.

Right, to actually build a DLL, you'll need to download and install Microsoft's Visual Studio, more notably for this tutorial, Visual Studio 2022 (Community Edition). Note: MS seem to always keep the latest version publicly available, but, when that version is superseded by a newer version, they tend to remove the older version, which is then only available via a MSDN subscription. So if the link doesn't point to the 2022 version anymore, you should be able to find it at places such as archive.org.

Moving on, download and install* that, then run it, and you should see the VS 2022 landing window, to the bottom left, there is a "Continue without code" link, click that and the Visual Studio editor will open.

Head into the menu and click the File->New->Project... item.

A new dialog will pop up displaying all the different types of projects we can build with Visual Studio, the list of these is to the right hand side, the one we want is the "Dynamic-Link Library" project, which can be found if you scroll down the list a little bit. Once you've found it, double click it to select it to move along.

Once sorted, we now have to configure our DLL project, first off, by giving our project a name, here we'll name it "TestDLL", and we'll change the location of the project to something of our own, I've created a new folder on C: root drive called the same as the project name, so my path will be "C:\TestDLL", all in all, if you did the same, you should have something like this:-



When all good to go, click the "Create" button, Visual Studio will setup the project accordingly, and you should be greeted with code editing area and other odds and ends.

We'll need to do a quick rename of our main C++ file before moving on... BUILD_DECLS requires the C++ source file to be the same name as the DLL we'll build. Cast your eyes over to the right hand side of the editor and you will see the Solution Explorer area, which has a list of different types of files you can have within your project. Open the "Source Files" tab, and then rename the file "dllMain.cpp" to "TestDLL.cpp".

We'll build this skeleton without changing anything else at the moment to see that all is well, and then take a look where Visual Studio has built and plonked our little DLL on the system, so head up to the menu, and click Build->Build Solution, you'll see a little bit of activity going off in the Output pane at the bottom, once it's done it's doings, there should be a line in there stating that '1 succeeded', this is to confirm everything is alright! :)

So, where has Visual Studio put our little DLL then? Well, if you set out the DLL project like I did, you will indeed find the 'TestDLL.dll' in the folder "C:\TestDLL\TestDLL\x64\Debug". Which is nice.

But, we have a little problem here, as you can see, it's built a x64 version of the DLL... Which is a bit of an issue in regards to Blitz userlibs, as they are only x86 compatible, because, well... BlitzCC generates x86 apps and you cannot mix'em. Easy fix though, in the Visual Studio editor, you will see two white drop down list boxes, one will say 'Debug', and the other will say 'x64', change these to 'Release' and 'x86', then rebuild it again like we did before.

Now, if we look, we should see that Visual Studio has built and placed the DLL in the folder "C:\TestDLL\TestDLL\Release".

But this means we need to move the DLL manually into the "/userlibs" folder, the same folder you found the UserLibs.txt file in.

So lets change that in the VS settings... Click the menu item Project->Properties to bring up the project properties dialog, and in the list to the left, click the item 'Linker', the dialog will change, but you'll notice at the top on the right hand side, you'll see a linker property called "Output File", and it'll probably have text in it like "$(OutDir)$(TargetName)$(TargetExt)", you can see what it's getting at, but, we'll wipe that text clean, and add the absolute path of where we want the outputted DLL to go. So, on my system, the Launchpad zipped file has been unzipped to the C: root, and the directory renamed to "Launchpad_1_6", thus, the text I will add to that property will be:-

C:\Launchpad_1_6\userlibs\TestDLL.dll

Click the "Apply" button, then rebuild, afterwards, head over to the userlibs folder and voila... Our little DLL should be there. \o/ yay

One thing left to change while we are editing the projects properties is to change the character set, we need to do this to stop VS throwing some errors on building our DLL. It's easy, in the list to the left where we found the "Linker" item, you should see another item called "Advanced", click that, then, on the editity properties bit to the right, scroll down slightly and change the item "Character Set" from

Use Unicode Character Set

to

Use Multi-Byte Character Set

Click "Apply" and then "OK" to head back into main editor section.

Okay, we're all done with that... Phew... I mean, it doesnt take 2 minutes, but explaining it feels like a life time! :D lol

Now we are back in the editor, we will get rid of all the text in the text editor apart from the line:-

#include "pch.h"
Keep that in, everything else, just remove and replace with the following:-

#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall
#define BBPTRSTR const char*
#define BBPTRVOID void*

BBDECL BBPTRSTR BBCALL ReturnString(BBPTRSTR str) {
    //Return our pass string.
    return str;
}

You probably read about BBDECL and BBCALL already, but I will highlight the BBPTRSTR and BBPTRVOID define statements. Basically, BBPTRSTR represents a string ($), and BBPTRVOID represents a bank or object! :D

Anyway, rebuild, check if the DLL is there, and we'll move back into working within Launchpad to use the brand new fresh out of the box super doper command known as ReturnString()! ;)

Okay, open Launchpad and create a new project, put this anywhere you like. In the new file, add the following (That is, if you followed the same steps I have):-

Print ReturnString$("Hello you... I've just been in a DLL!!!")

Then run the app as normal... And... Wahey... The ReturnString() command in the TestDLL.dll file would of been called, and there we go, in goes your eye out. If you peek inside the /userlibs folder, you should now see the TestDLL.decls file that BUILD_DECLS created.

And that's it really... How handy is that! :) hehehe

Initially Launchpad will not format the new command with syntax highlighting or include it in autocomplete, this only occurs when the project/file is opened, but, you can safely keep the project open as BlitzCC will always look at the userlibs folder when you run an application, so there is no need to close the project when you add new commands to the source/DLL.

I don't think there is anything else to note really, everything in regards to that side as in using WinAPI, or implementing third party libraries within a DLL is pretty much out of the realms of any tutorial here, if your wrapping something, then, more so then anything else... Google will be your friend.

Dabzy

*When I was installing Visual Studio 2022, at the time, I added "Desktop development with C++", "MFC and ATL support" and "ASP.NET and web development" as optional MSVC components. Not that it should make a difference here in regards to this, but, I'll just put it out there. If you need to install any components like this, you can do so using the VS 2022 installer which is located in the Windows Start menu, under "Visual Studio 2022" or using the NuGet package manager within Visual Studio itself.
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit