Du bist nicht angemeldet.

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

1

15.05.2010, 12:55

2D Grafik

Hallo ich hab da mal wieder ne frage diesmal zum Thema 2D.
Wenn ich so nen Dreieck zeichenn will:

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
struct SVertex
{
    tbVector3           vPosition;  // Position des Vertex
    float               fRHW;
    D3DCOLOR                dwColor;    // Farbe des Vertex
    static const DWORD  dwFVF;      // Vertexformat (statisch)
};

const DWORD SVertex::dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX2 | D3DFVF_TEXCOORDSIZE3(1);

    D3D->SetFVF(SVertex::dwFVF);
    g_aTriangleVertex[0].fRHW = 1;
    g_aTriangleVertex[1].fRHW = 1;
    g_aTriangleVertex[2].fRHW = 1;
    g_aTriangleVertex[0].vPosition  = tbVector3( 0.0f, 0.0f, 0.0f);
    g_aTriangleVertex[1].vPosition  = tbVector3( 0.0f, 640.0f, 0.0f);
    g_aTriangleVertex[2].vPosition  = tbVector3( 480.0f, 640.0f, 0.0f);
    g_aTriangleVertex[0].dwColor    = tbColor(1.0f, 0.0f, 0.0f);
    g_aTriangleVertex[1].dwColor    = tbColor(0.0f, 1.0f, 0.0f);
    g_aTriangleVertex[2].dwColor    = tbColor(0.0f, 0.0f, 1.0f);

    D3D->DrawPrimitiveUP(D3DPT_TRIANGLELIST,    // Dreiecksliste
                                                      1,                    // 1 Dreieck
                                                      g_aTriangleVertex,    // Vertexdaten
                                                      sizeof(SVertex));


warum kriege ich dann nichts angezeigt?

2

15.05.2010, 13:33

Also zu aller erst ist RHW nen float, also 1.0f.
Ansonsten sind D3DFVF_TEX2 und D3DFVF_TEXCOORDSIZE3(1) überflüssig da die Werte dafür nicht in der Struktur vorkommen.

3

15.05.2010, 13:37

Danke erstmal aber das hat nichts gebracht das Dreieck ist immernoch wie vom erdboden verschluckt.

4

15.05.2010, 13:40

Wie sieht der Rest vom Code denn aus?

CBenni::O

1x Contest-Sieger

Beiträge: 1 145

Wohnort: Stuttgart

  • Private Nachricht senden

5

15.05.2010, 13:40

Du renderst die Primitive schon in der Hauptschleife?
Sind die Vertices im Uhrzeigersinn? Ansonsten Umdrehen oder Backface-Culling ausschalten...

mfg CBenni::O
Ein Mitglied der VEGeiCoUndGraSonMaWiGeS Bewegung.
42!
Aufräumen kann jeder, nur das Genie überblickt das Chaos!
Metal will never die!
1. Sppro Gamecontest - mein Beitrag

6

15.05.2010, 13:46

Das ist der Komplette Code vom Program und ich wollte nen Interface anfangen zu Basten. Ich weis er ist nicht Optimal und etwas durcheinander warschein.
culling und umdrehen hat auch nichts gebracht.

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
// Kapitel 3
// Beispielprogramm 02
// ===================
// Dieses Programm demonstriert den Umgang mit der tbModel-Klasse.

#include <TriBase.h>
#include "Resource.h"

// ******************************************************************
// Struktur für einen Vertex der Sky-Box
struct SSkyBoxVertex
{
    tbVector3           vPosition;  // Position
    tbVector3           vTexture;   // 3D-Texturkoordinaten
    static const DWORD  dwFVF;      // Vertexformat
};

const DWORD SSkyBoxVertex::dwFVF = D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0);
struct SVertex
{
    tbVector3           vPosition;  // Position des Vertex
    float               fRHW;
    D3DCOLOR            dwColor;    // Farbe des Vertex
    static const DWORD  dwFVF;      // Vertexformat (statisch)
};

const DWORD SVertex::dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE;

// ******************************************************************
// Globale Variablen
tbConfig                g_Config;                       // Konfigurationsstruktur
tbVertexBuffer*         g_pSkyBoxVB = NULL;             // Sky-Box-Vertex-Buffer
tbIndexBuffer*          g_pSkyBoxIB = NULL;             // Sky-Box-Index-Buffer
PDIRECT3DCUBETEXTURE9   g_pSkyBoxTexture = NULL;        // Sky-Box-Textur
tbEffect*               g_pSkyBoxEffect = NULL;         // Sky-Box-Effekt
tbModel*                g_pCityModel = NULL;            // Modell der Stadt
tbModel*                g_pShipModel = NULL;            // Raumschiffmodell
tbModel*                g_pRaum = NULL;                 // Raumschiffmodell
tbModel*                g_pBildschirm = NULL;           // Raumschiffmodell
tbModel*                g_pWeltkarte = NULL;            // Raumschiffmodell
tbFont*                 g_pFont1 = NULL;                // Erste Schriftart
tbVector3               g_vCameraPos;                   // Kameraposition
float                   g_fCameraRot;                   // Rotation der Kamera
float                   g_fCameraUpDown;                // Schaut die Kamera hoch oder runter?
float                   g_fFOV = TB_DEG_TO_RAD(90.0f);  // Sichtfeld
float                   g_fTime = 0.0f;                 // Globaler Zeitzähler
SVertex                 g_aTriangleVertex[3];           // Die drei Vertizes des Dreiecks

// ******************************************************************
// Die Move-Funktion
tbResult MoveProc(float fNumSecsPassed)
{
    tbVector3 vCameraDir;

    // Den Zeitzähler aktualisieren
    g_fTime += fNumSecsPassed;

    // Tastatursteuerung...
    vCameraDir = tbVector3(sinf(g_fCameraRot) * cosf(g_fCameraUpDown),
                           sinf(g_fCameraUpDown),
                           cosf(g_fCameraRot) * cosf(g_fCameraUpDown));

    if(GetAsyncKeyState(VK_LEFT))       g_fCameraRot -= 1.0f * fNumSecsPassed;
    if(GetAsyncKeyState(VK_RIGHT))      g_fCameraRot += 1.0f * fNumSecsPassed;
    if(GetAsyncKeyState(VK_UP))         g_fCameraUpDown -= 1.0f * fNumSecsPassed;
    if(GetAsyncKeyState(VK_DOWN))       g_fCameraUpDown += 1.0f * fNumSecsPassed;
    if(GetAsyncKeyState(VK_ADD))        g_vCameraPos += vCameraDir * 1.0f * fNumSecsPassed;
    if(GetAsyncKeyState(VK_SUBTRACT))   g_vCameraPos -= vCameraDir * 1.0f * fNumSecsPassed;

    // Die Tasten "Bild auf" und "Bild ab" verändern das Sichtfeld.
    // So kann man in das Bild "hineinzoomen", mit 15 Grad pro Sekunde.
    if(GetAsyncKeyState(VK_PRIOR)) g_fFOV -= TB_DEG_TO_RAD(15.0f) * fNumSecsPassed;
    if(GetAsyncKeyState(VK_NEXT)) g_fFOV += TB_DEG_TO_RAD(15.0f) * fNumSecsPassed;

    // Das Sichtfeld darf 180° und 0° nicht erreichen.
    if(g_fFOV >= TB_DEG_TO_RAD(180.0f)) g_fFOV = TB_DEG_TO_RAD(179.9f);
    else if(g_fFOV <= TB_DEG_TO_RAD(0.0f)) g_fFOV = TB_DEG_TO_RAD(0.1f);

    return TB_OK;
}

// ******************************************************************
// Die Render-Funktion
tbResult RenderProc(float fNumSecsPassed)
{
    tbMatrix    mProjection;
    tbMatrix    mCamera;
    tbMatrix    mWorld;
    tbMatrix    mScall;
    tbVector3   vCameraDir;
    D3DLIGHT9   Light;
    int         iNumPasses;
    char        acText[256];


    // Z-Buffer leeren und die Szene beginnen
    tbDirect3D& D3D = tbDirect3D::Instance();
    //D3D->SetRenderState(D3DRS_LIGHTING, FALSE);
    D3D->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, tbColor(0.0f, 0.0f, 0.0f), 1.0f, 0);
    D3D->BeginScene();

    // Projektionsmatrix erstellen und einsetzen
    mProjection = tbMatrixProjection(g_fFOV, D3D.GetAspect(), 0.1f, 300.0f);
    D3D.SetTransform(D3DTS_PROJECTION, mProjection);

    // Kameramatrix erstellen und einsetzen
    vCameraDir = tbVector3(sinf(g_fCameraRot) * cosf(g_fCameraUpDown),
                           sinf(g_fCameraUpDown),
                           cosf(g_fCameraRot) * cosf(g_fCameraUpDown));
    mCamera = tbMatrixCamera(g_vCameraPos, g_vCameraPos + vCameraDir);
    D3D.SetTransform(D3DTS_VIEW, mCamera);

    

    // ------------------------------------------------------------------

    if(g_pSkyBoxTexture != NULL &&
       g_pSkyBoxVB != NULL &&
       g_pSkyBoxIB != NULL)
    {
        // Die Sky-Box-Textur setzen
        D3D.SetTexture(0, g_pSkyBoxTexture);

        // Weltmatrix erstellen, die die Sky-Box zur Kamera hin schiebt
        mWorld = tbMatrixTranslation(g_vCameraPos);
        D3D.SetTransform(D3DTS_WORLD, mWorld);

        // Vertex- und Index-Buffer aktivieren und das Vertexformat setzen
        D3D->SetStreamSource(0, g_pSkyBoxVB->GetVB(), 0, sizeof(SSkyBoxVertex));
        D3D->SetIndices(g_pSkyBoxIB->GetIB());
        D3D.SetFVF(SSkyBoxVertex::dwFVF);

        // Zeichnen!
        iNumPasses = g_pSkyBoxEffect->Begin();
        for(int iPass = 0; iPass < iNumPasses; iPass++)
        {
            g_pSkyBoxEffect->Pass(iPass);
            D3D->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 8, 0, 12);
        }

        g_pSkyBoxEffect->End();
    }

    // ------------------------------------------------------------------

    // Ein Richtungslicht erstellen mit der Richtung der Kamera
    ZeroMemory(&Light, sizeof(D3DLIGHT9));
    Light.Type = D3DLIGHT_DIRECTIONAL;
    Light.Diffuse = tbColor(0.5f, 0.5f, 0.5f);
    Light.Ambient = tbColor(0.5f, 0.5f, 0.5f);
    Light.Specular = tbColor(0.5f, 0.5f, 0.5f);
    Light.Direction = vCameraDir;
    D3D->SetLight(0, &Light);
    D3D->LightEnable(0, TRUE);

    // Linearer schwarzer Nebel!
    D3D.SetRS(D3DRS_FOGENABLE,      TRUE);
    D3D.SetRS(D3DRS_FOGVERTEXMODE,  D3DFOG_LINEAR);
    D3D.SetRS(D3DRS_RANGEFOGENABLE, TRUE);
    D3D.SetRS(D3DRS_FOGCOLOR,       0);
    D3D.SetRSF(D3DRS_FOGSTART,      100.0f);
    D3D.SetRSF(D3DRS_FOGEND,        350.0f);

    // Weltmatrix zurücksetzen
    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());

    // Das Modell rendern (zuerst alle opaken Effekte, dann alle transparenten)
    //g_pCityModel->Render(-1, -1, TRUE, FALSE);
    //g_pCityModel->Render(-1, -1, FALSE, TRUE);

    // ------------------------------------------------------------------

    // Büro und Möbel Berechnen und Zeichnen
    //Tisch
    mWorld = tbMatrixRotationZ(D3DX_PI*1.5) * tbMatrixRotationX(3*D3DX_PI/2) *
             tbMatrixTranslation(tbVector3(-0.5f, 0.8f, 3.5f));
    D3D.SetTransform(D3DTS_WORLD, mWorld);
    g_pShipModel->Render();
    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());

    //PC-Bildschirm
    mWorld = tbMatrixRotationZ(D3DX_PI*1.2) * tbMatrixRotationX(3*D3DX_PI/2) *
        tbMatrixScaling(tbVector3( 0.5f, 0.5f, 0.5f)) * tbMatrixTranslation(tbVector3(-0.6f, 0.81f, 3.7f));
    D3D.SetTransform(D3DTS_WORLD, mWorld);
    g_pBildschirm->Render();
    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());

    //Büro
    mWorld = tbMatrixRotationZ(D3DX_PI) * tbMatrixRotationX(3*D3DX_PI/2) *
        tbMatrixTranslation(tbVector3( 0.0f, 0.0f, 0.0f));
    D3D.SetTransform(D3DTS_WORLD, mWorld);
    g_pRaum->Render();
    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());

    //Weltkarte
    mWorld = tbMatrixRotationZ(3*D3DX_PI/2) * tbMatrixRotationX(D3DX_PI/2) * tbMatrixRotationY(0) *
        tbMatrixScaling(tbVector3( 1.0f, 1.0f, 2.0f)) * tbMatrixTranslation(tbVector3(-0.1f, 1.81f, 2.4f));
    D3D.SetTransform(D3DTS_WORLD, mWorld);
    g_pWeltkarte->Render();
    D3D.SetTransform(D3DTS_WORLD, tbMatrixIdentity());

    // ------------------------------------------------------------------

    // Kein Nebel mehr!
    D3D.SetRS(D3DRS_FOGENABLE, FALSE);
    //Frames und Zeit
    sprintf(acText, "Zeit: %.2f\nFPS: %.2f", g_fTime, 1.0f / fNumSecsPassed);
    g_pFont1->Begin();
    g_pFont1->DrawText(tbVector2((float)(g_Config.Direct3D.VideoMode.Width) - 100.0f, 50.0f),
                       acText,                      // Der Text
                       TB_FF_ALIGN_HLEFT,           // Links ausrichten
                       -1,                          // Textlänge automatisch ermitteln
                       tbColor(0.0f, 1.0f, 0.0f),   // Startfarbe (links), grün
                       tbColor(1.0f, 0.0f, 1.0f),   // Endfarbe (rechts), weiß
                       tbVector2(0.75f, 1.0f),      // Skalierung (75% auf x-Achse)
                       -2.0f,                       // Zeichen um 2 Pixel enger
                       2.0f,                        // Kursivität: 2 Pixel
                       0.0f,                        // Standardzeilenabstand
                       50.0f,                       // Tab-Stopps alle 50 Pixel
                       0.0f);                       // x-Abstand = 0
    g_pFont1->End();

    // ------------------------------------------------------------------

    D3D->SetFVF(SVertex::dwFVF);

    g_aTriangleVertex[0].fRHW = 1.0;
    g_aTriangleVertex[1].fRHW = 1.0;
    g_aTriangleVertex[2].fRHW = 1.0;
    g_aTriangleVertex[2].vPosition  = tbVector3( 0.0f, 0.0f, 0.0f);
    g_aTriangleVertex[1].vPosition  = tbVector3( 0.0f, 640.0f, 0.0f);
    g_aTriangleVertex[1].vPosition  = tbVector3( 480.0f, 640.0f, 0.0f);
    g_aTriangleVertex[0].dwColor    = tbColor(1.0f, 0.0f, 0.0f);
    g_aTriangleVertex[1].dwColor    = tbColor(0.0f, 1.0f, 0.0f);
    g_aTriangleVertex[2].dwColor    = tbColor(0.0f, 0.0f, 1.0f);

    D3D->DrawPrimitiveUP(D3DPT_TRIANGLELIST,    // Dreiecksliste
                                                      1,                    // 1 Dreieck
                                                      g_aTriangleVertex,    // Vertexdaten
                                                      sizeof(SVertex));

    // Szene beenden
    D3D->EndScene();

    return TB_OK;
}

// ******************************************************************
// Initialisierung der Sky-Box
tbResult InitSkyBox()
{
    SSkyBoxVertex aVertex[8];

    // Vertex- und Index-Buffer erstellen. 8 Vertizes, 36 Indizes.
    g_pSkyBoxVB = new tbVertexBuffer;
    if(g_pSkyBoxVB->Init(8 * sizeof(SSkyBoxVertex), sizeof(SSkyBoxVertex), SSkyBoxVertex::dwFVF,
                         D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DPOOL_DEFAULT))
    {
        // Fehler!
        return TB_ERROR;
    }

    // Nun der Index-Buffer (16 Bits pro Index)
    g_pSkyBoxIB = new tbIndexBuffer;
    if(g_pSkyBoxIB->Init(36 * sizeof(WORD), sizeof(WORD), D3DFMT_INDEX16))
    {
        // Fehler!
        return TB_ERROR;
    }

    // ------------------------------------------------------------------

    // Die Vertizes erstellen
    aVertex[0].vPosition = tbVector3(-1.0f,  1.0f,  1.0f);
    aVertex[1].vPosition = tbVector3( 1.0f,  1.0f,  1.0f);
    aVertex[2].vPosition = tbVector3( 1.0f,  1.0f, -1.0f);
    aVertex[3].vPosition = tbVector3(-1.0f,  1.0f, -1.0f);
    aVertex[4].vPosition = tbVector3(-1.0f, -1.0f,  1.0f);
    aVertex[5].vPosition = tbVector3( 1.0f, -1.0f,  1.0f);
    aVertex[6].vPosition = tbVector3( 1.0f, -1.0f, -1.0f);
    aVertex[7].vPosition = tbVector3(-1.0f, -1.0f, -1.0f);
    

    // Die Texturkoordinaten entsprechen den Vertexpositionen
    for(int iVertex = 0; iVertex < 8; iVertex++)
    {
        // Texturkoordinate eintragen und Sky-Box skalieren
        aVertex[iVertex].vTexture = aVertex[iVertex].vPosition;
        aVertex[iVertex].vPosition *= 10.0f;
    }

    // Alle Vertizes eintragen und den Vertex-Buffer aktualisieren
    g_pSkyBoxVB->AddVertices(8, aVertex);
    if(g_pSkyBoxVB->Update()) return TB_ERROR;

    // ------------------------------------------------------------------

    // Den Index-Buffer ausfüllen
    WORD awIndex[36] = {7, 3, 0,   4, 7, 0,     // Vorderseite
                        5, 1, 2,   6, 5, 2,     // Hinterseite
                        4, 0, 1,   5, 4, 1,     // Linke Seite
                        6, 2, 3,   7, 6, 3,     // Rechte Seite
                        2, 1, 0,   3, 2, 0,     // Oberseite
                        4, 5, 6,   7, 4, 6};    // Unterseite
    g_pSkyBoxIB->AddIndices(36, awIndex);
    if(g_pSkyBoxIB->Update()) return TB_ERROR;

    // ------------------------------------------------------------------

    // Die Textur der Sky-Box laden
    g_pSkyBoxTexture = tbTextureManager::Instance().GetCubeTexture("SkyBox.dds@Data\\SkyBox.zip");
    if(g_pSkyBoxTexture == NULL) return TB_ERROR;

    // Effekt laden
    g_pSkyBoxEffect = new tbEffect;
    if(g_pSkyBoxEffect == NULL) return TB_ERROR;
    if(g_pSkyBoxEffect->Init("SkyBox.fx@Data\\SkyBox.zip")) return TB_ERROR;

    return TB_OK;
}

// ******************************************************************
// Aufräumen
tbResult CleanUp()
{
    // Alles löschen
    TB_SAFE_DELETE(g_pSkyBoxVB);
    TB_SAFE_DELETE(g_pSkyBoxIB);
    TB_SAFE_DELETE(g_pSkyBoxEffect);
    TB_SAFE_DELETE(g_pCityModel);
    TB_SAFE_DELETE(g_pShipModel);
    TB_SAFE_DELETE(g_pRaum);
    TB_SAFE_DELETE(g_pBildschirm);
    TB_SAFE_DELETE(g_pWeltkarte);

    // Die TriBase-Engine herunterfahren
    tbExit();

    return TB_OK;
}

// ******************************************************************
// Windows-Hauptfunktion
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   char* pcCommandLine,
                   int iShowCommand)
{
    // TriBase-Engine initialisieren
    tbInit();

    // Konfiguration abfragen
    tbResult r;
    if(r = tbDoConfigDialog(&g_Config))
    {
        if(r == TB_CANCELED) return 0;
        else
        {
            // Fehler!
            MessageBox(NULL, "Fehler im Konfigurationsdialog!", "Fehler",
                       MB_OK | MB_ICONEXCLAMATION);
            return 1;
        }
    }

    // Direct3D initialisieren
    if(tbDirect3D::Instance().Init(&g_Config,
                                   "Beispielprogramm Nr. 2: Modelle",
                                   NULL,
                                   LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1))))
    {
        // Fehler!
        MessageBox(NULL, "Fehler bei der Direct3D-Initialisierung!", "Fehler",
                   MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }

    // Den Texturmanager initialisieren
    if(tbTextureManager::Instance().Init())
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Initialisieren des Texturmanagers!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }

    // Sky-Box initialisieren
    if(InitSkyBox()) TB_WARNING("Sky-Box konnte nicht erstellt werden!");

    /*// Das Stadtmodell laden
    g_pCityModel = new tbModel;
    if(g_pCityModel->Init("City.tbm@Data\\City.zip", "", "@Data\\City.zip"))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Laden der Stadtmodelldatei!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }*/

    // Das Raumschiffmodell laden
    g_pShipModel = new tbModel;
    if(g_pShipModel->Init("Tisch.tbm@3DMODEL\\3DMODEL.zip", "", "@3DMODEL\\3DMODEL.zip"))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Laden der Tisch.tbm!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }
    g_pBildschirm = new tbModel;
    if(g_pBildschirm->Init("Bildschirm.tbm@3DMODEL\\3DMODEL.zip", "", ""))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Laden der Bildschirm.tbm!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }
    g_pRaum = new tbModel;
    if(g_pRaum->Init("Raum.tbm@3DMODEL\\3DMODEL.zip", "", ""))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Laden der Raum.tbm!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }
    g_pWeltkarte = new tbModel;
    if(g_pWeltkarte->Init("Weltkarte.tbm@3DMODEL\\3DMODEL.zip", "", "@3DMODEL\\3DMODEL.zip"))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Laden der Weltkarte.tbm!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }
    g_pFont1 = new tbFont;
    if(g_pFont1->Init("3DMODEL\\Arial.tga", "3DMODEL\\Arial.tbf"))
    {
        // Fehler...
        return TB_ERROR;
    }

    // Kamera initialisieren
    g_vCameraPos = tbVector3(-1.5f, 1.0f, 0.5f);
    g_fCameraRot = 0.0f;
    g_fCameraUpDown = 0.0f;

    // Nachrichtenschleife betreten
    if(tbDoMessageLoop(MoveProc, RenderProc))
    {
        MessageBox(tbDirect3D::Instance().GetWindow(), "Fehler beim Zeichnen!",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        CleanUp();
        return 1;
    }

    // Aufräumen
    CleanUp();

    return 0;
}

// ******************************************************************

7

15.05.2010, 13:52

Versuch mal ohne das RHW du hast ja anscheinend ne Kamera

8

15.05.2010, 14:02

Wenn ich das mache landet das Dreieck am Punkt 0,0,0 und ist Durchgehend Schwarz egal wie rum ich es drehe und wende und ich müsste es immer so Berechnen das es dauerhaft vor der Camera sitzt soll nämlcih mal sone art Interface werden.

Also ich versuche ein Interface zu erstellen dazu soll ein Blauer Balken untem im Bild entstehen auf dem Tag Schrift angezeigt wird(informationen zum aktuellen Status ect).
Also dachte ich nehm Ich dazu nen 2D und lass dann über das Bild Zeichnen.

Würde mich allerdings nochmal interesieren wieso das Dreieck eigentlich immer schwarz ist wenn ichs ohne RHW mache und mit RHW isses einfach weg.

9

15.05.2010, 14:19

mach mal in der Vertexstruktur das D3DCOLOR zu DWORD so hab ich das in meinen programmen.
Da tbColor nur in nen DWORD gemacht werden kann.

Dass sollte das Farbproblem lösen.

10

15.05.2010, 14:46

D3DCOLOR ist vom DirectX und stellt quasi ein DWORD da is nurn anderer bezeichner, habs trotzdem mal geändert und bring keine änderung.

Werbeanzeige