Commits

Lars Viklund  committed ac518de

Linux build, buffer typo fix

  • Participants
  • Parent commits d48efc3

Comments (0)

Files changed (7)

 Release/
 
 *.dll
+*.so.*
+*.so
+*.o
+
+slade
+.tup
+include_rules
+: src/*.o |> g++ -o %o %f $(LDFLAGS) |> slade

File Tuprules.tup

+CXXFLAGS += -Wall -std=c++0x
+SFML_ROOT = /home/zao/opt/SFML-2.1
+CPPFLAGS += `PKG_CONFIG_PATH=$(SFML_ROOT)/lib/pkgconfig pkg-config sfml-all --cflags` -I. `pkg-config assimp --cflags`
+LDFLAGS += `PKG_CONFIG_PATH=$(SFML_ROOT)/lib/pkgconfig pkg-config sfml-all --libs` -lGL -lGLU -lGLEW `pkg-config assimp --libs`
 #include <sstream>
 #include <vector>
 
-#include <Windows.h>
-
 struct GameState {
   GameState() : Points(0) {}
   sf::Vector2f SledPosition;
-  Level Level;
+  ::Level Level;
   int Points;
 };
 
   sf::Transform BoardTransform;
   BoardTransform.scale(VideoMode.width / DESIGN_WIDTH,
     VideoMode.height / DESIGN_HEIGHT);
-  sf::Vector2f StarSkirt = BoardTransform.transformPoint(0.1f, 0.1f);
 
   sf::Font UIFont;
   UIFont.loadFromFile("art/impact.ttf");
   sf::Clock Clock;
   Clock.restart();
   auto SimTime = Clock.getElapsedTime();
-  auto VisTime = SimTime;
+  //auto VisTime = SimTime;
 
   BidirectionalInput MoveKeyHorizontal;
   BidirectionalInput MoveKeyVertical;
         case sf::Keyboard::Right:
           MoveKeyHorizontal.popPositive();
           break;
+        default: break;
         }
       default: break;
       }
       for (auto& Gift : State.Level.GiftReps) {
         Gift.Position.x += Dt.asSeconds() * WORLD_VELOCITY;
         Gift.Angle += Dt.asSeconds() * Gift.AngularVelocity;
-        Gift.Scale = Gift.ScaleBase + Gift.ScaleScale * sin(Now.asSeconds() * Gift.ScaleFreq + Gift.ScalePhase);
+        Gift.Scale = Gift.ScaleBase + Gift.ScaleScale * sin(SimTime.asSeconds() * Gift.ScaleFreq + Gift.ScalePhase);
       }
       auto& Gifts = State.Level.GiftReps;
       while (!Gifts.empty() && Gifts.front().Position.x < -0.1f*DESIGN_WIDTH) {
       TempPositions.reserve(9);
       Window.clear(sf::Color::Black);
       Window.pushGLStates();
+//      sf::Texture::bind(&*BackgroundStarfield.Textures.front());
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       gluPerspective(45, 16.0f / 9.0f, 0.1f, 100.0f);
       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
       glTranslatef(0.0f, 0.0f, -10.0f);
+      glScalef(0.1f, 0.1f, 0.1f);
       GiftMeshInstance.draw();
       SledMeshInstance.draw();
       glRotatef(Now.asSeconds() * 60.0f, 0.0f, 0.0f, 1.0f);
-      sf::Texture::bind(&*BackgroundStarfield.Textures.front());
       sf::Vector3f Points[] = { { -0.5f, -0.5f, 0.0f }, { 0.5f, -0.5f, 0.0f }, { 0.5f, 0.5f, 0.0f }, { -0.5f, 0.5f, 0.0f } };
       sf::Vector2f Texcoords[] = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
       glBegin(GL_TRIANGLES);
 
 #include <array>
 #include <cstdint>
+#include <cstring>
 #include <vector>
 
 Mesh
       enum { NUM_ATTRIBUTES = 3 };
       auto N = SourceMesh->mNumVertices;
 
+#if 0
       N = 4;
       std::array<float, 3> Points[] = { { -0.5f, -0.5f, 0.0f }, { 0.5f, -0.5f, 0.0f }, { 0.5f, 0.5f, 0.0f }, { -0.5f, 0.5f, 0.0f } };
       std::array<float, 2> Texcoords[] = { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f } };
 
       std::array<float, 3> Normal = { 0.0f, 0.0f, -1.0f }, Normals[] = { Normal, Normal, Normal, Normal };
+#endif
 
       Ret.PositionAttribute.ByteOffset = 0;
       Ret.PositionAttribute.Stride = sizeof(aiVector3D);
 
       VertexData.resize(byteEndOffset(Ret.TexcoordAttribute, N));
       char* P = VertexData.data();
+#if 0
       std::memcpy(P + byteBeginOffset(Ret.PositionAttribute), Points,    byteSize(Ret.PositionAttribute, N));
       std::memcpy(P + byteBeginOffset(Ret.NormalAttribute),   Normals,   byteSize(Ret.NormalAttribute, N));
       std::memcpy(P + byteBeginOffset(Ret.TexcoordAttribute), Texcoords, byteSize(Ret.TexcoordAttribute, N));
-      /*
+#else
       std::memcpy(P + byteBeginOffset(Ret.PositionAttribute), SourceMesh->mVertices,         byteSize(Ret.PositionAttribute, N));
       std::memcpy(P + byteBeginOffset(Ret.NormalAttribute),   SourceMesh->mNormals,          byteSize(Ret.NormalAttribute,   N));
       std::memcpy(P + byteBeginOffset(Ret.TexcoordAttribute), SourceMesh->mTextureCoords[0], byteSize(Ret.TexcoordAttribute, N));
-      */
+#endif
     }
 
     glGenBuffers(1, into(VB));
-    glBindBuffer(GL_BUFFER, from(VB));
-    glBufferData(GL_BUFFER, VertexData.size(), VertexData.data(), GL_STATIC_DRAW);
-    glBindBuffer(GL_BUFFER, 0);
+    glBindBuffer(GL_ARRAY_BUFFER, from(VB));
+    glBufferData(GL_ARRAY_BUFFER, VertexData.size(), VertexData.data(), GL_STATIC_DRAW);
+    glBindBuffer(GL_ARRAY_BUFFER, 0);
     Ret.VBId = VB;
 
     auto IB = std::make_shared<GLBuffer<OwnedId>>();
 MeshInstance::draw() const {
   if (!CurrentMesh) return;
 
+  glEnable(GL_TEXTURE_2D);
+
   GLuint VAOId;
   glGenVertexArrays(1, into(VAOId));
   glBindVertexArray(from(VAOId));
   glEnableClientState(GL_NORMAL_ARRAY);
   glEnableClientState(GL_VERTEX_ARRAY);
   glTexCoordPointer(2, GL_FLOAT, CurrentMesh->TexcoordAttribute.Stride,
-    (void*)CurrentMesh->TexcoordAttribute.ByteOffset);
+    (void*)(uintptr_t)CurrentMesh->TexcoordAttribute.ByteOffset);
   glNormalPointer(GL_FLOAT, CurrentMesh->NormalAttribute.Stride,
-    (void*)CurrentMesh->NormalAttribute.ByteOffset);
+    (void*)(uintptr_t)CurrentMesh->NormalAttribute.ByteOffset);
   glVertexPointer(3, GL_FLOAT, CurrentMesh->PositionAttribute.Stride,
-    (void*)CurrentMesh->PositionAttribute.ByteOffset);
+    (void*)(uintptr_t)CurrentMesh->PositionAttribute.ByteOffset);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, from(CurrentMesh->IBId));
   glDrawElements(GL_TRIANGLES, CurrentMesh->NumIndices, GL_UNSIGNED_INT, nullptr);
   glDeleteVertexArrays(1, &VAOId);
 
   (WasBlending ? glEnable : glDisable)(GL_BLEND);
-}
+}
+
+// vim: set ts=2 sw=2 et:

File src/Starfield.cc

 
   for (auto& Source : Sources) {
     auto Tex = std::make_shared<sf::Texture>();
-    Tex->loadFromFile("art/star1.png");
+    Tex->loadFromFile(Source);
     Tex->setSmooth(true);
     Textures.push_back(Tex);
   }
       }
     }
   }
-}
+}
+include_rules
+: foreach *.cc *.cpp |> g++ $(CXXFLAGS) $(CPPFLAGS) -c %f -o %o |> %B.o