Filed under Notes on January 9 | 0 comments
I just had to finish a huge project in a relatively short time. It was a PHP driven admin system that had to display various information to users and allow all content to be editable. There was a blog-like section and afew sections that needed to scan a directory. Users could only be added by administrators and you had to login to see any of it. Quite a pain considering that I was told to give an estimate at a time where only a small portion of the work was told to me. Luckily I lied and said it take longer.
So, the question is, what can I conjure up to make my life easier in the future. First, a solid login system is needed. Also, a way to organise sections of the site, including subsections. Each section should provide title text, breadcrumb text, menu text, content, edit content forms, templates and so on. Finally, a site object has to tie everything together.
This needs to be very freeform. First, the login system. EVolt has a good rundown that I think I’ll gut and modify to my liking. In its current form, it has too much involvement with the form object. Next, I need to create a Section class. It needs the following:
- Variables
- title_text
- menu_text
- breadcrumb_text
- id
- template
- subsections
- content
- is_current
- database
- Methods
- Section()
- get_content()
- add_subsection(section)
- set_current()
- draw()
The main Site class should be similar to Section, but act more as a wrapper and tell which section is current. That might be able to work.
Filed under Notes on December 9 | 0 comments
Using the new javacript canvas element, someone put together a simple ray caster.
Filed under Notes on December 8 | 0 comments
OpenGL Extensions allow us to use graphics hardware without delving into many specifics. The first one we will look at is fairly easy to use and understand, and it is a requirement for other extensions that do much more interesting manipulations. GL_ARB_depth_texture allows us to create a texture from the depth component of the scene. This will allow us to do shadow maps later on.
Set Up
In this example I will be using OglExt, but there are many different extension managers out there and all are easy to use. I like OglExt because it doesn’t require an initialization step like the OpenGL Extension Wrangler requires. I will also be using GLWindow as it is an easy to use OpenGL framework. This example works just as well in GLUT or any other window manager you can find. Here is the main file that we will be working with. Each step is outlined.
#include “GLWindow.h”
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
#include <GL/OglExt.h>
#define SIZE 512
class DepthTexture : public GLWindow
{
public:
GLuint texture;
bool init()
{
// Check that extension is supported
// Create texture
// Make texture active
// Fiddle with texture parameters
// Initialize texture memory using DEPTH_TEXTURE for internal format and format
return true;
}
void draw()
{
// clear the depth and color buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// Set viewpoint
// Draw scene that we will take the depth of
// Copy the current depth buffer to the texture
// clear the depth and color buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// Set viewpoint
// Draw a quad with the texture attached
}
};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
DepthTexture* window = new DepthTexture();
// Set Window size
window->starting_width = SIZE;
window->starting_height = SIZE;
window->mainLoop(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
Read more about GL_ARB_depth_texture
Filed under Notes on December 8 | 0 comments
Download it from the NVSG SDK page at NVidia’s website.
Filed under OpenGL on December 5 | 0 comments
Download GLWindow
Before we do any hardcore OpenGL programming, we need a framework for creating a window. Sure, you could use SDL or GLUT, but I want to play around with Win32. For that, we shall go to the old standard and copy NeHe’s code. Lesson 45 has a very nice example, but that’s C code. Let’s modify that to make it C++ worthy and create a GLWindow class. So, if you download NeHe’s Win32 code, you’ll see a lot of similarities to GLWindow, but I also made my own modifications
The GLWindow class is meant to be an easy to use framework for setting up an OpenGL project in no time. It allows access to most aspects of the code, making it easily expanded. The main workflow consists of subclassing GLWindow and overriding some of it’s virtual methods. Defaults are provided, so there is no need to override all of the methods. Once a subclass is defined, you instantiate it and call mainloop() to run the program. Piece of cake. Here’s the class structure.
class GLWindow
{
public:
GLWindow();
~GLWindow(void);
void redirectIOToConsole();
void terminateApplication();
void toggleFullscreen();
bool changeScreenResolution(int width, int height, int bitsPerPixel);
bool createWindow();
bool destroyWindow();
LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
bool registerWindowClass();
void mainLoop(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
virtual bool init();
virtual void deinit();
virtual void update(DWORD elapsedTime);
virtual void draw();
virtual void reshape(int width, int height);
virtual bool handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
virtual void onLMouseDown();
virtual void onLMouseUp();
virtual void onMMouseDown();
virtual void onMMouseUp();
virtual void onRMouseDown();
virtual void onRMouseUp();
virtual void onMouseMove(int x, int y, WPARAM keys);
virtual void onMouseWheel(WPARAM keys, int wheelDelta, int x, int y);
char title[256];
int starting_width, current_width;
int starting_height, current_height;
int bitsPerPixel;
bool isFullScreen;
protected:
HINSTANCE hInstance;
HWND hWnd;
HDC hDC;
HGLRC hRC;
char className[64];
bool isProgramLooping;
bool createFullscreen;
bool isMessagePumpActive;
bool isVisible;
DWORD lastTickCount;
bool keys[256];
private:
void sethWnd(HWND hWND) ;
static LRESULT CALLBACK staticWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};
See the rest of GLWindow
Filed under OpenGL on December 3 | 0 comments
A short list of OpenGL extension libraries
Filed under Project on November 28 | 0 comments
Updated an old project to work alittle better with link handling.
Presenting: CSS Magic
Filed under Project on November 16 | 0 comments
So, right now I’m working on creating a fairly realistic staircase that can be viewed in realtime in a head mounted display. Yup. There it is.
Filed under Uncategorized on November 8 | 0 comments
Express editions free for one year
I downloaded Visual Studio C++ 2005 Express and loaded up one of my working projects and it complained about not finding windows.h and winsock2.h. Looks like I won’t be using these.
Filed under Engine on November 8 | 0 comments
NVSG was built with a very comprehensive memory manager, and thread safety manager. But using these make things over complicated for the programmer using this package. Adding / removing references, creation and cloning through static class members. There must be simpler way to do this. I should look into implicit reference management and tagging.