Erwan
- Fixed MP3 play bug on the psp. MP3 files need to have NO Id3v2 tag, or they won't play. Also, volume control is broken - added dt to moving W's easter egg movement. - Added fullscreen for windows version - other stuff ?
This commit is contained in:
+43
-98
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JAudio.h"
|
||||
#include "../include/JCooleyesMP3.h"
|
||||
#include "../include/JMP3.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/decoder_prx.h"
|
||||
|
||||
@@ -29,7 +29,7 @@ short g_DecodedDataOutputBuffer[SAMPLE_PER_FRAME<<2] __attribute__((aligned(64))
|
||||
bool g_MP3DecoderOK = false;
|
||||
bool g_GotEDRAM;
|
||||
|
||||
JCooleyesMP3* g_CurrentMP3;
|
||||
JMP3* g_CurrentMP3;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@@ -38,7 +38,7 @@ WAVDATA currentWav[NUMBER_WAV_CHANNELS]; //
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内存
|
||||
char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载, memLoad-是否加载至内磥E
|
||||
{
|
||||
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
@@ -172,7 +172,7 @@ void releaseWaveData(WAVDATA* p_wav) // WAVE
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void audioOutCallback(int channel, void* buf, unsigned int length) // 各通道回调
|
||||
void audioOutCallback(int channel, void* buf, unsigned int length) // 各通道回祦E
|
||||
{
|
||||
WAVDATA* p_wav = NULL;
|
||||
memset(buf, 0, 4096);
|
||||
@@ -387,122 +387,67 @@ void audioInit() //
|
||||
memset(¤tWav[i], 0, sizeof(WAVDATA));
|
||||
p_currentWav[i] = NULL;
|
||||
}
|
||||
pspAudioInit();
|
||||
pspAudioSetChannelCallback(0, audioOutCallback_0, NULL);
|
||||
pspAudioSetChannelCallback(1, audioOutCallback_1, NULL);
|
||||
pspAudioSetChannelCallback(2, audioOutCallback_2, NULL);
|
||||
//pspAudioSetChannelCallback(3, audioOutCallback_3, NULL);
|
||||
|
||||
pspAudioSetChannelCallback(3, MP3AudioOutCallback, NULL);
|
||||
InitMP3Decoder();
|
||||
JMP3::init();
|
||||
}
|
||||
|
||||
void audioDestroy()
|
||||
{
|
||||
ReleaseMP3Decoder();
|
||||
pspAudioEnd();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MP3AudioOutCallback(void* buf, unsigned int length, void *userdata)
|
||||
{
|
||||
|
||||
// PSP_NUM_AUDIO_SAMPLES is 1024, 16bit samples (short), 2 channels for stereo sound
|
||||
memset(buf, 0, PSP_NUM_AUDIO_SAMPLES<<2);
|
||||
|
||||
if (g_CurrentMP3 != NULL)
|
||||
g_CurrentMP3->FeedAudioData(buf, length);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int mp3thread = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void PlayMP3(JCooleyesMP3 *mp3, bool looping)
|
||||
void PlayMP3(JMP3 *mp3, bool looping)
|
||||
{
|
||||
if (g_MP3DecoderOK)
|
||||
{
|
||||
g_CurrentMP3 = mp3;
|
||||
mp3->InitBuffers(g_MP3CodecBuffer, g_DecoderBuffer, g_DecodedDataOutputBuffer);
|
||||
mp3->Play(looping);
|
||||
}
|
||||
if (mp3thread) StopMP3();
|
||||
JMP3::mInstance = mp3;
|
||||
mp3->setLoop(looping);
|
||||
mp3->play();
|
||||
mp3thread = sceKernelCreateThread("decodeThread2", decodeThread2, 0x12, 0xFA0, 0, 0);
|
||||
printf("thread id : %i\n", mp3thread);
|
||||
sceKernelStartThread(mp3thread, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void StopMP3()
|
||||
{
|
||||
if (g_CurrentMP3 != NULL)
|
||||
{
|
||||
g_CurrentMP3->Stop();
|
||||
}
|
||||
printf("stop 1\n");
|
||||
JMP3 * mp3 = JMP3::mInstance;
|
||||
printf("stop 2\n");
|
||||
if (mp3){
|
||||
printf("stop 3\n");
|
||||
mp3->pause();
|
||||
printf("stop 4\n");
|
||||
sceKernelWaitThreadEnd(mp3thread, NULL);
|
||||
printf("stop 5\n");
|
||||
sceKernelDeleteThread(mp3thread);
|
||||
printf("stop 6\n");
|
||||
mp3->unload();
|
||||
printf("stop 7\n");
|
||||
JMP3::mInstance = NULL;
|
||||
mp3thread = 0;
|
||||
}
|
||||
printf("stop 8\n");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ResumeMP3()
|
||||
void ResumeMP3(JMP3 * mp3)
|
||||
{
|
||||
if (g_CurrentMP3 != NULL)
|
||||
{
|
||||
g_CurrentMP3->Resume();
|
||||
}
|
||||
mp3->play();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool InitMP3Decoder()
|
||||
{
|
||||
int result;
|
||||
|
||||
// if (sceKernelDevkitVersion() == 0x01050001)
|
||||
// {
|
||||
// LoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// LoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC);
|
||||
// }
|
||||
|
||||
// result = pspSdkLoadStartModule("flash0:/kd/me_for_vsh.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// result = pspSdkLoadStartModule("flash0:/kd/videocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// result = pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// result = pspSdkLoadStartModule("flash0:/kd/mpegbase.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
// result = pspSdkLoadStartModule("flash0:/kd/mpeg_vsh.prx", PSP_MEMORY_PARTITION_USER);
|
||||
//
|
||||
// pspSdkFixupImports(result);
|
||||
|
||||
prx_static_init();
|
||||
|
||||
sceMpegInit();
|
||||
|
||||
memset(g_MP3CodecBuffer, 0, sizeof(g_MP3CodecBuffer));
|
||||
|
||||
if ( sceAudiocodecCheckNeedMem(g_MP3CodecBuffer, 0x1002) < 0 )
|
||||
return false;
|
||||
|
||||
if ( sceAudiocodecGetEDRAM(g_MP3CodecBuffer, 0x1002) < 0 )
|
||||
return false;
|
||||
|
||||
g_GotEDRAM = true;
|
||||
|
||||
if ( sceAudiocodecInit(g_MP3CodecBuffer, 0x1002) < 0 )
|
||||
return false;
|
||||
|
||||
g_MP3DecoderOK = true;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void ReleaseMP3Decoder()
|
||||
{
|
||||
if ( g_GotEDRAM )
|
||||
sceAudiocodecReleaseEDRAM(g_MP3CodecBuffer);
|
||||
|
||||
}
|
||||
|
||||
int decodeThread2(SceSize args, void *argp){
|
||||
JMP3 * mp3 = NULL;
|
||||
while((mp3 = JMP3::mInstance) && !mp3->m_paused){
|
||||
mp3->update();
|
||||
|
||||
//sceKernelDelayThread(10000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include <stdio.h>
|
||||
#include <pspaudio.h>
|
||||
#include <pspmp3.h>
|
||||
#include <psputility.h>
|
||||
|
||||
#include "../include/JAudio.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JMP3.h"
|
||||
|
||||
|
||||
JMP3* JMP3::mInstance = NULL;
|
||||
|
||||
|
||||
|
||||
void JMP3::init() {
|
||||
loadModules();
|
||||
}
|
||||
|
||||
JMP3::JMP3(const std::string& filename, int inBufferSize, int outBufferSize) :
|
||||
m_volume(PSP_AUDIO_VOLUME_MAX), m_paused(true), m_samplesPlayed(0) {
|
||||
load(filename, inBufferSize,outBufferSize);
|
||||
}
|
||||
|
||||
JMP3::~JMP3() {
|
||||
unload();
|
||||
}
|
||||
|
||||
bool JMP3::loadModules() {
|
||||
int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC);
|
||||
if (loadAvCodec < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int loadMp3 = sceUtilityLoadModule(PSP_MODULE_AV_MP3);
|
||||
if (loadMp3 < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JMP3::fillBuffers() {
|
||||
SceUChar8* dest;
|
||||
SceInt32 length;
|
||||
SceInt32 pos;
|
||||
|
||||
int ret = sceMp3GetInfoToAddStreamData(m_mp3Handle, &dest, &length, &pos);
|
||||
if (ret < 0)
|
||||
return false;
|
||||
|
||||
if (sceIoLseek32(m_fileHandle, pos, SEEK_SET) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int readLength = sceIoRead(m_fileHandle, dest, length);
|
||||
if (readLength < 0)
|
||||
return false;
|
||||
|
||||
ret = sceMp3NotifyAddStreamData(m_mp3Handle, readLength);
|
||||
if (ret < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JMP3::load(const std::string& filename, int inBufferSize, int outBufferSize) {
|
||||
printf("load\n");
|
||||
m_inBufferSize = inBufferSize;
|
||||
printf("1\n");
|
||||
//m_inBuffer = new char[m_inBufferSize];
|
||||
//if (!m_inBuffer)
|
||||
// return false;
|
||||
|
||||
m_outBufferSize = outBufferSize;
|
||||
printf("2\n");
|
||||
//m_outBuffer = new short[outBufferSize];
|
||||
//if (!m_outBuffer)
|
||||
// return false;
|
||||
|
||||
printf("3:%s\n",filename.c_str());
|
||||
m_fileHandle = sceIoOpen(filename.c_str(), PSP_O_RDONLY, 0777);
|
||||
if (m_fileHandle < 0)
|
||||
return false;
|
||||
|
||||
printf("4\n");
|
||||
int ret = sceMp3InitResource();
|
||||
if (ret < 0)
|
||||
return false;
|
||||
|
||||
SceMp3InitArg initArgs;
|
||||
|
||||
int fileSize = sceIoLseek32(m_fileHandle, 0, SEEK_END);
|
||||
sceIoLseek32(m_fileHandle, 0, SEEK_SET);
|
||||
|
||||
unsigned char* testbuffer = new unsigned char[7456];
|
||||
sceIoRead(m_fileHandle, testbuffer, 7456);
|
||||
|
||||
delete testbuffer;
|
||||
|
||||
initArgs.unk1 = 0;
|
||||
initArgs.unk2 = 0;
|
||||
initArgs.mp3StreamStart = 0;
|
||||
initArgs.mp3StreamEnd = fileSize;
|
||||
initArgs.mp3BufSize = m_inBufferSize;
|
||||
initArgs.mp3Buf = (SceVoid*) m_inBuffer;
|
||||
initArgs.pcmBufSize = m_outBufferSize;
|
||||
initArgs.pcmBuf = (SceVoid*) m_outBuffer;
|
||||
|
||||
printf("5\n");
|
||||
m_mp3Handle = sceMp3ReserveMp3Handle(&initArgs);
|
||||
if (m_mp3Handle < 0)
|
||||
return false;
|
||||
|
||||
// Alright we are all set up, let's fill the first buffer.
|
||||
printf("5.5\n");
|
||||
bool _filled= fillBuffers();
|
||||
if (! _filled) return false;
|
||||
|
||||
printf("end = %i, bufsize = %i, outSize = %i\n", fileSize, m_inBufferSize, m_outBufferSize);
|
||||
|
||||
// Start this bitch up!
|
||||
printf("6\n");
|
||||
int start = sceMp3Init(m_mp3Handle);
|
||||
if (start < 0)
|
||||
return false;
|
||||
|
||||
printf("7\n");
|
||||
m_numChannels = sceMp3GetMp3ChannelNum(m_mp3Handle);
|
||||
printf("8\n");
|
||||
m_samplingRate = sceMp3GetSamplingRate(m_mp3Handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JMP3::unload() {
|
||||
printf("unload 1\n");
|
||||
if (m_channel >= 0)
|
||||
sceAudioSRCChRelease();
|
||||
|
||||
printf("unload 2\n");
|
||||
sceMp3ReleaseMp3Handle(m_mp3Handle);
|
||||
|
||||
printf("unload 3\n");
|
||||
sceMp3TermResource();
|
||||
|
||||
printf("unload 4\n");
|
||||
sceIoClose(m_fileHandle);
|
||||
|
||||
printf("unload 5\n");
|
||||
//delete[] m_inBuffer;
|
||||
|
||||
printf("unload 6\n");
|
||||
//delete[] m_outBuffer;
|
||||
|
||||
printf("unload 7\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JMP3::update() {
|
||||
if (!m_paused) {
|
||||
if (sceMp3CheckStreamDataNeeded(m_mp3Handle) > 0) {
|
||||
fillBuffers();
|
||||
}
|
||||
|
||||
short* tempBuffer;
|
||||
int numDecoded = 0;
|
||||
|
||||
while (true) {
|
||||
numDecoded = sceMp3Decode(m_mp3Handle, &tempBuffer);
|
||||
if (numDecoded > 0)
|
||||
break;
|
||||
|
||||
int ret = sceMp3CheckStreamDataNeeded(m_mp3Handle);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
|
||||
fillBuffers();
|
||||
}
|
||||
|
||||
// Okay, let's see if we can't get something outputted :/
|
||||
if (numDecoded == 0 || numDecoded == 0x80671402) {
|
||||
sceMp3ResetPlayPosition(m_mp3Handle);
|
||||
if (!m_loop)
|
||||
m_paused = true;
|
||||
|
||||
m_samplesPlayed = 0;
|
||||
} else {
|
||||
if (m_channel < 0 || m_lastDecoded != numDecoded) {
|
||||
if (m_channel >= 0)
|
||||
sceAudioSRCChRelease();
|
||||
|
||||
m_channel = sceAudioSRCChReserve(numDecoded / (2 * m_numChannels), m_samplingRate, m_numChannels);
|
||||
}
|
||||
|
||||
// Output
|
||||
m_samplesPlayed += sceAudioSRCOutputBlocking(m_volume, tempBuffer);
|
||||
m_playTime = (m_samplingRate > 0) ? (m_samplesPlayed / m_samplingRate) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JMP3::play() {
|
||||
return (m_paused = false);
|
||||
}
|
||||
|
||||
bool JMP3::pause() {
|
||||
return (m_paused = true);
|
||||
}
|
||||
|
||||
bool JMP3::setLoop(bool loop) {
|
||||
sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0);
|
||||
return (m_loop = loop);
|
||||
}
|
||||
|
||||
int JMP3::setVolume(int volume) {
|
||||
return (m_volume = volume);
|
||||
}
|
||||
|
||||
int JMP3::playTime() const {
|
||||
return m_playTime;
|
||||
}
|
||||
|
||||
int JMP3::playTimeMinutes() {
|
||||
return m_playTime / 60;
|
||||
}
|
||||
|
||||
int JMP3::playTimeSeconds() {
|
||||
return m_playTime % 60;
|
||||
}
|
||||
+14
-43
@@ -10,8 +10,9 @@
|
||||
|
||||
#include "../include/JSoundSystem.h"
|
||||
#include "../include/JAudio.h"
|
||||
#include "../include/JCooleyesMP3.h"
|
||||
|
||||
#include "../include/JMP3.h"
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
JMusic::JMusic()
|
||||
{
|
||||
@@ -26,6 +27,10 @@ JMusic::~JMusic()
|
||||
delete mTrack;
|
||||
}
|
||||
|
||||
void JMusic::Update(){
|
||||
//if (mTrack) mTrack->update();
|
||||
}
|
||||
|
||||
JSample::JSample()
|
||||
{
|
||||
mSample = NULL;
|
||||
@@ -93,29 +98,17 @@ void JSoundSystem::DestroySoundSystem()
|
||||
|
||||
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
{
|
||||
//char s[strlen(fileName)+1];
|
||||
//strcpy(s, fileName);
|
||||
|
||||
string s = "Res/";
|
||||
s.append(fileName);
|
||||
JMusic *music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
music->mTrack = new JCooleyesMP3();
|
||||
if (music->mTrack)
|
||||
music->mTrack->Load(fileName);
|
||||
music->mTrack = new JMP3(s);
|
||||
}
|
||||
|
||||
JMP3::mInstance = music->mTrack;
|
||||
return music;
|
||||
}
|
||||
|
||||
// void JSoundSystem::FreeMusic(JMusic *music)
|
||||
// {
|
||||
// if (music)
|
||||
// {
|
||||
// if (music->mTrack)
|
||||
// delete music->mTrack;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
{
|
||||
@@ -132,30 +125,8 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
return sample;
|
||||
}
|
||||
|
||||
//
|
||||
// void JSoundSystem::FreeMusic(JMusic *music)
|
||||
// {
|
||||
// if (music)
|
||||
// {
|
||||
// if (music->mTrack)
|
||||
// {
|
||||
// music->mTrack->Release();
|
||||
// delete music->mTrack;
|
||||
// }
|
||||
// delete music;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// void JSoundSystem::FreeSample(JSample *sample)
|
||||
// {
|
||||
// if (sample)
|
||||
// {
|
||||
// releaseWaveData(sample->mSample);
|
||||
// delete sample;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
{
|
||||
@@ -174,8 +145,8 @@ void JSoundSystem::PlaySample(JSample *sample)
|
||||
|
||||
void JSoundSystem::SetVolume(int volume)
|
||||
{
|
||||
|
||||
mVolume = volume;
|
||||
JMP3 * mp3 = JMP3::mInstance;
|
||||
if (mp3) mp3->setVolume(volume);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +159,7 @@ void JSoundSystem::StopMusic(JMusic *music)
|
||||
|
||||
void JSoundSystem::ResumeMusic(JMusic *music)
|
||||
{
|
||||
ResumeMP3();
|
||||
ResumeMP3(music->mTrack);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable : 4786)
|
||||
extern int actualWidth;
|
||||
extern int actualHeight;
|
||||
#endif
|
||||
|
||||
#include "../../Dependencies/include/png.h"
|
||||
@@ -192,13 +194,16 @@ void JRenderer::DestroyRenderer()
|
||||
void JRenderer::BeginScene()
|
||||
{
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
||||
glLoadIdentity (); // Reset The Modelview Matrix
|
||||
|
||||
glLoadIdentity ();// Reset The Modelview Matrix
|
||||
float scaleH = (float)actualHeight/SCREEN_HEIGHT_F;
|
||||
float scaleW = (float)actualWidth/SCREEN_WIDTH_F;
|
||||
glScalef(scaleW,scaleW,1.f);
|
||||
}
|
||||
|
||||
|
||||
void JRenderer::EndScene()
|
||||
{
|
||||
|
||||
glFlush ();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ JMusic::JMusic()
|
||||
|
||||
}
|
||||
|
||||
void JMusic::Update(){
|
||||
}
|
||||
|
||||
JMusic::~JMusic()
|
||||
{
|
||||
JSoundSystem::GetInstance()->StopMusic(this);
|
||||
|
||||
+22
-9
@@ -10,7 +10,8 @@
|
||||
* Visit My Site At nehe.gamedev.net
|
||||
*/
|
||||
|
||||
|
||||
int actualWidth;
|
||||
int actualHeight;
|
||||
|
||||
#include <windows.h> // Header File For Windows
|
||||
#include <gl\gl.h> // Header File For The OpenGL32 Library
|
||||
@@ -42,6 +43,7 @@ HINSTANCE hInstance; // Holds The Instance Of The Application
|
||||
bool active=TRUE; // Window Active Flag Set To TRUE By Default
|
||||
bool fullscreen=FALSE; // Windowed Mode By Default
|
||||
|
||||
|
||||
DWORD lastTickCount;
|
||||
|
||||
BOOL g_keys[256];
|
||||
@@ -142,17 +144,20 @@ GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize Th
|
||||
height=1; // Making Height Equal One
|
||||
}
|
||||
|
||||
glViewport(0,0,width,height); // Reset The Current Viewport
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
|
||||
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
|
||||
glLoadIdentity(); // Reset The Projection Matrix
|
||||
glScissor(0, 0, width, height);
|
||||
glViewport (0, 0, width, height); // Reset The Current Viewport
|
||||
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
|
||||
glLoadIdentity (); // Reset The Projection Matrix
|
||||
|
||||
gluOrtho2D(0.0f, (float) width-1.0f, 0.0f, (float) height -1.0f);
|
||||
|
||||
// Calculate The Aspect Ratio Of The Window
|
||||
gluPerspective(75.0f,(GLfloat)width/(GLfloat)height,0.5f,1000.0f);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
||||
glLoadIdentity(); // Reset The Modelview Matrix
|
||||
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
|
||||
glLoadIdentity (); // Reset The Modelview Matrix
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
|
||||
@@ -303,6 +308,11 @@ GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
|
||||
|
||||
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
|
||||
{
|
||||
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
|
||||
|
||||
GLuint PixelFormat; // Holds The Results After Searching For A Match
|
||||
WNDCLASS wc; // Windows Class Structure
|
||||
DWORD dwExStyle; // Window Extended Style
|
||||
@@ -373,6 +383,8 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscree
|
||||
dwStyle= WS_OVERLAPPED | \
|
||||
WS_CAPTION | \
|
||||
WS_MINIMIZEBOX |
|
||||
WS_SIZEBOX |
|
||||
WS_MAXIMIZEBOX |
|
||||
//WS_MINIMIZE |
|
||||
WS_SYSMENU;// | \
|
||||
//WS_THICKFRAME ;
|
||||
@@ -565,6 +577,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
|
||||
|
||||
case WM_SIZE: // Resize The OpenGL Window
|
||||
{
|
||||
|
||||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
|
||||
return 0; // Jump Back
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user