點(diǎn)此下載源文件
/*
MainApp.hpp
*/
#ifndef MAINAPP_HPP
#define MAINAPP_HPP
#include <GL/gl.h>
#include <SDL/SDL.h>
#define ImageWidth 64
#define ImageHeight 64
class MainApp
{
public:
??? MainApp();
??? ~MainApp();
??? void loop();???
??? void quit();???
???
private:???
??? void initGL();
??? void initTexture();
??? void makeImage();
??? void destroyGL();
??? void onKeyDown(const SDL_Event &event);
??? void draw();
??? bool running;
??? GLubyte Image[ImageWidth][ImageHeight][3];
};
#endif
/*
MainApp.cpp
*/
#include <GL/gl.h>
#include <SDL/SDL.h>
#include "MainApp.hpp"
MainApp::MainApp():running(true)
{
?? ?initGL();
}
MainApp::~MainApp()
{
?? ?destroyGL();
}
void MainApp::initGL()
{
?? ?SDL_Init(SDL_INIT_VIDEO);
?? ?SDL_SetVideoMode(600,300,16,SDL_OPENGL);
?? ?glClearColor(0,0,0,0);
?? ?initTexture();
}
/* 創(chuàng)建紋理 */
void MainApp::makeImage(void)
{
??? int i, j, r,g,b;
??? for (i = 0; i < ImageWidth; i++)
?? ?{
?? ??? ?for (j = 0; j < ImageHeight; j++)
?? ??? ?{
?? ??????? r=(i*j)%255;
?? ??? ???? g=(4*i)%255;
?????? ??? ?b=(4*j)%255;
?? ???????? Image[i][j][0] = (GLubyte) r;
?????? ??? ?Image[i][j][1] = (GLubyte) g;
?? ??? ???? Image[i][j][2] = (GLubyte) b;
?? ??? ?}
??? }
}
void MainApp::initTexture()
{
?? ?makeImage();
?/*? 定義紋理 */
??? glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth,
??? ImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
??? &Image[0][0][0]);
? /*? 控制濾波 */
??? glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
?? glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
??? glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
??? glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
/*? 說明映射方式*/
?? glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
/*? 啟動紋理映射 */
??? glEnable(GL_TEXTURE_2D);
}
void MainApp::destroyGL()
{
?? ?SDL_Quit();
}
void MainApp::loop()
{
?? ?SDL_Event event;
?? ?while(running)
?? ?{
?? ??? ?while(SDL_PollEvent(&event))
?? ??? ?{
?? ??? ??? ?switch(event.type)
?? ??? ??? ?{
?? ??? ??? ?case SDL_KEYDOWN:
?? ??? ??? ??? ?onKeyDown(event);
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?SDL_Delay(50);
?? ??? ?draw();
?? ?}
}
void MainApp::quit()
{
?? ?running=false;
}
void MainApp::onKeyDown(const SDL_Event &event)
{
?? ?switch(event.key.keysym.sym)
?? ?{
?? ?case SDLK_ESCAPE:
?? ??? ?quit();
?? ?}
}
void MainApp::draw()
{
?? ?glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
?? ?glBegin(GL_QUADS);
?? ??? ?glColor3f(1,1,1);
?? ??? ?glTexCoord2f(0,0);glVertex3f(-0.5,-0.5,-0.5);
?? ??? ?glTexCoord2f(0,1);glVertex3f(-0.5,0.5,-0.5);
?? ??? ?glTexCoord2f(1,1);glVertex3f(0.5,0.5,0.5);
?? ??? ?glTexCoord2f(1,0);glVertex3f(0.5,-0.5,0.5);
?? ?glEnd();
?? ?
?? ?SDL_GL_SwapBuffers();
}
int main(int argc,char* argv[])
{
?? ?MainApp app;
?? ?app.loop();?? ?
}
posted @
2006-10-17 18:42 四海 閱讀(1405) |
評論 (0) |
編輯 收藏
http://www.shnenglu.com/Files/giant35/Baihe.Tools.PatchCreator.rar
點(diǎn)此下載v0.01源程序點(diǎn)此下載v0.02源程序開發(fā)動機(jī):
因web開發(fā)更新極為頻繁,
且每次都不是整站更新而是修改了什么更新什么
每次挑選出需要更新的文件且按目錄結(jié)構(gòu)組織好頗費(fèi)一翻事
未曾找到類似的工作
所以產(chǎn)生了開發(fā)此程序的動機(jī)
目標(biāo):
補(bǔ)丁打包機(jī)
實(shí)現(xiàn)人工干預(yù)+智能規(guī)則推導(dǎo)找出所有需要更新的文件
并能以多種形式發(fā)布(復(fù)制/FTP上傳/打包……)
使用說明:
先選擇要更新的文件再使用菜單“補(bǔ)丁”->"發(fā)布"? 發(fā)布
有沒有人使呢?
posted @
2006-10-17 16:46 四海 閱讀(265) |
評論 (0) |
編輯 收藏
點(diǎn)擊下載源文件
/*
坐標(biāo)觀察程序,
ESC:退出
F5:復(fù)位
LEFT/RIGHT:以綠色Y為軸心旋轉(zhuǎn)
UP/DOWN:以紅色X為軸心旋轉(zhuǎn)
PAGEUP/PAGEDOWN:以藍(lán)色z為軸心旋轉(zhuǎn)
*/
#include <GL/gl.h>
#include <SDL/SDL.h>
bool running=true;
float x=0.0,y=0.0,z=0.0;
enum Target{modelview,projection};
Target target=modelview;
void initGL()
{
?? ?SDL_Init(SDL_INIT_VIDEO);
?? ?SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
?? ?SDL_SetVideoMode(600,300,16,SDL_OPENGL);
?? ?
}
void destroyGL()
{
?? ?SDL_Quit();
}
void drawCoordinate()
{
?? ?glBegin(GL_LINES);
?? ??? ?glLineWidth(10.0f);
?? ??? ?glColor3f(1,0,0);
?? ??? ?glVertex3f(0,0,0);
?? ??? ?glVertex3f(1,0,0);
?? ??? ?glColor3f(0,1,0);
?? ??? ?glVertex3f(0,0,0);
?? ??? ?glVertex3f(0,1,0);
?? ??? ?glColor3f(0,0,1);
?? ??? ?glVertex3f(0,0,0);
?? ??? ?glVertex3f(0,0,1);
?? ?glEnd();
}
void draw()
{
?? ?glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
?? ?if(target==modelview)
?? ?{
?? ??? ?glMatrixMode(GL_MODELVIEW);
?? ?}
?? ?else
?? ?{
?? ??? ?glMatrixMode(GL_PROJECTION);
?? ?}
?? ?glLoadIdentity();
?? ?glRotatef(x,1,0,0);
?? ?glRotatef(y,0,1,0);
?? ?glRotatef(z,0,0,1);
?? ?glMatrixMode(GL_MODELVIEW);
?? ?drawCoordinate();
?? ?
?? ?SDL_GL_SwapBuffers();
}
void switchTarget()
{
?? ?if(((int)target+1)>((int)projection))
?? ?{
?? ??? ?target=modelview;
?? ?}else
?? ?{
?? ??? ?target=(Target)((int)target+1);
?? ?}
}
void reset()
{
?? ?x=0;
?? ?y=0;
?? ?z=0;
}
void quit()
{
?? ?running=false;
}
void onKeyDown(const SDL_Event& event)
{
?? ?switch(event.key.keysym.sym)
?? ?{
?? ?case SDLK_ESCAPE:
?? ?quit();
?? ?break;
?? ?case SDLK_TAB:
?? ?switchTarget();
?? ?break;
?? ?case SDLK_F5:
?? ?reset();
?? ?break;
?? ?case SDLK_LEFT:
?? ?y+=1;
?? ?break;
?? ?case SDLK_RIGHT:
?? ?y-=1;
?? ?break;
?? ?case SDLK_UP:
?? ?x+=1;
?? ?break;
?? ?case SDLK_DOWN:
?? ?x-=1;
?? ?break;
?? ?case SDLK_PAGEUP:
?? ?z+=1;
?? ?break;
?? ?case SDLK_PAGEDOWN:
?? ?z-=1;
?? ?break;
?? ?
?? ?}
}
void loop()
{
?? ?SDL_Event event;
?? ?while(running)
?? ?{
?? ??? ?while(SDL_PollEvent(&event))
?? ??? ?{
?? ??? ??? ?switch(event.type)
?? ??? ??? ?{
?? ??? ??? ?case SDL_QUIT:
?? ??? ??? ??? ?quit();
?? ??? ??? ?break;
?? ??? ??? ?case SDL_KEYDOWN:
?? ??? ??? ??? ?onKeyDown(event);
?? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?draw();
?? ??? ?SDL_Delay(50);
?? ?}
}
int main(int argc,char* argv[])
{
?? ?initGL();
?? ?loop();
?? ?destroyGL();?? ?
?? ?return 0;
}
posted @
2006-09-28 16:52 四海 閱讀(1172) |
評論 (0) |
編輯 收藏
上一篇中我們繪制了一個(gè)彩色的三角型
這次我們讓它動起來
#include <GL/gl.h>
#include <SDL/SDL.h>
bool running=true;
float y=0.0;
void initGL()
{
?? ?SDL_Init(SDL_INIT_VIDEO);
?? ?SDL_SetVideoMode(600,300,16,SDL_OPENGL);
?? ?
}
void destroyGL()
{
?? ?SDL_Quit();
}
void draw()
{
?? ?glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
?? ?glRotatef(y,0,1,0);
?? ?glBegin(GL_TRIANGLES);
?? ??? ?glColor3f(1,0,0);
?? ??? ?glVertex3f(0,0,0);
?? ??? ?glColor3f(0,1,0);
?? ??? ?glVertex3f(1,0,0);
?? ??? ?glColor3f(0,0,1);
?? ??? ?glVertex3f(0,1,0);
?? ?glEnd();
?? ?SDL_GL_SwapBuffers();
}
void quit()
{
?? ?running=false;
}
void onKeyDown(const SDL_Event& event)
{
?? ?switch(event.key.keysym.sym)
?? ?{
?? ?case SDLK_ESCAPE:
?? ?quit();
?? ?break;
?? ?case SDLK_LEFT:
?? ?y+=0.1;
?? ?break;
?? ?case SDLK_RIGHT:
?? ?y-=0.1;
?? ?break;
?? ?
?? ?}
}
void loop()
{
?? ?SDL_Event event;
?? ?while(running)
?? ?{
?? ??? ?while(SDL_PollEvent(&event))
?? ??? ?{
?? ??? ??? ?switch(event.type)
?? ??? ??? ?{
?? ??? ??? ?case SDL_QUIT:
?? ??? ??? ??? ?quit();
?? ??? ??? ?break;
?? ??? ??? ?case SDL_KEYDOWN:
?? ??? ??? ??? ?onKeyDown(event);
?? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?draw();
?? ??? ?SDL_Delay(50);
?? ?}
}
int main(int argc,char* argv[])
{
?? ?initGL();
?? ?loop();
?? ?destroyGL();?? ?
?? ?return 0;
}
#include <GL/gl.h>
#include <SDL/SDL.h>
bool running=true;
float y=0.0;
void initGL()
{
??? SDL_Init(SDL_INIT_VIDEO);
??? SDL_SetVideoMode(600,300,16,SDL_OPENGL);
???
}
void destroyGL()
{
??? SDL_Quit();
}
void draw()
{
??? glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
??? glRotatef(y,0,1,0);
??? glBegin(GL_TRIANGLES);
??? ??? glColor3f(1,0,0);
??? ??? glVertex3f(0,0,0);
??? ??? glColor3f(0,1,0);
??? ??? glVertex3f(1,0,0);
??? ??? glColor3f(0,0,1);
??? ??? glVertex3f(0,1,0);
??? glEnd();
??? SDL_GL_SwapBuffers();
}
void quit()
{
??? running=false;
}
void onKeyDown(const SDL_Event& event)
{
??? switch(event.key.keysym.sym)
??? {
??? case SDLK_ESCAPE:
??? quit();
??? break;
??? case SDLK_LEFT:
??? y+=0.1;
??? break;
??? case SDLK_RIGHT:
??? y-=0.1;
??? break;
???
??? }
}
void loop()
{
??? SDL_Event event;
??? while(running)
??? {
??? ??? while(SDL_PollEvent(&event))
??? ??? {
??? ??? ??? switch(event.type)
??? ??? ??? {
??? ??? ??? case SDL_QUIT:
??? ??? ??? ??? quit();
??? ??? ??? break;
??? ??? ??? case SDL_KEYDOWN:
??? ??? ??? ??? onKeyDown(event);
??? ??? ??? break;
??? ??? ??? }
??? ??? }
??? ??? draw();
??? ??? SDL_Delay(50);
??? }
}
int main(int argc,char* argv[])
{
??? initGL();
??? loop();
??? destroyGL();???
??? return 0;
}
posted @
2006-09-28 16:46 四海 閱讀(543) |
評論 (0) |
編輯 收藏