Тема: raycasting
Показать сообщение отдельно
Старый 29.12.2013, 20:07   #54
alko
Оператор ЭВМ
 
Регистрация: 21.12.2013
Сообщений: 20
Написано 10 полезных сообщений
(для 10 пользователей)
Ответ: raycasting

Дело не в рейкастинге... Дело в самом quickCG.
Попробовал написать элементарное Хыллоу Ворлд, где будет закрашиваться экран и выводится отмасштабированный в два раза спрайт. И таки шо ви думаете? Эта хрень рисуется тоже 4 кадра пер секонд. (на пентиуме, разумеется... На моём ноуте 150 кадров в секунду)

#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif

#include <SDL.h>

#include <cmath>
#include <string>
#include <vector>
#include <iostream>

#include "quickcg.h"
using namespace QuickCG;

#define screenWidth 800
#define screenHeight 600

struct Sprite
{
  float x;
  float y;
  int texture;
};

Sprite sprite[50];

int main(int argc, char *argv[])
{
     double time = 0;
  double oldTime = 0;
    std::vector<Uint32> texture[11];
    unsigned long tw, th;
    Uint32 buffer[screenWidth][screenHeight];
    loadImage(texture[0], tw, th, "rc/gg1.png");

    screen(800, 600, 1, "Metallix zone");

    while(!done())
    {
        int i=0;
  for(int xx=0;xx<800;xx++)
  for(int yy=0;yy<600;yy++)
  buffer[xx][yy]= 0x0f00f0;
        int x=rand()%500,y=rand()%100;
        for(int xx=0;xx<128;xx++){

        for(int yy=0;yy<64;yy++){
        Uint32 color = texture[0][i];
        i++;

        if(color!=0xffffffff)for(int i=0; i<2 ; i++)
        for(int k=0; k<2 ; k++)
        buffer[yy*2+i+x][xx*2+k+y]=color<<8;}
        }
        drawBuffer(buffer[0]);

              oldTime = time;
    time = getTicks();
    double frameTime = (time - oldTime) / 1000.0;
    print(1.0 / frameTime); 
        redraw();
    }
}
(Offline)
 
Ответить с цитированием