c++

c++: how can i use sdl to load a bitmap into a cube in opengl ?

Hiya. I'm learning OpenGL and SDL and so far I've been able to properly draw and rotate 3d polygons ( yay for me! :) ) how can I load an image file using SDL and load that texture on the 3d shapes that i draw on screen using OpenGL. thanks!!! update I tried the following code that draw a cube, rotates it and adds a bitmap, but I don...

Knight movement.... " how to output all possible moves. "

The following is the code i wrote.. I have to write it for nXn but for easyness i tried to test it for 5X5. It does not display my output... could anybody tell me whats wrong with the following code: { #include <iostream> #include <iomanip> using namespace std; void knight ( int startx, int starty, int n, int p[][5], int used [][5], ...

Question about "Link Map" output and "Assume" directive of MASM assembler.

I am new to MASM. So the questions may be quite basic. When I am using the MASM assembler, there's an output file called "Link Map". Its content is composed of the starting offset and length of various segments, such as Data segment, Code segment and Stack segment. I am wondering that, where are these information describing? Are they ta...

Any way in C++ to forward declare a function prototype?

I make regular use of forward class declarations and pointers to such classes. I now have a need to pass a function pointer through a number of layers. I would prefer to include the header that declares my function pointer's prototype only into the module that dereferences a function pointer rather than into each layer that simply passe...

Vectors of Pointers, inheritance

Hi I am a C++ beginner just encountered a problem I don't know how to fix I have two class, this is the header file: class A { public: int i; A(int a); }; class B: public A { public: string str; B(int a, string b); }; then I want to create a vector in main which store either class A or class B vect...

clearing cin input? cin.ignore not a good way?

What's a better way to clear cin input? I thought cin.clear and cin.ignore was a good way...? code: void clearInput() { cin.clear(); cin.ignore(1000,'\n'); //cin.ignore( std::numeric_limits<streamsize>::max(), '\n' ); } My teacher gave me this reply... this is basically saying that your clearInput doesn't work ...

Stack overflow error after creating a instance using 'new'

EDIT - The code looks strange here, so I suggest viewing the files directly in the link given. While working on my engine, I came across a issue that I'm unable to resolve. Hoping to fix this without any heavy modification, the code is below. void Block::DoCollision(GameObject* obj){ obj->DoCollision(this); } That is where the sta...

C++ include .h includes .cpp with same name as well?

I have text.cpp which includes header.h and header.cpp which includes header.h. Will header.cpp be compiled as well? I'm following a guide here, and I am thoroughly confused. Also, what is the correct terminology for what I am asking? I know I sound like a moron, and I apologize, but I'm ignorant. Oh, int main() is in test.cpp. Also,...

Given a 1TB data set on disk with around 1KB per data record, how can I find duplicates using 512MB RAM and infinite disk space?

There is 1TB data on a disk with around 1KB per data record. How to find duplicates using 512MB RAM and infinite disk space? ...

llvm clang struct creating functions on the fly

I'm using LLVM-clang on Linux. Suppose in foo.cpp I have: struct Foo { int x, y; }; How can I create a function "magic" such that: typedef (Foo) SomeFunc(Foo a, Foo b); SomeFunc func = magic("struct Foo { int x, y; };"); so that: func(SomeFunc a, SomeFunc b); // returns a.x + b.y; ? Note: So basically, "magic" needs to tak...

How to use boost::crc?

I want to use boost::crc so that it works exactly like PHP's crc32() function. I tried reading the horrible documentation and many headaches later I haven't made any progress. Apparently I have to do something like: int GetCrc32(const string& my_string) { return crc_32 = boost::crc<bits, TruncPoly, InitRem, FinalXor, ...

LVM_INSERTITEM very slow in vista/W7

in a large listview control collection (say 5000 items), adding a SINGLE extra item can take 10+ seconds in windows vista/7, and that's just the LVM_INSERTITEM message handling it looks that it only affects LVS_ICON, LVS_REPORT and LVS_LIST are still very fast can anybody confirm this? the same code on windows XP with similar listview...

Is a control tree cached after the first call to FindWindowEx/EnumChildWindows?

I noticed that if you call FindWindowEx or EnumChildWindows against a hWnd that belongs to a window that's not in the foreground, i.e. minimized, then they don't report any children. On the other hand if I first call SetForegroundWindow against the window I'm querying, and after that FindWindowEx or EnumChildWindows, they report all the ...

C++ Convert string (or char*) to wstring (or wchar_t*)

string s = "おはよう"; wstring ws = FUNCTION(s, ws); How would i assign the contents of s to ws? Searched google and used some techniques but they can't assign the exact content. The content is distorted. ...

Binary Search Tree node removal

I've been trying to implement a delete function for a Binary Search Tree but haven't been able to get it to work in all cases. This is my latest attempt: Node* RBT::BST_remove(int c) { Node* t = get_node(c); Node* temp = t; if(t->get_left() == empty) *t = *t->get_left(); else if(t->get_right() == empty) ...

C++ min heap with user-defined type.

Hi, I am trying to implement a min heap in c++ for a struct type that I created. I created a vector of the type, but it crashed when I used make_heap on it, which is understandable because it doesn't know how to compare the items in the heap. How do I create a min-heap (that is, the top element is always the smallest one in the heap) fo...

How can I load an MP3 or similar music file for display and analysis in wxWidgets?

I'm developing a GUI in wxPython which allows a user to generate sequences of colours for some toys I'm building. Part of the program needs to load an MP3 (and potentially other formats further down the line) and display it to the user. That should be sufficient to get started but later I'd like to add features like identifying beats and...

gluLookAt doesn't work

hi, i'm programming with opengl and i want to change the camera view: ... void RenderScene() //Zeichenfunktion { glClearColor( 1.0, 0.5, 0.0, 0 ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity (); //1.Form: glBegin( GL_POLYGON ); //polygone glColor3f( 1.0f, 0.0f, 0.0f ); //rot glVe...

if i want to build logger class in c++ or java what should it be singletone or static

Hello all general question is i like to build logger class that writes to single log file from different classes in my application what should the logger class be singletone or static class ...

Testing of coding and naming conventions of C/C++ code

I'm looking for a script/tool that can be customized to check and enforce coding/naming conventions on a C/C++ code. It should check for example: Code lines are wrapped at some length. Private variables have prefix _ Code is indented properly. All functions are documented. Many of the projects I'm working on are outsourced by custo...