[QUOTE=WTF Nuke;35629246]Wow thanks, but how does that work?[/QUOTE]
It casts the character array pointer into a float pointer and stores it just as if it were a float at that location in memory.
[QUOTE=WTF Nuke;35629246]By flip do you mean src= *((float*)dst)?[/QUOTE]
No.
What I mean is that different systems store multi-byte values in different orders. It's called 'byte order' or 'endianness'. Some systems are little-endian (like x86), others are big-endian, and some can do either (ARM, etc.).
So if you want to write a file or send some data and have it make sense to every system, you have to choose either big-endian or little-endian for your format and convert accordingly.
Oh I see, thanks for the help man.
[editline]18th April 2012[/editline]
Sorry for bothering again, but this problem just doesn't make sense to me. Between these two calls:
[cpp]std::auto_ptr<cManager> managy(new cManager(name, app));
managy->gameLoop();[/cpp]
The value of managy->sd is dropped from being the socket number, to 0. I have checked and at the end of the constructor, the value of sd is not 0, but at the start of the gameLoop() call it becomes 0. It is not edited by anything else, and I am confused as to what is going on.
I am trying to make a function for checking to see if the player is inside of a prop for all constrained entities. Basically, if you have a ship, it will know if a player is inside of the thing by using it's bounding box.
And I have come up with a method for this. However, it is really expensive in terms of server processing, as it involves comparing the OBBMins and OBBMaxs of each constrained entity, then checking to see if it is inside of that, recursively. Certain people on my server have 100+ prop ships, and since it is checking for each player, you can see how this would get really resource intensive.
I have seen an entity that does this well with a relatively low performance hit, but have no idea how they did it. Is there some kind of function that makes this easy/cheap on the server? I've done a lot of looking through the Lua function Libraries and can't find anything.
EDIT: Nevermind, figured this one out.
Can anyone link me to any beginner level tutorials on C and C++? I am having a hard time really understanding things like %d, is there a list where it explains stuff like that?
And does anyone know of any books I should defiantly read if I want to become a programmer?
Trying to learn VBO so I wouldn't use immediate mode, but it is not drawing. I have looked over it a bunch of times and I still cannot see what I am doing wrong.
You can find the code for loading/drawing here: [URL="https://github.com/Bumrang/Vertex-Buffer-Object/blob/master/Triangle.cpp"]https://github.com/Bumrang/Vertex-Buffer-Object/blob/master/Triangle.cpp[/URL]
Triangle.cpp:
[CODE]#include "Triangle.h"
void Triangle::Load()
{
GLfloat Verts[] = {800 / 2, 600, 0, /**/ 0, 0, 0, /**/ 800, 0, 0}; // all the verts
GLubyte Index[] = {0, 1, 2}; // index
glGenBuffers (1 , &VBO); // create the buffers
glGenBuffers (1 , &Indices);
glBindBuffer (GL_ARRAY_BUFFER , VBO); // bind the buffers for verts
glBufferData (GL_ARRAY_BUFFER , sizeof (Verts) , Verts , GL_STATIC_DRAW);
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER , Indices); // indices
glBufferData (GL_ELEMENT_ARRAY_BUFFER , sizeof (Index) , Index , GL_STATIC_DRAW);
} // Simple so far.
void Triangle::Draw()
{
glLoadIdentity ();
glTranslatef (0 , 0 , -10);
glRotatef (ZRot , 0 , 0 , 1);
glColor3f (1 , 0 , 0);
glBindBuffer (GL_ARRAY_BUFFER , VBO);
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER , Indices);
glEnableVertexAttribArray (0);
glVertexAttribPointer (0 , 3 , GL_FLOAT , GL_FALSE , sizeof (float) * 3 , 0);
glDrawElements (GL_TRIANGLES , 3 , GL_UNSIGNED_BYTE , 0);
/* glPushMatrix();
glTranslatef(0,0,0);
glBegin(GL_TRIANGLES);
glVertex2f(800/2,600);
glVertex2f(0,0);
glVertex2f(800,0);
glEnd();
glPopMatrix();*/ // immediate mode, use if vbo is not working (debugging yay)
}[/CODE]
I'm pretty sure I'm doing something wrong with VBO, I tried the same coordinates with immediate mode and it worked.
Maybe the tutorial I'm using is wrong? I'm using this tutorial: [URL="http://www.theamazingking.com/ogl-vbo.php"]http://www.theamazingking.com/ogl-vbo.php[/URL]
[editline]18th April 2012[/editline]
[QUOTE=HoodedSniper;35630637]Can anyone link me to any beginner level tutorials on C and C++? I am having a hard time really understanding things like %d, is there a list where it explains stuff like that?
And does anyone know of any books I should defiantly read if I want to become a programmer?[/QUOTE]
[URL="http://www.youtube.com/user/antiRTFM"]AntiRTFM[/URL]
[QUOTE=esalaka;35624841]It means it can resolve to several objects
[editline]18th April 2012[/editline]
Or things in general, not just objects I guess?[/QUOTE]
So basically just a duplicate name that will be solved by renaming the class?
[QUOTE=HoodedSniper;35630637]Can anyone link me to any beginner level tutorials on C and C++? I am having a hard time really understanding things like %d, is there a list where it explains stuff like that?
And does anyone know of any books I should defiantly read if I want to become a programmer?[/QUOTE]
I take it you are talking about printf(). There are numerous references out there, because C/C++'s standard libraries vary from compiler to compiler. However I like to refer to [url]http://cplusplus.com[/url].
Anyways %d in a string refers to a decimal variable. [url]http://cplusplus.com/reference/clibrary/cstdio/printf/[/url]
[QUOTE=Topgamer7;35631750]I take it you are talking about printf(). There are numerous references out there, [b]because C/C++'s standard libraries vary from compiler to compiler[/b]. However I like to refer to [url]http://cplusplus.com[/url].
Anyways %d in a string refers to a decimal variable. [url]http://cplusplus.com/reference/clibrary/cstdio/printf/[/url][/QUOTE]
wot
[QUOTE=shill le 2nd;35628329]What... why are you putting "GameState::" before all the function names in MenuState??[/QUOTE]
Derp. :v: Fixed now.
[QUOTE=Topgamer7;35631750]I take it you are talking about printf(). There are numerous references out there, because C/C++'s standard libraries vary from compiler to compiler. However I like to refer to [url]http://cplusplus.com[/url].
Anyways %d in a string refers to a decimal variable. [url]http://cplusplus.com/reference/clibrary/cstdio/printf/[/url][/QUOTE]
That is the type of thing I was looking for, thank you!
[QUOTE=Mordi;35626235]What's the correct syntax for inheriting constructors in C++?
The following does not work.
GameState.h (Parent)
[cpp]class GameState
{
public:
GameState();
};[/cpp]
MenuState.h (Child)
[cpp]class MenuState : public GameState
{
public:
MenuState() : GameState() { }
};[/cpp]
There is also MenuState.cpp, but I'm not sure whether or not I'll need to do anything there?[/QUOTE]
So, can anyone point me in the right direction while I attempt to find the answer via google?
[QUOTE=Mordi;35634858]So, can anyone point me in the right direction while I attempt to find the answer via google?[/QUOTE]
You dont need to inherit the parents constructor...
[QUOTE=Richy19;35634876]You dont need to inherit the parents constructor...[/QUOTE]
Hmm, you are right. It seems that it works implicitly. Problem solved!
When it comes to keyboard keycodes, would something like [b]44[/b], [b]45[/b], and [b]46[/b] work relative to the [b]Z[/b], [b]X[/b], and [b]C[/b] keys on a QWERTY keyboard? I guess the question is if keycodes are relative based on position, so someone can press keys on the same area on a DVORAK or AZERTY keyboard and have it work?
[QUOTE=Stonecycle;35639997]When it comes to keyboard keycodes, would something like [b]44[/b], [b]45[/b], and [b]46[/b] work relative to the [b]Z[/b], [b]X[/b], and [b]C[/b] keys on a QWERTY keyboard? I guess the question is if keycodes are relative based on position, so someone can press keys on the same area on a DVORAK or AZERTY keyboard and have it work?[/QUOTE]
[url]http://www.asciitable.com/[/url]
Generally it works like this
Windows has a layout of how the keyboard should look. So regardless of what your keyboard thinks it is, windows overrides it and provides whatever the setting is
So if i press the top most left button on my keyboard, it doesnt matter what the keycap says, windows will return a Q (unless azerty etc), and by Q i mean the decimal equivalent of Q
[QUOTE=Icedshot;35640582][url]http://www.asciitable.com/[/url]
Generally it works like this
Windows has a layout of how the keyboard should look. So regardless of what your keyboard thinks it is, windows overrides it and provides whatever the setting is
So if i press the top most left button on my keyboard, it doesnt matter what the keycap says, windows will return a Q (unless azerty etc), and by Q i mean the decimal equivalent of Q[/QUOTE]
But seeing as how this ASCII table also contains lowercase, what value would be sufficient to return A on a QWERTY keyboard: 65 or 97?
I'm making a console hangman game in C#. How do I find how many instances of a character there is in a string and have a number assigned to each place? I need something exactly like IndexOf but not only the first character.
Having some issues removing a specific item from an array. When I try to splice out the specific item it seems to get rid of the entire array as it stands.
Where it's added
[code]prop = _root.attachMovie("prop", "props" + i, _root.getNextHighestDepth());
propArray.push(prop);[/code]
and suppose to be removed.
[code]
if (this.dead == true)
{
for (i = 0; i < _root.propArray.length; ++i)
{
removeMovieClip(this);
_root.propArray.splice(i);
}
}
[/code]
i've tried multiple set ups, this is just the latest one that doesn't work.
[QUOTE=Stonecycle;35640687]But seeing as how this ASCII table also contains lowercase, what value would be sufficient to return A on a QWERTY keyboard: 65 or 97?[/QUOTE]
Depends on how you're reading from the keyboard. If you're reading character codes, 'a' vs. 'A' would be determined by whether the user presses Shift or has CapsLock turned on while pressing the A key. You can also read raw key codes (sometimes known as "scan codes"), which [i]don't[/i] correspond to ASCII characters, they correspond to actual keys on the keyboard. At that level, the A key is the A key regardless of Shift or CapsLock, and the Shift and CapsLock keys have their own key codes so you can tell when the user presses those.
-snip- fixed
I'm currently doing a Java exercise but I'm having some little problems.
I'm trying to make a chat program, and it already sends messages to the server etc.
But when I open up another client and send something, the other client doesn't receive it.
Client.class
[CODE]import java.net.*;
import java.util.Scanner;
import java.io.*;
public class Client extends Thread{
Socket socket;
DataInputStream in;
PrintStream out;
String IP = "0.0.0.0";
int port = 8000;
String message;
String receivetext;
String naam;
Scanner text = new Scanner(System.in);
public static void main (String args[]){
Client client = new Client();
client.getConnection();
client.sendMessage();
client.receiveMessage();
}
private void getConnection(){
try{
socket = new Socket(IP,port);
in = new DataInputStream(socket.getInputStream());
out = new PrintStream(socket.getOutputStream());
System.out.println("Connected to "+IP +":" +port);
System.out.print("Name: ");
naam = text.nextLine();
}
catch(UnknownHostException e){
System.out.println("Connection refused.");
System.out.println("Client - getConnection():"+ e);
}
catch(IOException e){
System.out.println("Connection refused.");
System.out.println("Client = getConnection():"+e);
}
}
private void sendMessage()
{
message = text.nextLine();
System.out.println("You sent: " + message);
out.println(naam+ ": " +message);
}
@SuppressWarnings("deprecation")
private void receiveMessage()
{
try
{
while(true)
{
receivetext = in.readLine();
System.out.println(receivetext);
}
}
catch(IOException e)
{
System.out.println("Client - receiveMessage():" +e);
}
}
}
[/CODE]
Server.class
[CODE]import java.io.*;
import java.net.*;
class Server {
ServerSocket server;
Socket connection;
int port = 8000;
public static void main(String args[])
{
Server server = new Server();
server.getConnection();
}
private void getConnection()
{
System.out.println("Waiting for client...");
try
{
server = new ServerSocket(port);
while(true)
{
new Connection(server.accept());
}
}
catch (IOException e)
{
System.out.println("Server - getConnection(): "+e);
}
}
}
[/CODE]
Connection.class
[CODE]import java.io.*;
import java.net.*;
class Connection extends Thread
{
Socket connection;
DataInputStream in;
PrintStream out;
String message;
Connection(Socket connection)
{
this.connection = connection;
try
{
in = new DataInputStream(connection.getInputStream());
out = new PrintStream(connection.getOutputStream());
}
catch (IOException e)
{
System.out.println("Connection - Connection(): "+e);
}
start();
}
@SuppressWarnings("deprecation")
public void run()
{
try
{
while(true)
{
message = in.readLine();
sendMessage();
}
}
catch(IOException e)
{
System.out.println("Connection - run(): "+e);
System.out.println("Client disconnected");
}
}
private void sendMessage()
{
out.println(message);
System.out.println(message);
}
}[/CODE]
I think the problem lays in the receiveMessage() method in the Client class, but I'm not sure.
[QUOTE=wootmonster;35640759]I'm making a console hangman game in C#. How do I find how many instances of a character there is in a string and have a number assigned to each place? I need something exactly like IndexOf but not only the first character.[/QUOTE]
to find how many:
[code]
char ch = 'f';
int num_char = word.Count(c => c == ch);
[/code]
to get a list of indices where it occurs
[code]
string lol = "fjwairfjawr";
char ch = 'f';
int srch = 0;
List<int> places = new List<int>();
while(lol.IndexOf(ch, srch) != -1)
{
places.Add(lol.IndexOf(ch, srch));
srch = places.Last() + 1;
}
[/code]
I need some help with a chat client I am trying to make.
So I have my Client class okay, and I want it to take a name as a command line parameter, and I have a separate class called Server, which receives any messages and prints them out, but I want it to use the name passed onto the Client class. How can I do this?
So client types Hello and the server command line will print out Bobby: Hello for example.
Here is the two classes:
Server: [url]http://pastebin.com/enVyyxdP[/url]
Client: [url]http://pastebin.com/TUCCSsYv[/url]
Right now it keeps printing null for the name. I'm not sure how to fix it so the name carrys over to the next class
Resizing an n-dimensional array in C/C++:
Let's say I have a structure, a tensor, that has an integer specifying its dimension, an array of integers with the same length as that dimension, specifying the size of each dimension, and finally a pointer to the data. I know how to use realloc to resize a one-dimensional array, and I've seen some solutions for 2d arrays, but how do you extend it to n-dimensional arrays?
I need help with FUD Crypter.
Crypters that are available on internet, can't FUD after 1-2 weeks, because AV companies updating DBs.
So i want to make my own FUD Crypter.
But i dont know where to start. I read some posts, but all of them is VB based. I want to make it on C.
[QUOTE=Eudoxia;35651885]Resizing an n-dimensional array in C/C++:
Let's say I have a structure, a tensor, that has an integer specifying its dimension, an array of integers with the same length as that dimension, specifying the size of each dimension, and finally a pointer to the data. I know how to use realloc to resize a one-dimensional array, and I've seen some solutions for 2d arrays, but how do you extend it to n-dimensional arrays?[/QUOTE]
∏[sup]N[/sup][sub]i=0[/sub] n[sub]i[/sub]
Where:
N is the number of dimensions
n[sub]i[/sub] is the size of a given dimension
Is it possible to control which frame an animation should display for a model animation in Unity? I can't seem to find anything about it.
I'm going to attempt to create a Facepunch app for Windows 8, anything I should know because I'm going in completely blind and learning it along the way.
I'm coding some crap with OpenGL in C++. I'm using core functions of OpenGL 3.2\4.0
At some point, I do
glVertexAttribDivisor(ArrayHandles_[array], count);
This compiles fine, but at link time I get
undefined reference to `glVertexAttribDivisor'
I'm guessing this means that my libGL.so doesn't export the symbol? So I can't use the function? Any way around this? Ubuntu 10.10, libGL.so is /usr/lib/mesa/libGL.so.1.2 provided by libgl1-mesa-glx version 7.9~git20100924-0ubuntu2
I'm supposedly using proprietary drivers but I'm not sure what that means in terms of linking to things.
I am trying to implement a fixed time step into my program but the tutorial that I am looking at has example code in c++ but I only know java. I have run into something that I don't know if I fully understand.
There are two function.
[code]void integrate(State &state, float t, float dt)[/code]
[code]Derivative evaluate(const State &initial, float t)[/code]
BTW State is a struct
From my java background I am guessing that by passing in "const State &initial" passes in a instance of the variable. Then does "State &state" pass in a public var that changes how its changed in the function?
Sorry, you need to Log In to post a reply to this thread.