Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Recoil

Pages: [1] 2 3 ... 6
1
DotNet / Re: SFML on Linux with MonoDevelop
« on: February 17, 2020, 01:47:50 pm »
Thanks for the reply Balnian.

I've been trying to get simple projects up and running in both MonoDevelop and Visual Studio Code IDE's, but with both I am running into dependency issues (wrong version, unable to locate, etc.).  I do have the latest .Net Core installed on this system, but being new to using Linux I am honestly not sure if everything is configured correctly - which is most likely the root of the problem.

I guess I have been pampered using Visual Studio on Win7 for so long that switching to anything else has been difficult.  It looks like if I want to continue with SFML I am going to have to install Win10 and sell my soul back to M$FT  :-[

2
DotNet / SFML on Linux with MonoDevelop
« on: February 16, 2020, 06:53:53 pm »
I recently moved from Windows 7 and Visual Studio to Linux Mint and have been trying to get projects working in MonoDevelop, but kept running into a whole bunch of issues so I decided to just try to start from scratch and pull in what I previously wrote later.

I should note that I have diligently tried following advice on previous posts regarding setting up config files to point to .so files from .dll libraries, but was not successful as the error said:

Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. - which I cannot find.

This is what one of my config files loo like:
sfml.graphics.dll.config
&#38;#65279;<?xml version="1.0"?>
<configuration>
    <dllmap os="windows" dll="csfml-graphics-2" target="csfml-graphics-2.dll"/>    
    <dllmap os="linux" dll="csfml-graphics-2" target="libcsfml-graphics.so.2.2"/>
</configuration>
 

So I am trying to get a simple C# or VB.NET Hello World application up and running with MonoDevelop and SFML, yet keep running into issues with the references, either the .dll files pointing to .so files, or trying to use the SFML.NET package.  I have tried so many things it would be difficult to list them all and their errors trying to piece something together.

So I really hate to ask, but does anyone have a working hello world project they would be willing to share that works with MonoDevelop on Linux?

I am just so lost on getting anything working on this OS.

3
SFML development / Re: Window state
« on: July 20, 2019, 04:24:57 am »
Sorry to necro this post, and I know it is over a year old, but has there been any update to implementing minimize and maximize states?  My Google-fu has failed to find a working implementation of doing this programmatically.

I'm creating a borderless render window, and using a custom form that can be skinned (with a theme soon).  I can get the close button to work, and if this was a windows form I could go that route, but I am using .NET Core and this functionality does not exist.  I can clunkily maximize the render window, but there is no option to set the visibility = false and keep the icon in the taskbar for setting back to visibility = true.

4
DotNet / Re: Multi-threading SFML Render Window
« on: July 15, 2019, 07:43:13 pm »
After taking some time to mull this over, it doesn't matter what I do the form events are going to overtake any threading that I setup...

However, trying another route on customizing a form I found that if I set the form style to None and handled all my screen placement and resizing on my own, while it still bogs down a little, it still performs the operations.

My code probably will not help anyone else, but these links I went off of probably will:

Moving Borderless Windows
How to make the entire window draggable?


5
DotNet / Re: Multi-threading SFML Render Window
« on: July 10, 2019, 03:42:35 pm »
Thanks again Hapax!

It's been a few days because I have been trying to get justification working right on my control labels.  I finally got time to work up a test utilizing the TimeStep class you helped me with previously.

It contains a function OutOfSync that returns to allow the program to process all movements.  This part works until the window is moved or resized then halts processing until I release the window, then it continues the movements being done from where they stopped at.

This is not an overly huge issue as on a single player game it is like pausing it, and a multiplayer game the positions would be updated from the server anyways as soon as it got a chance.

I think I was looking at this the wrong way to be honest, because it would be the server portion that would pause if moving or resizing the window that would cause an interference.  While this is not likely to happen, it was something I though may be an issue at some point with updating the clients.  I may have to look at a different setup if using a server to host games with.

6
DotNet / Re: Multi-threading SFML Render Window
« on: July 01, 2019, 07:32:51 pm »
Thanks Hapax!

I'm not sure I need to do anything TBH.  But when I move the window and the UI info text updates, I get a spike in cycles per second from the timer, and a dip in FPS, but only for a brief second or two.  I'm not sure if that means the loop is catching and not processing, or simply processing but not updating the graphics.

I can't step through the debugger while I drag the window around to check.  Is there any way to actually tell?

7
DotNet / Multi-threading SFML Render Window
« on: July 01, 2019, 04:00:30 pm »
I have a Render Window working that is used to test objects and text drawn to it.  That Render Window is in a class called Engine, that handles all the initializations, program loop, render window events, and disposing.

My Sub Main() initializes an Engine instance, and runs the Engines loop.  When I move or resize the Render Window the program freezes until I let the mouse go.  So now I need to multi-thread the SFML's already multi-threaded render window.  However, when putting the Engine's instance on a separate thread to initialize and run the program loop, I run into the same thing of freezing while I am moving or resizing the window.  This make sense as pretty much nothing has changed, and only forwarded the issue to a new thread, yet I am not sure where to handle the freezing issue at so when I move or resize the screen the program keeps cycling.

I'm not sure how good a code example will work in this instance, but it is VB code so as close to pseudo code as possible...

Main Module:
Module Test

    Public Enum State

        Initializing
        Running
        Stopped

    End Enum

    Private m_Engine As Engine
    Private EngineThread As Threading.Thread

    Sub Main()

        EngineThread = New Threading.Thread(AddressOf EngineStart)

        EngineThread.Start()

    End Sub

    Private Sub EngineStart()

        m_Engine = New Engine(True)

        m_Engine.Initialize()

        Do While m_Engine.EngineState = Engine.State.Running

            m_Engine.Run()

        Loop

        m_Engine.DestroyEngine()

    End Sub

End Module
 

Engine Class:
    Public Sub New()
    End Sub

    Public Sub Initialize()

        SetState()

        ResetClock()

        SetContextSettings()

        CreateNewRenderWindow()

    End Sub

    Public Sub Run()

        CalculateTime()             ' process timing stuff

        PrepareScreens()            ' set view, dispatch events, clear

        DrawStuffToScreens()        ' entities, gui, text

        PresentScreens()            ' display

    End Sub
 

The Render Window is already handling any window events, keyboard input, mouse actions, and joystick events by default, so I am not sure where, or how, to allow the program to continue to process while I am moving or resizing the window.  Is this just a default of using the SFML RenderWindow?

8
DotNet / Re: Custom Shape with Texture
« on: June 30, 2019, 02:17:16 pm »
I have tried implementing shaders in vb.net previously, and come across the example you linked for something that "looked" simple enough to get converted into the language.  There are a few things I could never get translated over because I do not believe there is a way to do it in vb.

Anything with the "Uniform" keyword:
"uniform vec4 color;"
 

And this, it is assigning variables from other variables, but those variables aren't defined anywhere in the code:
const char VertexShader[] =
"void main()"
"{"
        "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
        "gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;"
        "gl_FrontColor = gl_Color;"
"}";
 

Sometimes I think I am the only hobby programmer here using vb.net for their choice of language to use, which means anything I want to do I am kinda breaking new ground with.  But it looks like in order to use shaders at all I would have to switch to a language with brackets...I'm just not that smart  :D

9
DotNet / Re: Custom Shape with Texture
« on: June 29, 2019, 05:03:02 am »
The Sprite was used to draw the RenderTexture exactly the size, shape, and location to demonstrate what I was pulling the texture from, and what it looked like.

And that was what I was trying to do - draw the shape with vertex points, then set a RenderTexture over that.  However, the only method I knew to try is drawing the vertices with a color, then drawing that to the screen.  I was not able to use a RenderTexture over that even when removing the colors.  The only way I could get this to work correctly was with actual shapes from the SFML Shape class.

I fixed the class file so it works, but it is completely different from the C++ example of a rounded rectangle, because I had issues moving the starting points where the radii are, which gave me a rectangle with blobbed corners.  When I converted this to VB code there was no way I could figure out to correct those points, without overriding the whole base Shape class to accept a vertex array on GetPoint function...which is a bit too much work to take on.

Here is an example that I am doing now.  All 4 RenderTextures are drawn at point (0, 0) and a size of (100, 100).  I am not using a sprite to show where they are.  This is using my new class, with a different RenderTexture for each one used:


The rounded gradient could use some work, but I know how to fix that by drawing a larger rounded rectangle with gradient colors for the points.

Thank you for the example.  Since I have been working on converting C++ examples it is easier to understand what is going on under the hood, and how to make things work for me, and what wont.  I am going to give that a shot when I have some free time after the weekend.

10
DotNet / Re: Custom Shape with Texture
« on: June 28, 2019, 12:17:31 am »
I already have it set where I can use .png images for controls, but I was going to try and convert some of what you have on Selba Ward eventually for this thing because I would like to use the Bitmap Text.  Converting from C++ takes some time though  ;D

However, yes I have tried plotting the TexCoords when I set the positions, but it isn't plotting them from anything if that makes sense.  I have the original rainbow gradient RenderTexture1 drawing at the top.  I draw the vertices of a n-sided shape on RenderTexture2, along with the TexCoords set to RenderTexture2's position.  Then I can draw a Sprite onto the RenderWindow using 1 RT or the other.  But I don't know how to draw the vertices and apply a texture that display over them and not have to use colors.

I don't get the option to set the TexCoords along with what RT they are using:
        Dim position As New Vector2f(0, 0)
        Dim size As New Vector2f(150, 50)

        m_renderTexture2 = New RenderTexture(150, 50)
        m_renderTexture2.Clear()

        Dim v0 As New Vertex
        v0.Position = New Vector2f(position.X + 5, position.Y)
        v0.TexCoords = New Vector2f(position.X, position.Y)

        Dim v1 As New Vertex
        v1.Position = New Vector2f(position.X + size.X - 5, position.Y)
        v1.TexCoords = New Vector2f(position.X + size.X, position.Y)

        Dim v2 As New Vertex
        v2.Position = New Vector2f(position.X + size.X, position.Y + size.Y)
        v2.TexCoords = New Vector2f(position.X + size.X, position.Y + size.Y)

        Dim v3 As New Vertex
        v3.Position = New Vector2f(position.X, position.Y + size.Y)
        v3.TexCoords = New Vector2f(position.X, position.Y + size.Y)

        m_renderTexture2.Draw({v0, v1, v2, v3}, PrimitiveType.Quads)
        m_renderTexture2.Display()

        Dim sprt As New Sprite(m_renderTexture2.Texture, New IntRect(0, 0, 150, 50))
        sprt.Position = New Vector2f(20, 100)
        m_engineWindow.Draw(sprt)
        sprt.Dispose()

        m_renderTexture2.Dispose()
 

I can still draw a radial gradient shape though, but I cannot apply a separate RT onto it, like in this image:


Right now I am considering just doing a ConvexShape for a rounded rectangle so I can apply a RT over that, but it is going to take some work to get running.  It is probably my best option.

Edit:

And that is exactly what I did - used a ConvexShape, along with all the code you helped me out with for drawing the radial gradient a while back, and applied the RenderTexture over it.  I may create a new thread with a class file for a textured rounded rectangle and update this thread with a link for people searching.



11
DotNet / Re: Custom Shape with Texture
« on: June 27, 2019, 10:11:23 pm »
The bulk majority of people here don't program in VB.NET or C#, so it's understandable  :).  I appreciate all the advice I can get.

As far as this example goes, I was using a RectangleShape, CircleShape, and ConvexShape, with the texture for them coming from the RenderTexture.  The top left square is drawing the vertices straight to the screen jut to show what and where the RenderTexture is.  The offset issue makes complete sense now.


However, I didn't know I was still having issues drawing a render texture over a set of vertices.  I wanted to be able to draw any shape with vertices and texture over them with any texture (vertical/horizontal/radial gradients).  While this process works for existing Shapes, it will not work for something like the rounded rectangle where I have to set the individual points with colors and draw to the screen.

This example I am drawing all the vertices of a rounded rectangle directly to the screen (since you helped me previously with that and I had that shape).  It is drawing at position (0, 0) for clarity with the cyan/magenta gradient.  For the same points I am drawing to a RenderTexture as well at the same location.  To the right is a Sprite with the texture from the first RenderTexture, and under that is a Sprite with the second RenderTexture.  The problem I am having is being able to keep the shape, but overlay another texture onto it.  For example, take the texture from the top right sprite, and overlay it onto the bottom right sprite white keeping the same shape that I drew all the vertices for.


So in the next post I decided to try and convert the C++ RoundedRectangle class and use it.  Because it is a shape I can texture it just like I do the ones in the first image, and it looks like that part works.  However, the problem I am running into with using that shape class is a bit over my head as I do not know how to correct the points.  I'm not sure if this has something to do with the base Shape class, or how I have converted to GetPoint function, but my lack of C++fu probably doesn't help.


All this is for my graphics control library I have been working on/off with for a while now.  It took forever but I finally nailed down passing click events for drawn objects in order to make controls, since I could never get any of the preexisting control libraries to work in VB.NET.  The base class handles drawing the shapes of each control, so the appearance effects is applicable to a panel like it is a button.  Having customizable shaped controls would be great, but not necessary.  I feel like I am close to resolving this one way or another though, and there might be another way I have not even thought of yet to make this work.

12
DotNet / Re: Custom Shape with Texture
« on: June 27, 2019, 02:32:36 pm »
For some reason I can draw a vertical/horizontal render texture to actual SFML shapes, but not drawn points like I am creating for the rounded rectangle with the triangle fans.  So I am approaching this another way different from the previous reply and edits.

I am making an attempt to convert this so I can use it like other shapes:
Source: Draw Rounded Rectangle

Here is the class I have converted from that link:
Imports System.Math
Imports SFML.System
Imports SFML.Graphics

Public Class RoundedRectangleShape
    Inherits Shape

    Dim mySize As Vector2f
    Dim myRadius As Single
    Dim myCornerPointCount As UInteger

    Public Sub SetSize(ByVal size As Vector2f)
        mySize = size
        Update()
    End Sub

    Public Function GetSize()
        Return mySize
    End Function

    Public Sub SetCornerRadius(ByVal radius As Single)
        myRadius = radius
        Update()
    End Sub

    Public Function GetCornerRadius()
        Return myRadius
    End Function

    Public Sub SetCornerPointCount(ByVal count As UInteger)
        myCornerPointCount = count
        Update()
    End Sub

    Public Overrides Function GetPointCount() As UInteger
        Return myCornerPointCount * 4
    End Function

    Public Sub New(ByVal size As Vector2f, ByVal radius As Single, ByVal cornerPointCount As UInteger)

        mySize = size
        myRadius = radius
        myCornerPointCount = cornerPointCount
        Update()

    End Sub

    Public Overrides Function GetPoint(ByVal index As UInteger) As Vector2f

        If index >= myCornerPointCount * 4 Then

            Return New Vector2f(0, 0)

        End If

        Dim deltaAngle As Single = 90.0F / (myCornerPointCount - 1)
        Dim center As Vector2f
        Dim centerIndex As UInteger = index / myCornerPointCount
        Dim pi As Single = 3.14159274F

        Select Case (centerIndex)
            Case 0
                center.X = mySize.X - myRadius
                center.Y = myRadius
            Case 1
                center.X = myRadius
                center.Y = myRadius
            Case 2
                center.X = myRadius
                center.Y = mySize.Y - myRadius
            Case 3
                center.X = mySize.X - myRadius
                center.Y = mySize.Y - myRadius
        End Select

        Return New Vector2f(myRadius * Cos(deltaAngle * (index - centerIndex) * pi / 180) + center.X, -myRadius * Sin(deltaAngle * (index - centerIndex) * pi / 180) + center.Y)

    End Function

End Class
 


Implementation in loop:
Dim roundedRectangle As New GFX_Control_Library.RoundedRectangleShape(New Vector2f(75, 25), 5, 3)
        roundedRectangle.SetSize(New Vector2f(75, 25))
        roundedRectangle.SetCornerRadius(5)
        roundedRectangle.SetCornerPointCount(3)
        roundedRectangle.Position = New Vector2f(140, 20)
        roundedRectangle.OutlineThickness = 1
        roundedRectangle.OutlineColor = Color.Blue
        roundedRectangle.Texture = m_renderTexture.Texture
        roundedRectangle.TextureRect = New IntRect(20, 20, 95, 45)
        m_engineWindow.Draw(roundedRectangle)
 

Here is my result:


I will be honest, I do not fully understand how this is working as the GetPoint function in the class works differently than the way points are being set drawing a rounded rectangle with triangle fans.  However, it looks like the 2 points on the right side are pulled to the left, and I have no idea where to start on correcting that.

Please tell me someone understand what is going on  :-[?

Edit:

Okay, so  looped through the debugger and noticed that it was only hitting [Case 0] 3 times while it hit the others 5, then looping through twice and returning the last 2 set values instead of a Case.  So I added this to the bottom:
Case Else
                center.X = mySize.X - myRadius
                center.Y = myRadius
 

I increased the radius size to 10, and this is what I get now:


So I'm getting closer, but I do not see a way to pull back the starting points.  After messing with a few settings I noticed this is drawing backwards, with position 0 at the top right, position 1 at the top left, and continuing counter clockwise.  It is drawing in the correct position I set it to though.

I believe this issue has something to do with the way the base Shape class draws the custom shapes, but honestly am not certain.  I'm hoping for some ideas on what I might be doing wrong so the starting points of the radii can draw in the correct position.

13
DotNet / Re: Custom Shape with Texture
« on: June 26, 2019, 09:18:51 pm »
Thanks Hapax for the example, but I think it is above my head in reference to what you are setting the vertex TexCoords to for the new shape.

I have simplified an example of what I am currently doing.  The set of vertices for the top image are at coordinates (20, 20) and a size of (100, 100), and I draw that to a render texture.  I'm not able to draw the render texture to the render window, so I draw a sprite for the RenderTexture.Texture, then draw that sprite to the screen.

Private Sub DrawControlShape()

        Dim posX As Integer = 20
        Dim posY As Integer = 20

        Dim v0 As New Vertex
        Dim v1 As New Vertex
        Dim v2 As New Vertex
        Dim v3 As New Vertex

        ' Set positions
        v0.Position = New Vector2f(posX, posY)
        v1.Position = New Vector2f(posX + 100, posY)
        v2.Position = New Vector2f(posX + 100, posY + 100)
        v3.Position = New Vector2f(posX, posY + 100)

        ' Gradient colors
        v0.Color = Color.Red
        v1.Color = Color.Blue
        v2.Color = Color.Yellow
        v3.Color = Color.Green

        ' Draw to show working
        m_engineWindow.Draw({v0, v1, v2, v3}, PrimitiveType.Quads)


        ' Create render texture
        m_renderTexture = New RenderTexture(100, 100)
        m_renderTexture.Clear()
        m_renderTexture.Draw({v0, v1, v2, v3}, PrimitiveType.Quads)
        m_renderTexture.Display()

        ' Create sprite
        m_sprite = New Sprite(m_renderTexture.Texture)
        m_sprite.Position = New Vector2f(posX, posY + 100)
        m_sprite.TextureRect = New IntRect(0, 0, 100, 100)

        ' Draw to show working
        m_engineWindow.Draw(m_sprite)

    End Sub
 
While this may be a separate issue, I do not understand why I have an offset when drawing the sprite from the render texture:


At any rate, when I create a rounded rectangle shape with vectors and triangle fans, I am not sure what to set each vertices to:

v0.TexCoords = ?
 

Edit:

Okay, so I don't need the sprite.  Once I draw the vertices to the render texture I have to set the texture and textureRect of Shapes (rectangle/circle/convex/etc).  I was thinking this had to be done another way.  I still don't fully understand the offsets for the positions and textureRects, but I'll work it out.



Edit2:

It doesn't seem that I am able to apply the same vertical/horizontal gradient effect over the rounded rectangles.  I can draw all the points with a circle gradient like normal to a render texture, then draw a new rectangle shape to the screen with that same render texture, but unable to apply another texture on it that keeps the fan edges and draws just a gradient rectangle instead of a rounded one.

14
DotNet / Custom Shape with Texture
« on: June 26, 2019, 05:41:13 pm »
I'm trying to create the graphics for custom shaped buttons.

Currently I can draw a vertex array with 4 points to the screen and set the color of those points to get a solid color shape or gradient shape for a simple rectangular button.

I can even set a sprite from .png image to draw for the button as well.

Instead of drawing a vertex array, or a simple RectangleShape, I would like to draw any shape, and use a rectangle RenderTexture (or other texture), for that shapes texture.

For instance, if I draw a rounded rectangle, I have to draw 5 attached rectangles (center, top, bottom, left, right), then draw a triangle fan at each corner.  I can set all the points to the same color for a solid color.  I can also set the center rectangle points and the triangle fan corner points to one color, and all the outside points to another color for a radial gradient.  However, I cannot apply a vertical or horizontal gradient effect from a rectangle texture over that set of vertices.


I'm not sure if what I am trying to achieve is clear, so I have attached a mock-up image showing what I want to do.  I'm merely looking for the logic of the best way to go about doing this.

15
DotNet / Re: [Solved-ish] Layer lighting help
« on: June 17, 2019, 07:02:12 pm »
And they all have alpha == 255, right?

Yes and no.  In those images the alpha value is turned all the way up to 255 for the black and white areas of the RenderTexture overlay and triangle fan light source.  I have a day/night system that changes the lighting value, so the alpha value on the RenderTexture, and .png or triangle fan increases as the level changes.

I am probably doing this all backwards though now that I think about it.  I'll have to come back after I try a few things.

Edit:

Okay, so I had to go back and pretty much change all my lighting levels, and which way they increased/decreased.  Before when I increased the alpha value (0->255) I was setting how dark the level was.  It was because how I was +/- the level in the engine timer.

Even though using the .png light was working, it threw me off on how I was calculating the alpha values for the circle fan shape gradient.  Now I get the same effect if I am using the .png or the circle fan, with no Venn diagram effect  :-[

Pages: [1] 2 3 ... 6