Skip to content

Commit

Permalink
fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed Apr 4, 2012
1 parent 5b70615 commit 7580d44
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 89 deletions.
2 changes: 1 addition & 1 deletion c3dsobject.cpp
Expand Up @@ -114,7 +114,7 @@ void C3dsScene::parseFile(string filename)
break;

default:
printf("Unkown chunk %04x of length %u\n", parser.getChunkId(), parser.getChunkLength());
LOG("Unkown chunk " << parser.getChunkId() << " of length " << parser.getChunkLength());
parser.skipChunk();
break;

Expand Down
2 changes: 1 addition & 1 deletion cube.cpp
Expand Up @@ -8,7 +8,7 @@ Cube::Cube() : VboObject() {
genBO();
m_material = new RawTexture("legendary.raw");
//mat = new CRenderToTextureMaterial;
Log("Cube VBO generated\n");
LOG("Cube VBO generated");
}
}

Expand Down
2 changes: 0 additions & 2 deletions engine.cpp
Expand Up @@ -10,7 +10,6 @@
void Engine::init()
{
m_cube = 0;
initLog("debug.log");
m_engine = this;
}

Expand Down Expand Up @@ -46,7 +45,6 @@ void Engine::toggleFrame() {
void Engine::destroy() {
delete m_render;
delete m_object;
closeLog();
}

double Engine::getTime() {
Expand Down
9 changes: 5 additions & 4 deletions glrender.cpp
Expand Up @@ -78,10 +78,11 @@ void GLRender::drawFrame()
void GLRender::toggleFrame() {
glPolygonMode(GL_FRONT, m_fill ? GL_LINE : GL_FILL);
m_fill ^= 1;
if (m_fill)
Log("Wireframe off.\n");
else
Log("Wireframe on.\n");
if (m_fill) {
LOG("Wireframe off.");
} else {
LOG("Wireframe on.");
}
}

void GLRender::loadShaders()
Expand Down
4 changes: 2 additions & 2 deletions legendary.pro
Expand Up @@ -13,7 +13,6 @@ SOURCES += \
engine.cpp \
file.cpp \
glrender.cpp \
msg.cpp \
rtt.cpp \
c3dsparser.cpp \
rawtexture.cpp \
Expand Down Expand Up @@ -59,5 +58,6 @@ unix {
LIBS += -lX11 \
-lGLEW \
-lvorbisfile \
-lasound
-lasound \
-lGL
}
6 changes: 3 additions & 3 deletions linux.cpp
Expand Up @@ -29,7 +29,7 @@ int LinuxEngine::msgBox(std::string msg) {
//printf("ATTENTION: %s\n", msg);
system(std::string("zenity --info --text='" + msg + "'").c_str());
//Forward to Log
Log(msg.c_str());
LOG(msg.c_str());
return 0;
}

Expand All @@ -47,7 +47,7 @@ int main() {

display = XOpenDisplay(NULL);
if (!display) {
Log("Couldn't open display, terminating.\n");
LOG("Couldn't open display, terminating.");
delete Engine;
return 1;
}
Expand All @@ -72,7 +72,7 @@ int main() {
glXMakeCurrent(display, win, context);

if (glewInit()) {
Log("FATAL! glewInit failed!\n");
LOG("FATAL! glewInit failed!");
return 0;
}

Expand Down
53 changes: 0 additions & 53 deletions msg.cpp

This file was deleted.

17 changes: 3 additions & 14 deletions msg.h
@@ -1,18 +1,7 @@
#ifndef __msg_h_
#define __msg_h_

#define LOG(text) std::cout << __PRETTY_FUNCTION__ << " (" << __FILE__ << ":" << __LINE__ << "): " << text << std::endl;

#ifndef MSG_H
#define MSG_H
#include <iostream>

bool initLog(const char *filename);
bool closeLog();
void Log(const char *format, ...);

extern FILE *logfile;
extern char *logfilename;


#define printf BRUK_LOG_DIN_KUKFAEN
#define LOG(text) std::cout << __PRETTY_FUNCTION__ << " (" << __FILE__ << ":" << __LINE__ << "): " << text << std::endl;

#endif
4 changes: 2 additions & 2 deletions rtt.cpp
Expand Up @@ -16,7 +16,7 @@ void RenderToTextureMaterial::genTO() {
GLuint FBO;
GLuint RBO;

Log("Generating texture\n");
LOG("Generating texture");

glGenTextures(1, &TO);
glBindTexture(GL_TEXTURE_2D, TO);
Expand All @@ -37,7 +37,7 @@ void RenderToTextureMaterial::genTO() {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, TO, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, RBO);
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
Log("Framebuffer panic!\n");
LOG("Framebuffer panic!\n");

glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, 512, 512);
Expand Down
28 changes: 21 additions & 7 deletions vboobject.cpp
Expand Up @@ -76,26 +76,40 @@ void VboObject::draw() {
static float i=0;
i+=0.20;

GLfloat transform[16] = {

// Set an identity matrix
const GLfloat transform[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
loc.x, loc.y, loc.z, 1
};
glLoadMatrixf(transform);

// Bind our buffers
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO);

// Enable shit
glEnableClientState(GL_VERTEX_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

// Rotate to base
glRotatef(i, 1, 1, 1);

// Point to our vertices
glVertexPointer(3, GL_FLOAT, 0, 0);
//glColorPointer(3, GL_UNSIGNED_BYTE, 0, (GLvoid *)VBO_size_vertices);
//glTexCoordPointer(2, GL_FLOAT, 0, (GLvoid *)(VBO_size_vertices+VBO_size_colours));

glColorPointer(3, GL_UNSIGNED_BYTE, 0, (GLvoid *)VBO_size_vertices);
glTexCoordPointer(2, GL_FLOAT, 0, (GLvoid *)(VBO_size_vertices+VBO_size_colours));
glDrawElements(GL_TRIANGLES, VBO_indices, INDEX_SIZE, 0);

// Return to previous state
glDisableClientState(GL_VERTEX_ARRAY);
//glDisableClientState(GL_COLOR_ARRAY);
//glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
Expand Down

0 comments on commit 7580d44

Please sign in to comment.