I used both, in my opinion OpenGL.NET is better because it's actively maintained and much easier to set up to use than OpenTK. I remember having problems with OpenTK when trying to set it up with an existing SFML context.
OpenGL.NET also supports System.Numerics types (vectors and matrices) which i'm a huge fan of compared to rolling your own vectors mainly because they support SIMD and because of the huge amount of implemented methods.
I'm using monogame and for better or worse I don't bother with the pipeline. I simply load in texture like this.
private Texture2D SpriteLoader(string filePath)
{
using (var stream = TitleContainer.OpenStream("Content/" + filePath))
{
return Texture2D.FromStream(this._graphicsDevice, stream);
}
}
Then I save those textures in memory on game startup in a singleton I can access anywhere.
SystemT = new Dictionary<string, Texture2D>();
...
SystemT.Add("city_layer1", SpriteLoader("System/city_layer1.png"));
Then when I want to draw I do something like.
spriteBatch.Draw(SystemT["city_layer1"], new Rectangle((int)renderLocation2.X, (int)renderLocation2.Y, 69, 69), new Rectangle(0, 0, 69, 69), Color.White)
Like you said, there's really no real good documentation on best practices so it's up to you to find what works and just roll with it.
The one tip i'll give you is when you start making classes like : GrassTile, CarpetTile, DirtTile etc. it's good to indication to abstract that out into maybe a Tile class that can take properties such as tileName, defenseBonus, sprite, and everything else you need to define tiles such as a grass tile or a carpet tile.
public class Tile
{
string name,
int defbonus,
string textureName
public Tile(string name, int defbonus, string textureName)
{
this.name = name;
this.defbonus = defbonus;
this.textureName = textureName;
}
public Draw(SpriteBatch sb, Vector2 renderloc)
{
sb.Draw(resourceSingleton.instance.tileTextures[textureName],renderloc,Color.White);
}
}
...
Tile carpetTile = new Tile("carpet", 69, "carpet.png");
Tile grassTile = new Tile("grass", 24, "grass.png");
But learning what to abstract is a hard part of programming, and finding a balance can be difficult so don't worry too much about it.
I'm loading Textures in my Monogame project similar to this, but I'd recommend storing the Texture2D in the Tile class, like in the following:
public class Tile {
//other properties
Texture2D texture;
public Tile(string textureName, /*more properties*/) {
this.texture = resourceSingleton.instance.tileTextures[textureName];
}
public Draw(SpriteBatch sb, Vector2 renderLoc) {
sb.Draw(texture, renderLoc, Color.White)
}
}
If you access the singleton every time, then on every frame that the tile gets drawn, the program will have to hash out the string, and then search for the Texture in the singleton. This can cause problems if you have a lot of tiles being drawn at once, as the program gets stuck doing a ton of busywork that it reasonable could have done just once in the constructor.
I just finished a phone interview with a manager at Blackberry QNX, overall I'd say things went well. The interviewer said that they almost exclusively deal in C programming which I don't know too well but I mentioned that it's something that I'd be willing to learn. The interviewer asked me look at low level C examples and Linux kernel services to see if that's the kind of work that interests me (and to reply back to another manager if it does).
Does anyone have any helpful tips for learning C or pointers on what kind resources to read up on? All help is appreciated.
Working in C# at the moment with SFML.Net. Is it worth developing a hook system for my game a la Garry's Mod?
Working on a soundbot for Discord, and I'm getting shafted by buffering in C#. I'm creating a youtube-dl and ffmpeg process, then piping the former's stdout into the latter's stdin.
Doing this in a standard shell from the same machine reveals youtube-dl is not having any transfer rate issues, and that ffmpeg can do its encode and dump to stdout at 100-300x speed.
Doing this in C#:
var psi = new ProcessStartInfo {
FileName = "youtube-dl",
Arguments = $@" -f bestaudio/best ""{url}"" --no-playlist -o -",
RedirectStandardOutput = true,
RedirectStandardError = false,
UseShellExecute = false
};
ytdlProcess = Process.Start(psi);
psi = new ProcessStartInfo {
FileName = "ffmpeg",
Arguments = $@"-hide_banner -i pipe:0 -vn -ac 2 -f s16le -ar 48000 pipe:1",
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = false,
UseShellExecute = false
};
ffmpegProcess = Process.Start(psi);
var intermediaryStream = new BufferedStream(ytdlProcess.StandardOutput.BaseStream, 1000000*10);
intermediaryStream.CopyToAsync(ffmpegProcess.StandardInput.BaseStream);
_stream = new BufferedStream(ffmpegProcess.StandardOutput.BaseStream, 1000000*10);
As I fire off audio (at realtime; 1x speed) from _stream, ffmpeg is reporting that it is encoding from 0.9-1.3x speeds. When the speed drops <1x, stuttering.
Now, the reason there are 10MB BufferedStreams everywhere here is simply a result of me ensuring every buffering link in the chain here has more than enough room to fit the source I'm testing with more than 5 times over in the hope that it might allow the processes to chunk through much quicker at least until the buffer is filled.
So, correct me if I'm wrong, but I'm assuming a BufferedStream will read the stream it wraps until its internal buffer is sated, so I'd expect YTDL to happily fill up intermediaryStream until the buffer is full, likewise for ffmpeg to fill up _stream. But from what I'm seeing, this isn't happening.
Why not just use a single Process.Start then?
So I had this idea that when you use the command !cloak ^, that it changes the users physgun colour to these:
-1200
0
0
In the colour area (Like when holding C)
Tried adding it under the the ULX base functions and nothing i've tried works.
Any ideas?
The proper subforum would be a good start.
I can, it'd be a per-OS branch but that's no worry.
However some more testing reveals I'm pointing my finger at the wrong place. By just writing the final stream out onto a disk, I get ~70x encoding speeds, indicating the cause of the 1x encoding speeds is actually due to me reading from the final stream at 1x speeds.
So I'm misunderstanding how the BufferedStream works. To simplify things, I've a Process' stdout stream wrapped in a BufferedStream with a buffer size of say, 128 MB. If I don't read from the stream, my assumption was that it'd still read from the underlying stdout stream until the buffer is filled, but it doesn't.
If I read at 1x from this BufferedStream, I get a 1x rate pull from the underlying stdout stream. I can probably work around this by implementing my own FIFO buffer that I fill up and pull from, but if anyone knows what the BufferedStream is actually doing here, why I'm using it wrong and/or if there is a better solution, that'd be grand.
What's a good SDL/SFML-like library for Java? JSFML is no longer maintained but I liked working with that. I've started to get into SDL at home with C++ and like that
If I have an instantiated class inside my Configuration class that is responsible for nothing more than holding the deserialized contents of a configuration JSON file, what should I call it?
JSON_PKG?
"Configuration"
I'd probably call it data.
While technicaly not programming, would here be the right place to ask for help in circuitry ?
Try here: Electrical Engineering V3
Can someone post an invite to FP Discord?
Sorry, you need to Log In to post a reply to this thread.