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 - tom64

Pages: 1 [2] 3 4
16
General / Re: Loading fonts to a custom surface?
« on: April 10, 2013, 02:08:26 am »
But I thought maybe I could just use some of the 'modules' of SFML to do smaller stuff like loading only the fonts and getting the pixel info without the other stuff loaded also.

17
General / Re: C++: Advice for creating a 'screen' and 'object' system
« on: April 10, 2013, 02:06:03 am »
But I do understand OOP. I just don't understand the syntax to store objects in the list and have that list/screen-class then 'create' that object as an instance, and then how to safely destroy everything.

Surely it can't be that hard..

18
General / Re: Loading fonts to a custom surface?
« on: April 09, 2013, 02:28:28 pm »
Because I may be using DirectX and don't want to also load OpenGL, especially if it might interfere with DX.

19
General / C++: Advice for creating a 'screen' and 'object' system
« on: April 09, 2013, 01:37:51 pm »
Hi all, I am thinking to create a system for screens and objects.

Screens are just the pages in the application. eg. When the app loads you see the 'welcome' screen, then after that you see the 'menu' screen.

Objects are just things that store data and do stuff which you put inside your screen.

Now, I'm guessing both screens and objects will be 'classes'. The screen class will get details about its size, color, etc.

After creating the objects (which is just a blueprint), I would then 'add' the object to a particular screen. Then when the screen loads by gotoScreen(screenName) the screen would create instances of those objects and those objects would begin to do stuff.

How I might do it: I'm thinking maybe a linked-list in the screen class that stores what objects that screen will need to create. But how do I do that? Do I need to pass a pointer of the object to the linked list? And then how would the screen class then use that pointer to 'create' an instance of that object?

And then if say I wanted to 'clear' the screen after I go to the next screen (deleting all of the object-instances/data/etc being used by the previous screen - except the blueprints of course - as I may want to load that screen again), how do I do that??

Objects are also capable of 'creating' instances of objects as well as new variables that allocate memory. Those would also need to be destroyed when the screen gets cleared.

Any advice on the best way to go about this?

Thanks,
Tom.


20
General / Re: Loading fonts to a custom surface?
« on: April 09, 2013, 01:26:28 pm »
Quote
Also, could I do all of this without having to import OpenGL?
?? ???
[/quote]

Sorry, it's just that SFML is so closely connected with OpenGL I don't know what parts of it will include/require it or not. I guess the font thing is completely separate then.

21
General / Re: Loading fonts to a custom surface?
« on: April 09, 2013, 12:54:26 pm »
You can draw to a texture (sf::RenderTexture) and retrieve the result in your own pixel array.
Would that also provide me the total dimensions (w, h) of the entire string in pixels?

Also, could I do all of this without having to import OpenGL?

22
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 12:46:07 pm »
Quote
Introducing dirty hacks because you don't want to write a few more characters is a very bad idea.

I know, but I'm talking about doing it for very generic/general/basic functions, not everything.

23
General / Loading fonts to a custom surface?
« on: April 09, 2013, 12:44:33 pm »
If I make my own surface (a 2D pixel array), is it possible to draw text to that surface instead of directly to the window?

Or if I could at least get the pixel information about the 'text' then I could just place it on-top of my surface myself?

For example, if I'm using DirectX and have my own surface that gets sent to a backbuffer (to be displayed onto the screen), if I wanted to draw text on the screen I would either have to make sure SFML can draw text ontop of the backbuffer (unlikely if I had to guess since SFML is OpenGL), otherwise I was hoping SFML can read font files and text and provide the pixel info so I can place the text ontop myself.

Thanks in advance,
Tom.

24
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 11:00:47 am »
Quote
You all told me it couldn't be done!
I said it would work only if the other library is completely inlined (everything in header, no compiled library). Which is the case here. But is it also the case in your real program?

Ah, nevermind, it doesn't work on math.h. Says 'floor is not a member of myNamespace2'

Also, I just realised now that round() isn't even inside <math>  ;D

I definitely need some sleep.

Thanks again everyone..

PS: Does anyone know if it's possible to only load/include a specific function from a file? e.g. Say I only wanted to include the floor() function from <cmath> without loading all the other functions, is that possible?

25
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 10:21:45 am »
SUCESS!

I actually managed to do it, and it works!?? Pretend that lib1 is MY library, and lib2 is the <math> library.

main.cpp
#include <iostream>

namespace myNamespace2{
        #include "lib2.h"
}

#include "lib1.h"

int main(){
        std::cout << func() << std::endl;
        return 0;
}

lib1.h
#pragma once

int func(){
        return myNamespace2::func();
}

lib2.h
#pragma once

int funcc(){
        return 3;
}

int func(){
        return funcc();
}

Outputs: 3

You all told me it couldn't be done!

26
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 09:42:21 am »
But namespaces don't completely solve the problem. Because if you have tons of lazy programmers all giving you their lib, and they make namespaces like a:: or xyz:: then you're not only going to get function name conflicts but also namespace conflicts...

Anyway thanks everyone for your help. I feel smarter  :-*

27
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 09:32:45 am »
Quote
You're using the wrong header, as stated before.
It should be: #include <cmath>, which puts everything into the std namespace.

OMG that was just an example!!!!!!!!!

I meant that I might be including lots of other peoples files which don't use namespaces...

28
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 09:26:52 am »
I totally understand!!!

I just don't get why they never added a feature to C++ to say:
"we are going to rename the function round() from <math> to math_round() only in 'this' .cpp script"

What if someone elses library had the same function name and the same namespace name? It just seems like a clumsy design for a language...

PS: Thanks very much eXpl0it3r for that example, that helps alot.

I suppose I'll just have to bite the bullet. Either create unique function names, or add a namespace to them.

Thanks all for your help.  :) :'(

29
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 09:21:06 am »
I still dont get why it's possible to namespace my functions, but not possible to namespace someone elses functions?

Can't I just wrap the #include "lib2.h" inside a namespace?

That way, my function will be global, and the other (<math>) will be under a namespace?

30
General / Re: C++: Two functions with same name dilema
« on: April 09, 2013, 09:14:25 am »
Quote
and the code posted by you, the second library doesn't have its own namespace.

Yes... but isn't that exactly what many libraries do? Like in the <math> library you just simply use the function 'round()' as is. You don't need a namespace::..

That's why I'm using that as an example.

So in other words, I can't make my own library with simple function names, because I will hit someone elses and therefore need to put ugly xxx:: in front of everything..  :'(

Pages: 1 [2] 3 4
anything