|
Hello,
I've been programming a C# game engine, mainly just for fun and learning purposes. The project is going very well and i've learned alot seeing as this is my first time working with DirectX, but even though the project is going well i continuously run into the same problem.
I'm building my Engines around the idea of an RTS game and i have 3 seperate engines. The Game Engine(master) and then 2 lower engines the Sprite Engine(DirectDraw) and my Object Engine(Manages Units).
Since i'm still testing things there are times when there are no units on the screen. If this happens and i don't have any debug information being drawn then it begins to lag extremely. Its obviously hard to tell whats going on because it only does it when theres a blank white screen displayed, but i first noticed it in how laggy the responses are in the keyboard.
I'm at a total loss as to why giving DirectX nothing to do would lag my program? any ideas?
Heres a segment of my code from the Sprite engine that actually draws stuff on the screen:
back.ColorFill(Color.White);<br />
<br />
for (int i=0; i <= AnimQPt; i++)<br />
{<br />
for (int z=0; z <= AnimQ[i].spriteCluster.TotalSprites; z++)<br />
{<br />
back.DrawFast(AnimQ[i].spriteCluster.sprites[z].point.X, AnimQ[i].spriteCluster.sprites[z].point.Y, Models[AnimQ[i].intModelID].Sprites[AnimQ[i].spriteCluster.sprites[z].SpriteID].SpriteSurface, AnimQ[i].spriteCluster.sprites[z].rectangle, DrawFastFlags.SourceColorKey);<br />
}<br />
}<br />
if (bObjectNumDisplay)<br />
{<br />
for (int i=0; i <= AnimQPt; i++)<br />
{<br />
back.DrawText(AnimQ[i].pointDisplay.X, AnimQ[i].pointDisplay.Y, AnimQ[i].intUnitID.ToString("N0"), false);<br />
}<br />
back.DrawText(10, 10,"ScreenWidth = " +Screen.Width.ToString()+ " ScreenHeight = " +Screen.Height.ToString()+ " XPos = " +AnimQ[0].pointDisplay.X +" YPos = " +AnimQ[0].pointDisplay.Y +" Current Point = " +this.AnimQ[0].spriteCluster.sprites[0].rectangle.ToString() + " ElapsedTime = " +this.AnimQ[0].pointDisplay.ToString(), false);<br />
}
The variable AnimQPt would normally be -1 if there are no units on the screen.
|
|
|
|
|
How are you rendering the scene - a OnPaint->Invalidate() call (thus making OnPaint be called over and over again)? If so, that could be a cause of your problems; doing OnPaint and Invalidate is extremely inefficient, lots of overhead. It wasn't meant to be used in this manner.
Check out Managed DirectX creator Tom Miller's blog posting here[^] regarding the best, most efficient way to render your scene.
The other possibility is that you're doing something too heavy; too many allocations, too much drawing to the screen, too many garbage collections going on. It's tough to say without a knowledge of the codebase.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Who is Jewish, the Trivia Game!
Judah Himango
|
|
|
|
|
Dear Gurus,
I have the following problem (reduced from more complicated stuff):
I want to process different types of data in a class (in the example I simply store the data).
The problem here (in C#) to my best understanding is, that I have to write an extra function for each data-type. This can be much more easily managed in C++ via Templates.
How do I manage such a problem in C#?
Class-Example:
public class Action {<br />
<br />
public void storeValue(int i) { m_intValue = i; }<br />
public void storeValue(char c) { m_charValue = c; }<br />
public void storeValue(double d) { m_doubleValue = d; }<br />
<br />
private int m_intValue;<br />
char m_charValue;<br />
double m_doubleValue;<br />
}
Thank you for your help
|
|
|
|
|
Hi!
Either you use .NET 2.0, where a template system is supported, or you use public void storeValue(object o) and sacrifice type-safety.
Nevertheless, you can query the real type of the object passed to your function using the typeof or is operators.
Regards,
mav
|
|
|
|
|
hi to all,
how do i go about implementing remoting using SSL sockets?. i have googled for SSL sockets + C# and im getting alot of middleware and 3rd aprty products. is it possible without these, or is it just harder
links to learn from would be good, or msdn docs too.
kind regards,
g00fy
Ethical axioms are found and tested not very differently from the axioms of science. Truth is what stands the test of experience.
Albert Einstein
|
|
|
|
|
|
thank you kindly
g00fy
|
|
|
|
|
hi
i am mukesh
i want zip and folder through coding zip on client and unzip on server
mukesh
|
|
|
|
|
Use DOS/cmd scripts with WIPZIP
|
|
|
|
|
|
You can use the zip libraries through J#. I did this a while back, but I completely forget the details. I don't remember whether I wrote that part in J# and exposed it to C#, or whether it was directly accessible from C#. Now I'm being too lazy to go look it up for you, but this should get you going in the right direction... You can always post back more questions if you need more help.
|
|
|
|
|
Guys,
I need to developed a program in C# that runs every midnight and this program will be executed by our server. This will read data from SQL server and send notification to specific person. The question is which Type of project will I be using "Console Application", "Windows application", "Windows Server"????
I tried to use the Console Application but when I tried to execute the sqldataadapter statement it gives me an error <code>"Additional Information: Request for the permission of type System.data.sqlclient.sqlclientpermission,System.Data, Version=1.0.5000 ...</code> but when I run the same sqldataadapeter in WEb project it works perfect.
Please I need the answer ASAP... thanks.
|
|
|
|
|
How are you connecting in your code, use a SQL server account rather than trusted account as it will be lost once the system service runs the code.
The console app is the righ one to use.
|
|
|
|
|
Yes, I am glad I am on the right track. This is how I connect.
SqlConnection objconn = new SqlConnection("server=server1;database=Personnel;uid=person;pwd=person123;");<br />
objconn.Open();<br />
SqlDataAdapter objadap = new SqlDataAdapter(sSelect,objconn);<br />
objadap.Fill(DSEmployee);<br />
objconn.Close();
Does it mean the I will replace the current connection ID with the connection ID/password that I am using in connecting to the sql server?
Thanks for your help.
|
|
|
|
|
Yes,
you need a connection string like this
SERVER=SQLserver;uid=user;password=pass;DATABASE=Sales
Also you have to go into SQL server enterprise manager and create a SQL Server user (one not based on a domain account) with enough rights on the required database to insert change data etc..
|
|
|
|
|
Dear ones,
I have a specified width, and a long string. I want to know with complete accuracy how much of the string fits in that width for a give font. I have used MeasureString,GenericTypographics, TextRenderingHint etc. But i am not satisfied with the results. Give me any clue,function,API etc that could give the exact string that fits in that specified width.
|
|
|
|
|
In what way are you not satisfied with the results?
---
b { font-weight: normal; }
|
|
|
|
|
hi,
I create in my application a new custom system log and send all my logs to it. In some cases, the log gets corrupted, and the solution I have is to either clear the log or remove it and create a new one instead.
Is there a way to actually find which entries are invalid and remove them and keep the rest of the entries available for me? Or is it possible to go through the entries, and copy the valid ones to a new log file?
Thanks
|
|
|
|
|
|
I know what leads to corrupt my log. sometimes a hard shutdown makes my logs corrupt, a system crash can give me that. I'm not looking for a way to prevent it, I'm looking for a way to repair it without clearing or deleting the log.
|
|
|
|
|
|
Thanks, this did help in minimising the cause of getting a corrupted log.
And I found on the net an actual way of reparing the corrupted one and/or export the entries to HTML or Excel sheet.
|
|
|
|
|
Hi all,
My question is about how to intercept Office event in a C# add-in. I want to intercept file printing, saving, copying etc. I know that I can intercept events in VBA by supplying the rights macros, eg for file print,
Sub FilePrint()
MsgBox "I am printing " + ActiveDocument.Name
ActiveDocument.PrintOut
End Sub
The Application.Class in Word does not seem to have a FilePrint event
So my question is how do I achieve this functionality in a C# add-in ?
Thanks in advance
|
|
|
|
|
Hello all.
First of all I'm trying to send CTRL+ESC using SendKeys.Send("^{ESC}");
It doesn't work. Why?
Second, can you tell me how can i send LWIN (Left Windows key) using SendKeys? Thx
|
|
|
|
|
Hi guys, I am facing a problem regarding static methods, what happens when we call a static method (accessing only local variables),
public static void HelpMePlease()
{
int a=0;
a++;
Console.WriteLine("A must be 1 " + " a :" + a.ToString());
a++;
Console.WriteLine("A must be 2 " + " a :" + a.ToString());
a++;
Console.WriteLine("A must be 3 " + " a :" + a.ToString());
a++;
Console.WriteLine("A must be 4 " + " a :" + a.ToString());
}
Lets suppose, I call this method from 50 threads simultaneously.
will All methods keep single copy of a. or each one will have its own copy.
Please explain it comprehensively, compiler internals etc.
Thanks in advance
M.Waseem
|
|
|
|