Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 |
CMath *vec: vec = new CVector2D(); ((CVector2D*)vec)->add(1, 2); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
//----vector2d.h #ifdef _WINDLL # define ENGINE_API __declspec(dllexport) #else # define ENGINE_API __declspec(dllimport) #endif struct ENGINE_API vector2d{ float x; float y; vector2d(){}; vector2d(float a, float b){x = a; y = b;}; vector2d &operator +=(vector2d &b){ x += b.x; y += b.y; return *this; }; vector2d operator +(vector2d &b)const{ return vector2d(x + b.x, y + b.y); }; //is eigentl. ueberfluessig vector2d &operator =(vector2d &b){ x = b.x; y = b.y; return *this; }; vector2d &add(vector2d &b){ x += b.x; y += b.y; return *this; }; }; //---main.cpp #include <iostream> #include "vector2d.h" #pragma comment(lib, "enginedll.lib") int main(){ using namespace std; vector2d va(1, 2), vb(3, 4); vector2d *res; //damit auch ein new drin is :) res = new vector2d(); (*res) = va + vb; //sollte "result: 4, 6" ausspucken cout<<"result: "<<res->x<<", "<<res->y<<endl; (*res) = vector2d(1, 2); res->add(va); //sollte "result: 2, 4" ausspucken cout<<"result: "<<res->x<<", "<<res->y<<endl; delete res; return 0; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
class ENGINE_API baseShader{ private: protected: public: virtual bool loadFromFile(const char *) = 0; virtual bool setFConstant(float *, uint) = 0; //...etc. }; class ENGINE_API vertexShader:public baseShader{ public: bool loadFromFile(const char *){//...}; bool setFConstant(float *f, uint size){ return SUCCEEDED(device->SetVertexShaderConstantF(f, size)); }; }; class ENGINE_API pixelShader:public baseShader{ public: bool loadFromFile(const char *){//...}; bool setFConstant(float *f, uint size){ return SUCCEEDED(device->SetPixelShaderConstantF(f, size)); }; }; |
Zitat
... geht da nicht wieder ein stück unabhängigkeit verloren?
Werbeanzeige