mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added more examples.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../../src/common.sh"
|
||||
@@ -25,6 +25,8 @@ struct PosColorVertex
|
||||
uint32_t m_abgr;
|
||||
};
|
||||
|
||||
static bgfx::VertexDecl s_PosColorDecl;
|
||||
|
||||
static PosColorVertex s_cubeVertices[8] =
|
||||
{
|
||||
{-1.0f, 1.0f, 1.0f, 0xff000000 },
|
||||
@@ -137,7 +139,6 @@ int _main_(int _argc, char** _argv)
|
||||
}
|
||||
|
||||
// Create vertex stream declaration.
|
||||
bgfx::VertexDecl s_PosColorDecl;
|
||||
s_PosColorDecl.begin();
|
||||
s_PosColorDecl.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float);
|
||||
s_PosColorDecl.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true);
|
||||
@@ -174,13 +175,21 @@ int _main_(int _argc, char** _argv)
|
||||
while (true)
|
||||
{
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if not other draw calls are submitted to view 0.
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::submit(0);
|
||||
|
||||
int64_t now = bx::getHPCounter();
|
||||
static int64_t last = now;
|
||||
const int64_t frameTime = now - last;
|
||||
last = now;
|
||||
const double freq = double(bx::getHPFrequency() );
|
||||
const double toMs = 1000.0/freq;
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/01-cube");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering simple static mesh.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
float at[3] = { 0.0f, 0.0f, 0.0f };
|
||||
float eye[3] = { 0.0f, 0.0f, -35.0f };
|
||||
|
||||
@@ -5,6 +5,8 @@ $input v_color0
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "../common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = v_color0;
|
||||
|
||||
@@ -3,96 +3,7 @@
|
||||
# License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
#
|
||||
|
||||
ifndef TARGET
|
||||
.PHONY: all
|
||||
all:;@echo Usage: make TARGET=# [clean]
|
||||
@echo TARGET=0 (dx9)
|
||||
@echo TARGET=2 (dx11)
|
||||
@echo TARGET=3 (nacl)
|
||||
@echo TARGET=4 (android)
|
||||
@echo TARGET=5 (linux)
|
||||
else
|
||||
SHADERC="../../../../tools/bin/shaderc"
|
||||
BGFX_DIR=../..
|
||||
RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
|
||||
|
||||
EXT=sc
|
||||
|
||||
ifeq ($(TARGET), 0)
|
||||
VS_FLAGS=--platform windows -p vs_2_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_2_a -O 3
|
||||
SHADER_PATH=shaders/dx9
|
||||
else
|
||||
ifeq ($(TARGET), 1)
|
||||
VS_FLAGS=--platform windows -p vs_4_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_4_0 -O 3
|
||||
SHADER_PATH=shaders/dx11
|
||||
else
|
||||
ifeq ($(TARGET), 2)
|
||||
VS_FLAGS=--platform nacl
|
||||
FS_FLAGS=--platform nacl
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 3)
|
||||
VS_FLAGS=--platform android
|
||||
FS_FLAGS=--platform android
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 4)
|
||||
VS_FLAGS=--platform linux -p 140
|
||||
FS_FLAGS=--platform linux -p 140
|
||||
SHADER_PATH=shaders/glsl
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
BUILD_OUTPUT_DIR=$(addprefix ./, $(SHADER_PATH))
|
||||
BUILD_INTERMEDIATE_DIR=$(addprefix ../../.build/, $(SHADER_PATH))
|
||||
|
||||
VS_SOURCES=$(wildcard vs_*.$(EXT))
|
||||
VS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(VS_SOURCES))))
|
||||
|
||||
FS_SOURCES=$(wildcard fs_*.$(EXT))
|
||||
FS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(FS_SOURCES))))
|
||||
|
||||
CMD_MKDIR=cmd /C "if not exist "$(subst /,\,$(1))" mkdir "$(subst /,\,$(1))""
|
||||
CMD_RMDIR=cmd /C "if exist "$(subst /,\,$(1))" rmdir /S /Q "$(subst /,\,$(1))""
|
||||
|
||||
VS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(VS_SOURCES))))
|
||||
FS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(FS_SOURCES))))
|
||||
|
||||
BIN = $(VS_BIN) $(FS_BIN)
|
||||
ASM = $(VS_ASM) $(FS_ASM)
|
||||
|
||||
$(BUILD_INTERMEDIATE_DIR)/vs_%.bin : vs_%.$(EXT)
|
||||
@echo [$(<)]
|
||||
@$(SHADERC) $(VS_FLAGS) --type vertex --depends -o $(@) -f $(<)
|
||||
@cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
|
||||
|
||||
$(BUILD_INTERMEDIATE_DIR)/fs_%.bin : fs_%.$(EXT)
|
||||
@echo [$(<)]
|
||||
@$(SHADERC) $(FS_FLAGS) --type fragment --depends -o $(@) -f $(<)
|
||||
@cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
|
||||
|
||||
.PHONY: all
|
||||
all: dirs $(BIN)
|
||||
@echo Target $(SHADER_PATH)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo Cleaning...
|
||||
@-rm -vf $(BIN)
|
||||
@-$(call CMD_RMDIR,$(BUILD_INTERMEDIATE_DIR))
|
||||
|
||||
.PHONY: dirs
|
||||
dirs:
|
||||
@-$(call CMD_MKDIR,$(BUILD_INTERMEDIATE_DIR))
|
||||
@-$(call CMD_MKDIR,$(BUILD_OUTPUT_DIR))
|
||||
|
||||
.PHONY: rebuild
|
||||
rebuild: clean all
|
||||
|
||||
endif # TARGET
|
||||
|
||||
-include $(VS_DEPS)
|
||||
-include $(FS_DEPS)
|
||||
include $(BGFX_DIR)/premake/shader.mk
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,7 @@ $output v_color0
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "common.sh"
|
||||
#include "../common/common.sh"
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user