[QUOTE=WTF Nuke;24675388]How do I use tinxml to go to an element? This doesn't work:
[code]
character.ToElement(currentmap);
chracter >> maps.mapname;
[/code][/QUOTE]
Retoast.
I'm working on a simple app to learn C# and the Windows Presentation Foundation and I wanted to ask a quick question. Right now all my buttons are flat and boring, they look like the Windows 98 ones. How do I make them take on the appearance of the standard Win7 button widget?
Here's a picture if you don't know what I mean:
[img]http://dl.dropbox.com/u/7630525/10two5.png[/img]
Oh, and sort of unrelated, is there a way to take screencaps of windows with transparency?
I'm using WMI to catch process creation and deletion. It works as expected in a console application, but doesn't in a Windows Forms app. This is due to the ManagementEventWatcher.EventArrived event being executed in a separate thread.
So, my question is: how can I modify my form from another thread?
I tried this very popular snippet:
[cpp]if( InvokeRequired )
{
BeginInvoke( new PrintDelegate( Print ), new object[] { args.NewEvent["Name"] } );
}
else
{
Print( args.NewEvent["Name"] );
}[/cpp]
But it doesn't work in this case.
[b]Edit:[/b]
It seems that the problem occurs in this piece of code: [I]args.NewEvent["Name"][/I]. It just stops any further execution.
[b]Edit:[/b]
Never mind, I fixed it. The "Name" property didn't exist, so the class decided not to throw an exception.
[b]Edit:[/b]
The debugger doesn't catch exceptions thrown from other threads. Something to know.
[QUOTE=ColdFusion;24752696]I am trying to edit data at a specific address. Reading seems to work fine. But when I edit it it seems to crash. But when using a memory editor it seems to work fine.
[cpp]
unsigned char *Addy1 = (unsigned char *)dllbase + X + 0;
unsigned char *Addy2 = (unsigned char *)dllbase + X + 1;
unsigned char *Addy3 = (unsigned char *)dllbase + X + 2;
*Addy1 = 144;
*Addy2 = 144;
*Addy3 = 144;
[/cpp]
EDIT: And yes this injected in to the process[/QUOTE]
Anyone ?
[QUOTE=Nevec;24774036]I'm using WMI to catch process creation and deletion. It works as expected in a console application, but doesn't in a Windows Forms app. This is due to the ManagementEventWatcher.EventArrived event being executed in a separate thread.
So, my question is: how can I modify my form from another thread?
I tried this very popular snippet:
[cpp]if( InvokeRequired )
{
BeginInvoke( new PrintDelegate( Print ), new object[] { args.NewEvent["Name"] } );
}
else
{
Print( args.NewEvent["Name"] );
}[/cpp]
But it doesn't work in this case.
[b]Edit:[/b]
It seems that the problem occurs in this piece of code: [I]args.NewEvent["Name"][/I]. It just stops any further execution.
[b]Edit:[/b]
Never mind, I fixed it. The "Name" property didn't exist, so the class decided not to throw an exception.
[b]Edit:[/b]
The debugger doesn't catch exceptions thrown from other threads. Something to know.[/QUOTE]
I see you've solved it, but for anyone else struggling with this, here's what I usually do:
[code]
someControl.Invoke((MethodInvoker)(() =>
{
// your code here
}));
[/code]
[QUOTE=ROBO_DONUT;24768119]The "varying" qualifier specifies that values are automatically interpolated before they are passed to the fragment shader. You create a value "varying vec2 texcoord" and set it in the vertex shader, then read it in the fragment shader.[/QUOTE]
Ok, it all works now.
Thank you a lot.
So, how does the shader know what values to interpolate? I mean, couldn't I pass some value I want to process on the vertex to the fragment shader the way it is, without it being interpolated?
[QUOTE=Darwin226;24783171]Ok, it all works now.
Thank you a lot.
[/QUOTE]
Excellent.
No problem.
[QUOTE=Darwin226;24783171]So, how does the shader know what values to interpolate? I mean, couldn't I pass some value I want to process on the vertex to the fragment shader the way it is, without it being interpolated?[/QUOTE]
Any values marked "varying" are interpolated by their positions in relation to the three vertexes of a triangle. As far as I understand, you can't not interpolate values specified in the vertex shader because there are three vertexes and many many fragments in between. It isn't obvious which fragments should be associated with which vertex, so interpolation is used to generate intermediate values.
You can, however, use "uniform" values in a fragment shader. Since uniforms are the same for every vertex/fragment, they do not need to be interpolated.
[QUOTE=ROBO_DONUT;24783469]As far as I understand, you can't not interpolate values specified in the vertex shader because there are three vertexes and many many fragments in between. It isn't obvious which fragments should be associated with which vertex, so interpolation is used to generate intermediate values.[/QUOTE]
If you use the newer 'in' and 'out' keywords instead of 'varying', there is a storage qualifier, 'flat' which allows non-interpolated values to be passed between vertex and fragment shaders. I'm not sure if it would average the values, or select the first vertex of the triangle. ([URL="http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.10.pdf"]GLSL 1.3, section 4.3[/URL])
In your opinion what's the best library for game development in java?
[QUOTE=bean_xp;24783717]If you use the newer 'in' and 'out' keywords instead of 'varying', there is a storage qualifier, 'flat' which allows non-interpolated values to be passed between vertex and fragment shaders. I'm not sure if it would average the values, or select the first vertex of the triangle.[/QUOTE]
I was going to mention "in" and "out", which is what I usually use, but his shaders are #version 110.
I didn't know about "flat" though, so thanks for the info.
Ok, 110 is associated with OpenGL 3.0 right?
Also, I should have separate buffers for separate models right? Then pass the matrices as uniforms.
The other way that would work with only one buffer would be to have all the matrices in an array and passed as an uniform and then give vertices an attribute which would be the index in that array. That sounded way more complicated.
[QUOTE=Darwin226;24783945]Ok, 110 is associated with OpenGL 3.0 right?[/QUOTE]
No, I think GLSL 150 (1.5) is the latest for OpenGL 3.x.
[QUOTE=Darwin226;24783945]Also, I should have separate buffers for separate models right? Then pass the matrices as uniforms.[/QUOTE]
Yes, each model usually has its own vertex buffer. The model, view, and projection matrixes should all be passed as uniforms. If you need TBN matrixes for normal mapping, you can pass them as per-vertex attributes.
[QUOTE=Darwin226;24783945]The other way that would work with only one buffer would be to have all the matrices in an array and passed as an uniform and then give vertices an attribute which would be the index in that array. That sounded way more complicated.[/QUOTE]
I'm not totally sure I understand what you mean, but I'll try to answer anyway. "Buffer" is about as specific as "data", but I assume you're talking about the vertex buffer. So if you're talking about putting all the vertex data for the entire scene in one buffer, as well as the transformation matrixes of each model, that's really not the best idea. First, it gives you almost no freedom to adjust things per-model. For example, it's usually best to render level geometry front-to-back with blending off (assuming it can be easily sorted, such as in the case of a BSP tree). This increases performance because every fragment which is obscured by something will fail the initial depth test instead of rendering out, then being overwritten. Conversely, in the game I'm writing at the moment, game levels are ordinary models, semi-transparent, with thick lines at each edge. I need to sort the polygons back-to-front with blending enabled and depth-writes disabled (leaving depth writes enabled causes z-fighting between the polygon faces and the edges).
Lumping it all together would make different rendering techniques impossible, or at least very difficult.
Second, you need to keep your shaders as simple as possible. Graphics cards have limitations on shader complexity. If you hit that limit, it won't compile/run.
[QUOTE=Darwin226;24783945]Also, I should have separate buffers for separate models right? Then pass the matrices as uniforms.[/QUOTE]
I believe that's the preferred way, yes.
[QUOTE=Darwin226;24783945]The other way that would work with only one buffer would be to have all the matrices in an array and passed as an uniform and then give vertices an attribute which would be the index in that array. That sounded way more complicated.[/QUOTE]
The second way is more complicated but it gives you the flexibility of specifying which matrix to use per-vertex. Useful for animation perhaps.
Awesome, I just went from hating non-deprecated OpenGL to loving it in 2 days.
How come all this stuff is so hard to find help with? I've literally spent like a month and only just now I finally understand how everything works and what I need to do to make something happen.
Ok, so I just accidentally hit the back button on my browser after writing out my problem for 10 minutes...
basically, I'm attempting to copy a listview's checked items to a second thread so that my form doesn't start lagging up when I make ~2800 invokes to those checked items from the second thread. My problem is that whatever I do creates a reference to the listView, and doesn't create a new instance of the collection. How would I get it to create a new instance of the collection (specifically a ListView.CheckedListViewItemsCollection)?
[editline]01:32PM[/editline]
There are two methods in this code right now, sorry about it being a bit messy, I'll clean it all up when I have a working copy of the collection..
My delegate method:
[cpp]public delegate ListView.CheckedListViewItemCollection CheckedItemCollectionCallBackType();[/cpp]
The button that starts the new thread:
[cpp]private void btn_convert_Click(object sender, EventArgs e)
{
//make sure there's a list before we convert
if (!b_list_created)
MessageBox.Show("No directory loaded! Please click the \"Set Directory\" button to load a directory first.");
else
{
//Disable all interaction and set values prior to work thread.
lbl_progress.Text = "Initializing...";
listView.Enabled = false;
btn_check.Enabled = false;
btn_uncheck.Enabled = false;
btn_convert.Enabled = false;
btn_setDir.Enabled = false;
btn_options.Enabled = false;
menuStrip1.Enabled = false;
if (s_dir == "")
{
s_dir = root_dir;
}
progressBar.Maximum = listView.CheckedItems.Count;
//Run the conversion in a separate thread
ConvertOptions co = new ConvertOptions();
co.collection = listView;
Thread converter = new Thread(xbt_convert);
converter.Name = "FileConverterThread";
converter.Start((object)co);
}
}[/cpp]
The start of my second thread (where I try and parse the location of each file):
[cpp]private void xbt_convert(object lsvClass)
{
//Setup
ListView.CheckedListViewItemCollection collection = (ListView.CheckedListViewItemCollection)Invoke(new CheckedItemCollectionCallBackType(ReturnListViewItem));
//ConvertOptions co = (ConvertOptions)lsvClass;
//ListView collection = (ListView)lsvObject;
string[] lsv = new string[collection.Count];
Invoke(new setlblTextCallBackType(setlblProgressText), "Generating filelist...");
//Call back to thread 1 and grab all the file locations
for (int init = 0; init < collection.Count; init++)
{
lsv[init] = (string)collection[init].SubItems[1].Text;
//set progress bar value
Invoke(new progressCallBackType(setProgressBarVal), init);
}
//....(there's more to this method, I just don't want to start stretching the page with unrelated code)
}[/cpp]
What's currently in ReturnListViewItem (it's changed quite a bit, from string to object to the listview collection object):
[cpp]public ListView.CheckedListViewItemCollection ReturnListViewItem()
{
return listView.CheckedItems;
}[/cpp]
And finally, my secondary "class" which I thought would have worked by holding a new instance of the ListView that I could reference, even though it doesn't:
[cpp]public class ConvertOptions
{
public ListView collection;
}[/cpp]
I'm trying to use Perlin noise to generate heightmaps, but keep getting images like this:
[img]http://i56.tinypic.com/33fclr6.png[/img]
Using this code:
[cpp]#include <ctime>
#include <cstdlib>
#include <cmath>
#include "Perlin.h"
Perlin::Perlin(int iSampleSize, unsigned int uiSeed)
: m_iSampleSize(iSampleSize)
{
if(uiSeed == 1)
{
// Initialize seed to Unix time
time((time_t *) &uiSeed);
}
// Seed psuedo-random number generator
srand(uiSeed);
// Initialize the permutation table
m_aiPermutations = new int[iSampleSize];
for(int i = 0; i < iSampleSize; i++)
m_aiPermutations[i] = i;
for(int i = 0; i < iSampleSize; i++)
{
int j = rand() % iSampleSize;
int k = m_aiPermutations[i];
m_aiPermutations[i] = m_aiPermutations[j];
m_aiPermutations[j] = k;
}
}
Perlin::~Perlin()
{
delete m_aiPermutations;
}
// Nonlinear fading of t
float Perlin::Fade(float t)
{
return t * t * t * (t * (t * 6 - 15) + 10);
}
// Linear interpolation between a and b
float Perlin::Lerp(float t, float a, float b)
{
return a + t * (b - a);
}
float Perlin::Grad(int hash, float x, float y)
{
int h = hash & 3;
float u = (h & 2) == 0 ? x : -x;
float v = (h & 1) == 0 ? y : -y;
return u + v;
}
// Bi-dimensional noise
float Perlin::Noise2(float x, float y)
{
// Compute neighbouring grid coordinates
int ix, iy;
ix = (int) x % (m_iSampleSize - 1);
iy = (int) y % (m_iSampleSize - 1);
float fx0, fx1, fy0, fy1;
fx0 = x - floor(x);
fx1 = fx0 - 1.0f;
fy0 = y - floor(y);
fy1 = fy0 - 1.0f;
// Permute hash coordinates
int A, B;
A = m_aiPermutations[ix] + iy;
B = m_aiPermutations[ix + 1] + iy;
// Compute fade curves
float u, v;
u = Fade(fx0);
v = Fade(fy0);
// Interpolate between directions
return Lerp(v, Lerp(u, Grad(m_aiPermutations[A], fx0, fy0),
Grad(m_aiPermutations[A + 1], fx0, fy1)),
Lerp(u, Grad(m_aiPermutations[B], fx1, fy0),
Grad(m_aiPermutations[B + 1], fx1, fy1)));
}
[/cpp]
If i have two ints, one being 6 and the other being 4. How would I 'generate' a unique ID using them both, ranging from 0 - 23?
[QUOTE=layla;24796039]If i have two ints, one being 6 and the other being 4. How would I 'generate' a unique ID using them both, ranging from 0 - 23?[/QUOTE]
I don't really know want because you didn't explain it well. You should write down what you want, the inputs and outputs, and stuff.
[QUOTE=layla;24796039]If i have two ints, one being 6 and the other being 4. How would I 'generate' a unique ID using them both, ranging from 0 - 23?[/QUOTE]
[code]
long id = num1 * INT_MAX + num2;
[/code]
Recompiling my application with the latest .net SDK (the old version was on the beta) fixed my button problem.
[QUOTE=layla;24796039]If i have two ints, one being 6 and the other being 4. How would I 'generate' a unique ID using them both, ranging from 0 - 23?[/QUOTE]
In order to clamp a value to a certain range you can use modulo, so you could for example do
[code]int id = int1 * int2 % 23[/code]
I'm interested in making something like Ndless for the new Nspire 2. Where would I have to look/learn in order to make something like this?
can anyone link me to something that simplifies quaternions and spacial rotation. Wikipedia is worded so poorly that I can't understand a thing. Videos, pictures, and kind of visual aid would be tremendous.
[QUOTE=DOG-GY;24813807]can anyone link me to something that simplifies quaternions and spacial rotation. Wikipedia is worded so poorly that I can't understand a thing. Videos, pictures, and kind of visual aid would be tremendous.[/QUOTE]
Quaternions are pretty complex, and I don't think you'll find an explanation much simpler than the one on Wikipedia.
I've found [url=http://www.lce.hut.fi/~ssarkka/pub/quat.pdf]this reference[/url] very helpful in the past.
It's also important to note that there are two quaternions to represent any given orientation. This is important when using SLERP, because you will get the longest or shortest possible path depending on which ones you use. (You can use the dot product to check)
Posting this again for a new page: How do I create a new instance of a ListView and copy all the data to it? (in C#) Making >2000 invoke calls from one thread to another in order to grab all the subitems takes WAY too long and still lags up the program, because it's still the main thread being invoked constantly.
Or does anyone know a painless way of copying subitems (not items) from a ListView into a string array?
How can i use SFML in QT Creator IDE on linux?
-s to the n to the i to the p-
lol i am dum
[url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
I need help with a VBA (HURR) code
[code]Function Resistance(Color1, Color2, Color3)
'First color is The first Number. Second is the second number. If there is no fourth color, then the Third is how many 0's you add at the end. If there is a fourth, then the first three are your first three numbers and the FOURTH is the number of 0's.
Select Case Color1
Case black: First = 0
Case brown: First = 10
Case red: First = 20
Case orange: First = 30
Case yellow: First = 40
Case green: First = 50
Case blue: First = 60
Case purple: First = 70
Case violet: First = 70
Case grey: First = 80
Case white: First = 90
End Select
Select Case Color2
Case black: Second = 0
Case brown: Second = 1
Case red: Second = 2
Case orange: Second = 3
Case yellow: Second = 4
Case green: Second = 5
Case blue: Second = 6
Case purple: Second = 7
Case violet: Second = 7
Case grey: Second = 8
Case white: Second = 9
End Select
Select Case Color3
Case black: Third = 10 ^ 0
Case brown: Third = 10 ^ 1
Case red: Third = 10 ^ 2
Case orange: Third = 10 ^ 3
Case yellow: Third = 10 ^ 4
Case green: Third = 10 ^ 5
Case blue: Third = 10 ^ 6
Case purple: Third = 10 ^ 7
Case violet: Third = 10 ^ 7
Case grey: Third = 10 ^ 8
Case white: Third = 10 ^ 9
End Select
Resistance = (First + Second) * Third
End Function[/code]
[QUOTE=WTF Nuke;24675388]How do I use tinxml to go to an element? This doesn't work:
[code]
character.ToElement(currentmap);
chracter >> maps.mapname;
[/code][/QUOTE]
Repost for a new page. Sorry about it, I just have no idea what to do with this :saddowns:.
[QUOTE=Whiterfire;24829648][url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
[url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
[url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
[url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
[url]http://www.facepunch.com/showthread.php?p=24827886#post24827886[/url]
I need help with a VBA (HURR) code[/QUOTE]
Try Google instead of spamming your thread
Sorry, you need to Log In to post a reply to this thread.