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.


Topics - HardCoded

Pages: [1]
1
Graphics / [SFML.Net] SFML.Graphics.Font no textures loading.
« on: May 18, 2014, 09:44:40 am »
Okay, so, I downloaded SFML.Net and got to some basic stuff first and drew a circle on a RenderWindow easily. Then, I tried Text and got stuck.

Basically, I've tried two custom fonts and the default Arial font from the system fonts folder without success. I think I know what's wrong but I don't know what's causing it.

I have attached a screenshot of the source code. f.myTextures.Count is always zero for some reason. And that means I can't draw any text.. But I don't know *why* it isn't getting any textures.

public void run () {
    Font f = new Font("res/font/arial.ttf");
}

2
Graphics / Blocking main thread causes failed texture load
« on: July 16, 2013, 04:55:05 am »
I was testing some stuff and got this to work:
01) Open File Dialog opens (using some old deprecated C++ code..)
02) File is selected
03) Texture A is loaded from a file (not related to open file dialog)
04) Texture B is loaded from a file (not related to open file dialog)
05) Texture C is loaded from a file (not related to open file dialog)

The problem is, the A and C load and render fine. But B fails to load and no error message is output onto the console. It just fails quietly.. And even reports that the texture is loaded.
As in, the error here never triggers but the texture loaded is just.. Blank:
if (!texture.loadFromFile("filename")) {
    //error
}
 

Also notice that none of the textures loaded are related to the file chosen in the OFD. When I remove the code for the OFD so the main thread is never blocked, all three textures load and render without issues.

It's only when I block the thread that the 2nd texture fails to load.. Which is weird. I would think that it should be the first texture that fails, if any of the three has to fail.

The deprecated C++ code I'm talking about is:
    OPENFILENAME opendialog = {0};
    WCHAR szFile[260] = {0};

    opendialog.lStructSize = sizeof (opendialog);
    opendialog.hwndOwner = hwnd;
    opendialog.hInstance = GetModuleHandle(NULL);
    opendialog.lpstrFile = &szFile[0];
    opendialog.nFilterIndex = 0;
    opendialog.nMaxFile = 256;
    opendialog.lpstrInitialDir = NULL;
    opendialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

    GetOpenFileName(&opendialog);
    return std::wstring(szFile);
 

3
General / Efficient and easy collision detection?
« on: April 03, 2012, 08:16:01 am »
Hi, I've been working on a little game framework as a learning experience but have hit a brick wall.
My game is tile-based and will have agents moving about.

I've gotten agent-to-tile collision working with a constant time complexity (yay) which means moving n-agents, I only have to do n-work to check if their new positions will collide with a tile; cool.

However, agent-to-agent collision is much harder for me =/
I've been thinking of solutions but have been hard pressed to come up with any.

If I do a naive implementation (as I have done), I'll end up with (n-1) comparisons for moving one agent and [n(n-1)]/2 comparisons for moving n-agents. That is, check each agent and see if they collide; if they don't, allow them to move.

I've thought of a bunch of ways; like having them in a list sorted by x-coordinates at all times so that the checks I have to do is significantly less. But then, I run into the problem of having to update the list as I move the units and swapping things around. Even thought of splitting the game-world that the agents live into grids of 5 tiles but that doesn't solve my book-keeping problem.

I just can't really wrap my head around an efficient algorithm. My agents are always 32.32 pixels in size (so that's one thing that's made slightly easier.)

Are there any hints on how I could store my agents that always have their locations changing?

4
General / Just a few questions about sf::Sprite
« on: January 18, 2012, 06:40:59 pm »
I noticed (only recently) that I could do something like this:
Code: [Select]

Create sprite
Set sprite's texture

Draw sprite to screen
Change sprite's position
Draw sprite to screen

Display


And it'll make two images appear at different locations.
I had been using one sf::Sprite per image before that =x

Anyways, which of the following is better for drawing multiple images to the screen at different positions?
A) One texture, many sprites with that texture.
B) One texture, one sprite with that texture but has its position moved around and drawn to the screen.

I'm guessing it's option B but I'd rather ask and be sure.

Also, if I had many different textures..
Should I be doing this?
Many textures, one sprite.

For each image, I just set the one sprite's texture, set the sprite's position and draw it.

So the loop will be, like:
Code: [Select]

sf::Sprite 'A' was created some where..
for each image I want to draw
    set A's texture to that image
    set A's position
    draw A
end

render_window.Display()

5
Graphics / sf::Texture.. "colliding" with sf::Text ?
« on: November 10, 2011, 05:33:49 am »
I wouldn't really know how to post the code because there's just so much =/
But, somehow, when I display sf::Text on the RenderWindow, I have a texture applied to the texts (all of them) when I never did anything like that.
(I didn't even know you could apply textures to texts)

I've been trying to find the simplest way to replicate the issue but I can't =/
I do know that I use the following:
sf::Font
sf::Sprit
sf::Texture
sf::Text

Texture and Sprite are for the 'units' in my game while Font and Text are for little menus.

I don't see any direct interaction between the classes that would make it bug but it's happening to me.
Replicable in my project but not from scratch.

I'm using SFML2.0
I would upload the entire project but it's 70MB =/



[EDIT]
I moved the source files to a new project and zipped it up: http://a2step.com/ErrorProj.rar

It won't compile straight away as it needs the libs, dlls and header files for SFML2.0 to be configured for it.
Anyways, if you run it, go to NewGame->Easy, you will see the text bug with a texture applied on it =/

I wish I could replicate it in an easy way but I can't =/

6
Window / Focus on Window?
« on: November 07, 2011, 12:17:32 am »
I'm using SFML2.0 and VC++2010 and when I compile and run this:
Code: [Select]

int main () {
sf::RenderWindow App(sf::VideoMode(X_RATIO, Y_RATIO, 32), WINDOW_TITLE);
App.SetFramerateLimit(32);
while (true) {
App.Display();
}
return 0;
}

I can't seem to 'click' on the window it creates or move it about or do anything with it.
However, I can interact with the console window that opens up with it.

Am I missing something?

7
Graphics / dbgheap.c; bad pointer passed
« on: November 02, 2011, 04:05:00 pm »
I recently decided to stop using GLUT because it was just too restrictive =x
I looked around for alternatives and saw SFML recommended, so here I am.

Anyways, I was following the tutorials and reached the Fonts and Texts part when I hit a road block =/

The code I'm using is roughly:
Code: [Select]

sf::Font Font;
Font.LoadFromFile("04B_30_.TTF");
sf::Text Text("Hello, world!", Font);
while (true) {
Window.Draw(Text);
}


It works and all, the text is drawn onto the window but when I close the program, I get this error (from debugging):
Code: [Select]

         /*
         * If this ASSERT fails, a bad pointer has been passed in. It may be
         * totally bogus, or it may have been allocated from another heap.
         * The pointer MUST come from the 'local' heap.
         */
        _ASSERTE(_CrtIsValidHeapPointer(pUserData));

So some bad pointer is being passed or so it is claimed =/

I commented the line: sf::Text Text("Hello, world!", Font);
And the Drawing part and the error never came up.

I'm using SFML 2 (VS2010) and would like to know if I messed up or if it's just a little bug =x

Pages: [1]
anything