Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Basic DX8 rendering


santa-clause
 Share

Recommended Posts

Hello everyone,

Some info about tutorial:

Difficulty: normal

Supported engines:

-CS:DE

-Mirage source

-Eclipse advanced

-All other engines based on CS:DE

-It can work with other dx8 engines like EO3.0 and all others but the modules and some names of classes are different that's all but the logic behind it is the same.

Credits: Santa-Clause

Special Thanks to: Thomas And Robin (for making these awesome engines)

**Chapter 1: Rendering a guiwindow**

So here i will explain how to render a guiwindow

The first thing you do is go to modrendering and scroll all the way down.

Then make a sub (in this example we will use DrawTest)

```
Public Sub DrawTest()
Dim X As Long, Y As Long, Width As Long, Height As Long

X = GUIWindow(GUI_TEST).X
Y = GUIWindow(GUI_TEST).Y

Width = GUIWindow(GUI_TEST).Width
Height = GUIWindow(GUI_TEST).Height

Directx8.RenderTexture Tex_GUI(2), X, Y, 0, 0, Width, Height, Width, Height
RenderText Font_Default, "Test Window", (GUIWindow(GUI_TEST).Width / 2) - EngineGetTextWidth(Font_Default, "Test Window"), Y + 5, White
End Sub
```
[attachment=916:delala.png]

(GUIWindow(GUI_TEST).Width / 2) - EngineGetTextWidth(Font_Default, "Test Window") This line of code does the following:

Guiwindow(GUI_TEST).width gets the width of the window ofcourse and he devides that by 2 so half the window.

Then he does Enginetextgetwidth whit fontdefault and for test("Test window) and he also devides that by 2 so this text will be on top of the window and centered

And Directx8.rendertexture TEX_GUI(2),x,y,0,0,width,height,width,height simply renders the image whit the name 2.png from the gui folder.

Warning: make sure you all numbers in gui folder are consecutive.

Now in initialisegui in modgeneral:

```
' 21 - Test
With GUIWindow(GUI_TEST)
.X = 300
.Y = 100
.Width = 257
.Height = 152
.visible = False
End With

```
So this just defines the posision and the height and width of the window(picture).

At the end of Public Enum GUIType

add GUI_TEST

Warning: put it above GUI_COUNT

In Public Sub DrawGUI() Add:

```
If GUIWindow(GUI_TEST).visible Then DrawTest

```
**Chapter 2: Clicking**

Here i will talk about how to make windows clickable

Ok so what you wanna do first is test if the window you've rendered is actually rendering correctly then go on and follow this

Now in Public Sub HandleMouseUp(ByVal Button As Long)

add this at the end before end select:

```
Case GUI_TEST
Test_mouseup

```
So this just sends the client to another sub when it sees that GUI_TEST is clicked (mouseup)

(no need to explain it i think)

```
Public Sub Test_mouseup()
Dim X As Long, Y As Long
X = GUIWindow(GUI_TEST).X
Y = GUIWindow(GUI_TEST).Y

If GlobalX > X+35 And GlobalY > Y+54 Then 'Point 1
If GlobalX < X+3 And GlobalY < Y+23 Then 'Point 2
Call Something
End If
End If

End Sub

```
So this actually does what it needs to do if you click it

Normally you just put all those coordinates in one if but i devided into 2points and i'll explain in the picture under this text:

[attachment=917:tutorial.png]

I can add extra Chapters if you want

I hope you all enjoyed this tutorial and i hope it's usefull it's pretty basic but i didn't wanna make it too hard for a first tutorial on this forum about rendering in dx8.

Please like tutorial if it helped you or if you just like it :)

You can also use Paint.net for coordinates i also use it its very handy you can see pixel coordinates at right bottom. :)

Regards Santa,
Link to comment
Share on other sites

> This is a useful tutorial for those who don't know a single thing about how a GUI renders. Don't say it's easy, you had to learn how to walk just like the rest of us.

It's called a basic tutorial for something :p

I'm also aiming for beginners not for ppl like general awesome but whatever.

Tnx for reply ;)
Link to comment
Share on other sites

  • 7 months later...
Just realized that you're using the standard first quadrant graph to represent a 2D computer view.

I personally think this is a extremely bad way to represent things.

It should be more like:

![](http://i.imgur.com/GqhgbCZ.png)

Whilst both the X and Y values start at 0 and increase to infinity, as happens in the first quadrant, the quadrant that better represents them in this case is the 4th one with the Y values inverted.
Link to comment
Share on other sites

> Just realized that you're using the standard first quadrant graph to represent a 2D computer view.
>
>  
>
> I personally think this is a extremely bad way to represent things.
>
>  
>
> It should be more like:
>
> ![](http://i.imgur.com/GqhgbCZ.png)
>
> Whilst both the X and Y values start at 0 and increase to infinity, as happens in the first quadrant, the quadrant that better represents them in this case is the 4th one with the Y values inverted.

True, i'll maybe change it some day.
Link to comment
Share on other sites

I might sound like a total noob right now (which I kind of am) but for some reason I can't seem to find modRendering, I'm using EO 3.0 - Electrified Events which (from what I know) was the first Eclipse Engine using DirectX 8\. If the rendering module simply is named something else in EO 3.0 and somone knows it, please answer me. I have found a class module called cGDIpRenderer, however, since I don't want to mess something up I would rather take the safe before the unsafe and ask here on the forums first. cGDIpRenderer is located in the client.vbp if anyone wants to know.
Link to comment
Share on other sites

> I might sound like a total noob right now (which I kind of am) but for some reason I can't seem to find modRendering, I'm using EO 3.0 - Electrified Events which (from what I know) was the first Eclipse Engine using DirectX 8\. If the rendering module simply is named something else in EO 3.0 and somone knows it, please answer me. I have found a class module called cGDIpRenderer, however, since I don't want to mess something up I would rather take the safe before the unsafe and ask here on the forums first. cGDIpRenderer is located in the client.vbp if anyone wants to know.

Actually this engine was made for CS:DE, Mirage Source, Eclipse Advance and all other things that are based on CS:DE.

But ir should also work on eo3.0 with some customizations
Link to comment
Share on other sites

> CSDE is more a modification to EO that was released years ago. not sure if you can get it anywhere anymore but yea.

CS:DE isn't a modification to EO just released to the public.

CS:DE or Crystal Shire:Developers Editor was and engine developed by Robin whom AFAIK created the Eclipse Origins engine. He left after EO 2.0 and created his own game: [CrystalShire](http://Crystalshire.com). He made a major change to his game by adding in a better graphics management and revamped the login system. He sold the "old" game and after that he just released it. 

You can get it by downloading Robin's Amazing bundle found in the resources section.
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...