小编rev*_*nix的帖子

OpenGL中的纹理映射(使用SOIL)

我在使用SOIL加载纹理以便在此四边形上正确显示时遇到问题.如果不清楚,我只是写了一个小的2D精灵引擎,这就是渲染部分(毫无疑问需要一点优化).我在几个月内没有做过任何OpenGL,而且我还是很生气.

#include <OpenGL/OpenGL.h>
#include <GLUT/GLUT.h>
#include "SOIL.h"

#include <stdio.h>

GLuint linktex;

void drawSprite(GLint left, GLint right, GLint bottom, GLint top, GLuint texture){  
    //Draw clockwise
    glColor3f(1.0, 1.0, 1.0);
    glBindTexture(GL_TEXTURE_2D, texture);

    glBegin(GL_QUADS);
    glTexCoord2i(1,1); glVertex2i(right , top);
    glTexCoord2i(1,0); glVertex2i(right , bottom);
    glTexCoord2i(0,0); glVertex2i(left , bottom);
    glTexCoord2i(0,1); glVertex2i(left , top);
    glEnd();
}

void display(void){
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glLoadIdentity();
    glOrtho(0.0, 240.0, 0.0, 160.0, -1.0, 1.0);
    drawSprite(50, 82, 50, 82, linktex);
    glFlush();
}

void reshape(int w, int h){
    glViewport(0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity(); …
Run Code Online (Sandbox Code Playgroud)

c opengl

2
推荐指数
1
解决办法
7097
查看次数

'X级'没有成员'Y'

这个错误是莫名其妙地发生的.这是代码和输出:

timer.cpp:

#include "timer.h"
#include "SDL.h"
#include "SDL_timer.h"

void cTimer::recordCurrentTime()
{
    this->previous_t = this->current_t;
    this->current_t = SDL_GetTicks();
}
Run Code Online (Sandbox Code Playgroud)

timer.h:

#include "SDL.h"
#include "SDL_timer.h"

class cTimer
{
private:
    int previous_t;
    int current_t;
    float delta_time;
    float accumulated_time;
    int frame_counter;
public:
    void recordCurrentTime();
    float getDelta();
    void incrementAccumulator();
    void decrementAccumulator();
    bool isAccumulatorReady();
    void incrementFrameCounter();
    void resetFrameCounter();
    int getFPS();
};
Run Code Online (Sandbox Code Playgroud)

编译器错误:

make
g++ -Wall -I/usr/local/include/SDL -c timer.cpp
timer.cpp: In member function ‘void cTimer::recordCurrentTime()’:
timer.cpp:6: error: ‘class cTimer’ has no member named ‘previous_t’ …

c++

1
推荐指数
1
解决办法
6370
查看次数

标签 统计

c ×1

c++ ×1

opengl ×1