I'm sorry if this should be incredibly obvious, but I could not find the answer to this whatsoever and it's been so frustrating:
Where is there a damn list of "default" UnrealScript functions? As in functions that "come with" the UDK?
I'm trying to enumerate a bunch of UPSes connected to a single machine. I've been using WMI with c#, and it's worked well so far, except that there doesn't seem to be a way to uniquely identify each UPS returned by WMI. Does anyone know of any other (managed) APIs to get this kind of data?
[QUOTE=bootv2;43783218]You're not addressing all values in your unsigned char array, the maximum amount of values in the array is 262144 while you're only addressing 66563 values.[/QUOTE]
Huh, I thought the loop took care of that, how should I write the loop then?
[QUOTE=Richy19;43785662]Huh, I thought the loop took care of that, how should I write the loop then?[/QUOTE]
[code]
const size_t bbp = 4;
unsigned char image[256 * 256 * bbp];
size_t i = 0;
for(int y = 0; y < 256; y++)
{
for(int x = 0; x < 256; x++)
{
unsigned char val = (unsigned char)(noise.Generate(x, y) * 100);
unsigned char* buffer = &image[i * bbp];
i++;
buffer[0] = 255;
buffer[1] = val;
buffer[2] = val;
buffer[3] = 255;
}
}
t->LoadData(image,256,256);[/code]
I think you could also just do this:
[CODE]const size_t bbp = 4;
const size_t rowLength = 256*bpp;
int prevRows = 0;
int acc = 0;
unsigned char image[256 * 256 * bbp];
for(int y = 0; y < 256; y++)
{
for(int x = 0; x < rowLength; x++)
{
unsigned char val = (unsigned char)(noise.Generate(x, y) * 100);
image[0 + acc + prevRows] = 255;
image[1 + acc + prevRows] = val;
image[2 + acc + prevRows] = val;
image[3 + acc + prevRows] = 255;
acc += bpp;
}
prevRows += 256;
}
t->LoadData(image,256,256);[/CODE]
I am amazed at my ability to even fail at the most simple things
By calling "glClearColor(1.0f, 0.f, 0.f, 1.f);" and later "glClear(GL_COLOR_BUFFER_BIT);" i [I]should[/I] get a red window.
However, what i get is a white window.
no errors at all. And before someone asks i did link to OpenGL32.lib, glu32.lib, glew32.lib, SDL2.lib, SDL2main.lib
[CODE]
int main(int /*argc*/, char* /*args*/[])
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
return -1;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
auto pWindow = SDL_CreateWindow(
"Title",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
1280,
720,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (pWindow == nullptr)
return -1;
auto Context = SDL_GL_CreateContext(pWindow);
if (Context == NULL)
return -1;
SDL_GL_SetSwapInterval(1);
glewExperimental = GL_TRUE;
if (GLEW_OK != glewInit())
return -1;
glClearColor(1.0f, 0.f, 0.f, 1.f);
SDL_Event e;
bool running = true;
while (running)
{
glClear(GL_COLOR_BUFFER_BIT);
SDL_PollEvent(&e);
if (e.type == SDL_QUIT)
{
running = false;
}
}
// Cleanup
SDL_GL_DeleteContext(Context);
SDL_DestroyWindow(pWindow);
SDL_Quit();
return 0;
}
[/CODE]
[QUOTE=Sergesosio;43788912]I am amazed at my ability to even fail at the most simple things
By calling "glClearColor(1.0f, 0.f, 0.f, 1.f);" and later "glClear(GL_COLOR_BUFFER_BIT);" i [I]should[/I] get a red window.
However, what i get is a white window.
no errors at all. And before someone asks i did link to OpenGL32.lib, glu32.lib, glew32.lib, SDL2.lib, SDL2main.lib
[/QUOTE]
I don't know much about SDL, but shouldn't you be swapping buffers with SDL_Flip or something?
[QUOTE=bootv2;43789070]I've been having a lot of trouble with file tokenizing and intrepetation.
I've seperated each token by a : sign in my files, and each individual entry is on a seperate line.
when I read in the line bootv2:0.00000:0:1:1234 with the following code, I get the included image as a result.
*snip*[/QUOTE]
I think this might help you: [url]http://stackoverflow.com/a/236803[/url]
Is there a way to make a static class in python without just annotating all methods with @staticmethod?
[QUOTE=vexx21322;43791275]Is there a way to make a static class in python without just annotating all methods with @staticmethod?[/QUOTE]
Do you absolutely need @staticmethod? The only advantage there is nicer access to the class object. In Python 3, classes can call their own functions without an instance.
[code]
class Foo:
def bar(x):
print(x)
Foo.bar(3)
[/code]
[QUOTE=Larikang;43793042]Do you absolutely need @staticmethod? The only advantage there is nicer access to the class object. In Python 3, classes can call their own functions without an instance.
[code]
class Foo:
def bar(x):
print(x)
Foo.bar(3)
[/code][/QUOTE]
Didn't know you could do that in Python 3.
Unfortunately, I'm still in Python 2.
[QUOTE=Sergesosio;43788912]I am amazed at my ability to even fail at the most simple things
By calling "glClearColor(1.0f, 0.f, 0.f, 1.f);" and later "glClear(GL_COLOR_BUFFER_BIT);" i [I]should[/I] get a red window.
However, what i get is a white window.
no errors at all. And before someone asks i did link to OpenGL32.lib, glu32.lib, glew32.lib, SDL2.lib, SDL2main.lib
[CODE]
int main(int /*argc*/, char* /*args*/[])
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
return -1;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
auto pWindow = SDL_CreateWindow(
"Title",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
1280,
720,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (pWindow == nullptr)
return -1;
auto Context = SDL_GL_CreateContext(pWindow);
if (Context == NULL)
return -1;
SDL_GL_SetSwapInterval(1);
glewExperimental = GL_TRUE;
if (GLEW_OK != glewInit())
return -1;
glClearColor(1.0f, 0.f, 0.f, 1.f);
SDL_Event e;
bool running = true;
while (running)
{
glClear(GL_COLOR_BUFFER_BIT);
SDL_PollEvent(&e);
if (e.type == SDL_QUIT)
{
running = false;
}
}
// Cleanup
SDL_GL_DeleteContext(Context);
SDL_DestroyWindow(pWindow);
SDL_Quit();
return 0;
}
[/CODE][/QUOTE]
[QUOTE=Goz3rr;43789096]I don't know much about SDL, but shouldn't you be swapping buffers with SDL_Flip or something?[/QUOTE]
True, but not SDL_Flip (from SDL 1.2) but SDL_GL_SwapWindow(SDL_Window*)
I've decided to create some VOIP software in F# w/ WPF.
I found this solution for handling events, F# is awesome.
[code]
let (+=) (event : IEvent<_, _>) handle =
(event :> Microsoft.FSharp.Control.IDelegateEvent<_>).AddHandler(RoutedEventHandler(handle))
[/code]
Anyway, are there any decent .NET libraries to implement the VOIP with? Or should I just do it manually? I can't seem to find anything worth using.
If I have to go about it manually what is the best way to stream the audio? I have zero experience with audio outside of simple media frameworks.
[QUOTE=reevezy67;43797064]I've decided to create some VOIP software in F# w/ WPF.
I found this solution for handling events, F# is awesome.
[code]
let (+=) (event : IEvent<_, _>) handle =
(event :> Microsoft.FSharp.Control.IDelegateEvent<_>).AddHandler(RoutedEventHandler(handle))
[/code]
Anyway, are there any decent .NET libraries to implement the VOIP with? Or should I just do it manually? I can't seem to find anything worth using.
If I have to go about it manually what is the best way to stream the audio? I have zero experience with audio outside of simple media frameworks.[/QUOTE]
Does that work with .NET events too, or only with F# ones?
[QUOTE=Tamschi;43797550]Does that work with .NET events too, or only with F# ones?[/QUOTE]
I think all but I haven't tested it. You do lose all event argument data though.
[url]http://msdn.microsoft.com/en-us/library/system.windows.routedeventhandler(v=vs.110).aspx[/url]
[editline]6th February 2014[/editline]
Ok no they aren't they have to derive from IEvent.
[url]http://msdn.microsoft.com/en-us/library/system.management.instrumentation.ievent(v=vs.110).aspx[/url]
There is probably a way to do it generically, I'll look in to it.
[QUOTE=reevezy67;43797669]There is probably a way to do it generically, I'll look in to it.[/QUOTE]
Probably not. .NET events are just two public methods and a few attributes iirc.
You could make a "template" for easily adding a wrapper to an existing class though, so that you have to declare them once and then can use the wrapped versions with operators after importing the right module.
[editline]5th February 2014[/editline]
Another interesting thing about .NET events: You can assign delegates of compatible types no problem, as long as they are the exact same delegate type.
If you have an Action<object> event and add an Action<Foo> and an Action<Bar> though, the first one will succeed and the second one will fail.
It's possible to wrap the delegate into a lambda with explicit type cast, but the nicer option may be to rebuild the delegate with the original target but the right type. (This is likely important when calling remove, as the anonymous one will create a differing instance if it captures something.)
Yeah you are right. It would still be possible to create a generic operator for the majority of Events in .NET, they mostly derive from Event or IEvent.. I think.
Something stupid like this, although I'm sure there is a better solution.
[code]
//Psuedo
let (+=) (event:'a) (handle:'a) =
if etype = Event then
()
elif etype = IEvent<_> then
()
[/code]
The compiler would throw a fit at this because of the type inference.
[editline]6th February 2014[/editline]
Nah, that's a stupid idea.
[QUOTE=reevezy67;43798368]Yeah you are right. It would still be possible to create a generic operator for the majority of Events in .NET, they mostly derive from Event or IEvent.. I think.
Something stupid like this, although I'm sure there is a better solution.
[code]
//Psuedo
let (+=) (event:'a) (handle:'a) =
if etype = Event then
()
elif etype = IEvent<_> then
()
[/code]
The compiler would throw a fit at this because of the type inference.
[editline]6th February 2014[/editline]
Nah, that's a stupid idea.[/QUOTE]
You can do that, even generically and safely. Make it an inline method and use statically typed generics, one for each type.
[editline]5th February 2014[/editline]
If you wanted, you could also make += and -= inline operators that call the add and remove methods on objects, but I don't know what that would interfere with.
-snip- my solution worked
Does anyone know of a Lua extension for Visual Studio 2013, or one for a previous version of Visual Studio that is till compatible with VS 13?
[QUOTE=huntingrifle;43805550]Does anyone know of a Lua extension for Visual Studio 2013, or one for a previous version of Visual Studio that is till compatible with VS 13?[/QUOTE]
just download [url=http://visualstudiogallery.msdn.microsoft.com/7af51f37-07ad-4d6b-9c2b-00672bb051ad]this[/url] one, open it with 7zip or something and change the supported version in the manifest, works fine
Can I ascertain the type of a generic and then create an instance of that type in F#?
[code]
let inline (+>) (d:'a) (u:unit) =
let DType = d.GetType()
d := DType(u)
[/code]
[QUOTE=reevezy67;43808266]Can I ascertain the type of a generic and then create an instance of that type in F#?
[code]
let inline (+>) (d:'a) (u:unit) =
let DType = d.GetType()
d := DType(u)
[/code][/QUOTE]
You can do it dynamically or with generics, like everywhere else in .NET:
[code]let (+>) (d : 'a ref) () =
d := new 'a ()[/code]
The version with the default constructor works without inline and with normal generics, as there's a [I]new()[/I] constraint. You may want to inline it nonetheless, as it's so short.
[I]'a ref[/I] is an alias for [code]Ref<'a>[/code]
I don't know how to call more complicated constructors, but are you sure this is something that makes the program clearer?
I'd probably use something like this to reset reference cells: [code]let inline reset (d : ^a ref) =
d := new ^a ()
let bla = ref 1
reset bla
// val bla : int ref = {contents = 0;}[/code]
Also, if you need some default value I suggest using an [I]a' option ref[/I] and then just initialising that with None. You can just use [code]let bla = ref None[/code] and have the compiler infer the correct type from the following code.
I'm assuming I can't put in initialization arguments like u in this?
[code]
let inline (+>) (d:'a) (u:unit) =
d = new 'a(u) |> ignore
()
[/code]
I'm trying to create an operator for easily adding parameterless delegates.
[editline]7th February 2014[/editline]
I guess I'll try dynamics?
[QUOTE=reevezy67;43809732]I'm assuming I can't put in initialization arguments like u in this?
[code]
let inline (+>) (d:'a) (u:unit) =
d = new 'a(u) |> ignore
()
[/code]
I'm trying to create an operator for easily adding parameterless delegates.
[editline]7th February 2014[/editline]
I guess I'll try dynamics?[/QUOTE]
It might work with statically typed generics, but I'm not sure.
Reflection will work but isn't type safe, so just use the normal constructor instead of this operator thing.
[editline]edit[/editline]
Your code doesn't do anything close to what you're trying to achieve, [I]d[/I] would be constrained to [I]()[/I].
Parameterless delegates should already have an operator for adding them, just use + which works on compatible [I]Action<_>[/I]s for example.
If you're working with F# functions, which aren't the same as .NET delegates, use the >> operator.
If you want to require a [I]unit[/I] parameter, just use the [I]()[/I] pattern.
Unity problem. I'm pretty new at this...
I have three 3d text objects rendering in front of a semi-transparent sprite. The problem is that at some camera angles some of the text gets rendered behind the sprite (marked on picture). What could be causing this? [IMG]http://svgsch.at/what.PNG[/IMG]
[QUOTE=TuLiq;43810830]Unity problem. I'm pretty new at this...
I have three 3d text objects rendering in front of a semi-transparent sprite. The problem is that at some camera angles some of the text gets rendered behind the sprite (marked on picture). What could be causing this? [IMG]http://svgsch.at/what.PNG[/IMG][/QUOTE]
Have you tried placing the text very slightly in front of the sprite? You don't want positional differences to be so small that Z-Buffer fighting or Floating point errors causes things like this to happen.
[QUOTE=Cold;43811171]Have you tried placing the text very slightly in front of the sprite? You don't want positional differences to be so small that Z-Buffer fighting or Floating point errors causes things like this to happen.[/QUOTE]
Failing that, I think you can force some Z-buffer stuff in Unity.
[QUOTE=Cold;43811171]Have you tried placing the text very slightly in front of the sprite? You don't want positional differences to be so small that Z-Buffer fighting or Floating point errors causes things like this to happen.[/QUOTE]Placing the text slightly in front of the sprite just makes all the text render behind it. If I put the sprite further back than in the picture, it appears on top of the sprite more consistently, (and creates a cool 3d floating text effect, which is kinda what I'm after) but it still renders behind the sprite when viewed from the far right or left.
-snip-
Sorry, you need to Log In to post a reply to this thread.