[QUOTE=Bambo.;35397975]so what does everyone use?[/QUOTE]
You can use triangle strips if you want to, I think they work OK for terrain because it's got a very regular pattern.
In general, though, I think indexed triangle lists give (slightly) better performance. Maybe even for terrain.
[url]http://hacksoflife.blogspot.com/2010/01/to-strip-or-not-to-strip.html[/url]
how to set texture coordinates right on a 3D (or 2D) square?
[code]
private static FloatBuffer texbuf, vertbuf;
private final void TextureCoords()
{
float texcoord[] =
{
0.0f, 1.0f, // 0,1
1.0f, 1.0f, // 1,1
1.0f, 0.0f, // 1,0
0.0f, 0.0f, // 0,0
};
ByteBuffer bytebuf = ByteBuffer.allocateDirect(texcoord.length * 4);
bytebuf.order(ByteOrder.nativeOrder());
texbuf = bytebuf.asFloatBuffer();
texbuf.put(texcoord);
texbuf.position(0);
}
private final void VertexCoords()
{
float vertcoord[] =
{
-256.0f, 256.0f,-256.0f, // 0,1
256.0f, 256.0f,-256.0f, // 1,1
256.0f,-256.0f,-256.0f, // 1,0
-256.0f,-256.0f,-256.0f, // 0,0
};
ByteBuffer vbb = ByteBuffer.allocateDirect(vertcoord.length * 4);
vbb.order(ByteOrder.nativeOrder());
vertbuf = vbb.asFloatBuffer();
vertbuf.put(vertcoord);
vertbuf.position(0);
}
[/code]
is shown all gray.
draw: [url]http://pastebin.com/0JAaKuGa[/url]
Could somebody help me set up SQL.
I have just been trying to learn it using the Northwind Database and I downloaded Microsoft SQL Management Suite but it keeps asking me to connect to a server and I have no idea what I am meant to be connecting to. I just want to use the Northwind database to try some stuff, I have been using it on the College computers but How do I get it working at home?
Connect to localhost.
In the server part it says (local) when I try connect to that it doesn't work.
Is it meant to be localhost?
Does anyone know of a good multimedia library for C other than Allegro.
[QUOTE=Over-Run;35399345]In the server part it says (local) when I try connect to that it doesn't work.
Is it meant to be localhost?[/QUOTE]
Do you have SQL Server? You have to actually have the server installed and running, unless you plan to use Access instead.
[editline]2nd April 2012[/editline]
[QUOTE=/dev/sda1;35399378]Does anyone know of a good multimedia library for C other than Allegro.[/QUOTE]
SDL?
[QUOTE=shill le 2nd;35399456]Do you have SQL Server? You have to actually have the server installed and running, unless you plan to use Access instead.
[editline]2nd April 2012[/editline]
SDL?[/QUOTE]
Thanks.
I installed Microsoft SQL Server 2008, I have no idea how to use any of it, I just knew how to use it in College. How do I run the server and connect to NorthWind?
XNA C#:
Suppose I have a BasicEffect that has Projection and View matrices set. What method exists to get the Vector2 screen position from a Vector3 world coordinate?
Better yet, what should I use to draw a Texture2D to the screen when given a Vector3 to place it at, with camera position, camera 3D rotation, sprite scale, and sprite 3D rotation all taken into account?
[QUOTE=Ehmmett;35401696]
[lua]function ent.keypress(key)
for i,k in ipairs(ent) do
if ent[i].keypress ~= nil then
ent[i].keypress(key)
end
end
[/lua][/QUOTE]
Try this.
[QUOTE=Hypershadsy;35401294]XNA C#:
Suppose I have a BasicEffect that has Projection and View matrices set. What method exists to get the Vector2 screen position from a Vector3 world coordinate?
Better yet, what should I use to draw a Texture2D to the screen when given a Vector3 to place it at, with camera position, camera 3D rotation, sprite scale, and sprite 3D rotation all taken into account?[/QUOTE]
Not sure how in XNA, but try looking up Projecting and Unprojecting.
[editline]2nd April 2012[/editline]
[url=http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.unproject.aspx]Found this[/url]
[editline]2nd April 2012[/editline]
[url=http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.project.aspx]and this[/url]
[QUOTE=NovembrDobby;35402020]Not sure how in XNA, but try looking up Projecting and Unprojecting.
[editline]2nd April 2012[/editline]
[url=http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.unproject.aspx]Found this[/url]
[editline]2nd April 2012[/editline]
[url=http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.project.aspx]and this[/url][/QUOTE]
In XNA you can use GraphicsDevice.Viewport.Unproject and GraphicsDevice.Viewport.Project :P
[QUOTE=Jawalt;35389077]OpenGL or Canvas?
[editline]1st April 2012[/editline]
This is good advice regardless, but usually the power of 2 problem causes white boxes, not distortion.[/QUOTE]
Using canvas.
So I got a free magnetic card reader that can read credit cards and the such
[url]http://www.magtek.com/V2/products/secure-card-reader-authenticators/magnesafe-mini.asp[/url]
The [URL="http://www.magtek.com/support/software/demo_programs/usb_swipe_insert.asp"]software[/URL] they give you is pretty much made to be modified to whatever you need. My question is what I need to modify it
The source installation option gives me this:
[img]http://i.imgur.com/ZkQwq.png[/img]
What would I need to modify this, I am pretty sure the extensions are for Basic and Visual Basic
Umm you need Visual Basic (6?)
Im trying to re-route all the std::cout stuff to a file instead of the console using this example:
[cpp]#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream log("output.log");
ostream placeHolder = cout;
cout = log;
cout << "this is a test..." << endl; // note that the endl is a little more important here since it will flush the buffer.
log.close();
cout = placeHolder;
cout << "this is also a test..." << endl;
return 0;
}[/cpp]
But when I do that in my application I get these errors
[code]/usr/include/c++/4.6/bits/ios_base.h||In member function ‘std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)’:|
/usr/include/c++/4.6/bits/ios_base.h|791|error: ‘std::ios_base& std::ios_base::operator=(const std::ios_base&)’ is private|
/usr/include/c++/4.6/bits/basic_ios.h|64|error: within this context|
/usr/include/c++/4.6/ostream||In member function ‘std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&)’:|
/usr/include/c++/4.6/ostream|57|note: synthesized method ‘std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)’ first required here |
/home/richy/Desktop/game/src/main.cpp||In function ‘int main(int, char**)’:|
/home/richy/Desktop/game/src/main.cpp|22|note: synthesized method ‘std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&)’ first required here |
||=== Build finished: 4 errors, 0 warnings ===|
[/code]
Why are you trying to redefine "cout"? Just use "log << "whatever" << endl"
I already have alot of cout << stuff << endl in my program, and i want to be able to put that into a file without having to rewrite my hole program
Well, you can't redefine the cout object, but what you can do (it's a bit of a hack) is do a preprocessor replacement:
#define cout log
But that will affect your whole program. If you don't want that, you're going to have to do a search-and-replace (just use the search-and-replace function in your IDE; you don't have to "rewrite" anything). cout is an object of class ostream, not a pointer, and the ostream class does not allow reassignment (that is why the errors are telling you that operator= is private within the context; ostream has its operator= set to private so you cannot reassign an object of that class)
Ok, I have been trying to solve this by myself for the past day but haven't figured it out yet so here it goes.
I started messing around with Love2d a few days ago and right now I'm drawing something procedural to the screen that keeps getting recalculated all the time because it is inside the love.draw() callback, if I stop it from drawing the screen will be cleared, it's also very processing intensive.
Is there a way for me to draw this image on a separate thread and send it over to the main loop as an image? If so, could you give me a simple example?
Thanks in advance
[QUOTE=Richy19;35403580]I already have alot of cout << stuff << endl in my program, and i want to be able to put that into a file without having to rewrite my hole program[/QUOTE]
C++ doesn't let you re-define variables, you're going to have to write a function that logs a message to a file and use that everywhere.
[cpp]
std::ofstream logfile;
void logSomeShit( std::string theShit )
{
if( !logfile.is_open() ) {
logfile.open("ohsnap.log");
}
logfile << theShit << std::endl;
}
[/cpp]
[QUOTE=danharibo;35403726]C++ doesn't let you re-define variables, you're going to have to write a function that logs a message to a file and use that everywhere.
[cpp]
std::ofstream logfile;
void logSomeShit( std::string theShit )
{
if( !logfile.is_open() ) {
logfile.open("ohsnap.log");
}
logfile << theShit << std::endl;
}
[/cpp][/QUOTE]
No, he can just do a search-and-replace so "cout" becomes "log"; it doesn't need a separate function (if he declares log globally). And C++ definitely does let you redefine variables; it's just that the ostream [I]class[/I] has its operator= set to private; that [i]class[/i] does not let you reassign objects of its type (e.g. cout)
-snip-
[QUOTE=shill le 2nd;35403771]No, he can just do a search-and-replace so "cout" becomes "log"; it doesn't need a separate function (if he declares log globally). And C++ definitely does let you redefine variables; it's just that the ostream [I]class[/I] has its operator= set to private; that [i]class[/i] does not let you reassign objects of its type (e.g. cout)[/QUOTE]
Even if he does do a search and replace for cout, it's still easier to route your logging through a simple function, it's easier to maintain.
Edit:
I misread his code as trying to define cout as a different datatype, my bad.
[QUOTE=danharibo;35403811]Even if he does do a search and replace for cout, it's still easier to route your logging through a simple function, it's easier to maintain.
Edit:
I misread his code as trying to define cout as a different datatype, my bad.[/QUOTE]
That's true in a sense, but he doesn't want to "rewrite his code" so that's probably too complicated for what he wants to do.
[QUOTE=shill le 2nd;35403866]That's true in a sense, but he doesn't want to "rewrite his code" so that's probably too complicated for what he wants to do.[/QUOTE]
regex to the rescue
cout << (.*) << std::endl;
loggingFunction( \1 );
Hey guys
why can't you make a loggerstream class that's an ostream that deals with the logging
[QUOTE=esalaka;35403999]Hey guys
why can't you make a loggerstream class that's an ostream that deals with the logging[/QUOTE]
That would do nothing beyond clog your namespace with a class that's just a copy of another.
You're either going to want to make a class that contains an ostream and passes any messages into it, or just use a typedef:
[cpp]
typedef std::ostream Logger;
[/cpp]
As its not possible to re define cout, is it possible to access everything that has been writen to it, and just dump that into a file?
[editline]3rd April 2012[/editline]
I have just ended up doing this:
[cpp]// redirecting cout's output
#include <iostream>
#include <fstream>
using namespace std;
int main () {
streambuf *psbuf, *backup;
ofstream filestr;
filestr.open ("test.txt");
backup = cout.rdbuf(); // back up cout's streambuf
psbuf = filestr.rdbuf(); // get file's streambuf
cout.rdbuf(psbuf); // assign streambuf to cout
cout << "This is written to the file";
cout.rdbuf(backup); // restore cout's original streambuf
filestr.close();
return 0;
}[/cpp]
As this page suggests: [url]http://www.cplusplus.com/reference/iostream/ios/rdbuf/[/url]
Works perfectly.
Sorry, you need to Log In to post a reply to this thread.